Skip to content

Agents: enable Codex parallel tool calls#53819

Closed
sasan1200 wants to merge 2 commits intoopenclaw:mainfrom
sasan1200:fix-codex-parallel-tool-calls
Closed

Agents: enable Codex parallel tool calls#53819
sasan1200 wants to merge 2 commits intoopenclaw:mainfrom
sasan1200:fix-codex-parallel-tool-calls

Conversation

@sasan1200
Copy link
Copy Markdown

@sasan1200 sasan1200 commented Mar 24, 2026

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem: src/agents/pi-embedded-runner/extra-params.ts applied parallel_tool_calls to openai-completions and openai-responses, but not openai-codex-responses.
  • Why it matters: openai-codex/gpt-5.3-codex sessions could serialize tool work by default, leading to extra assistant/tool rounds and unnecessary prompt replay costs.
  • What changed: the runner now applies parallel_tool_calls to openai-codex-responses and defaults openai-codex to parallel_tool_calls: true unless explicitly overridden.
  • What did NOT change (scope boundary): no other providers were changed, no tool policies changed, and explicit parallel_tool_calls: false / null overrides still win.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #
  • Related #

User-visible / Behavior Changes

openai-codex embedded runs now default to parallel tool calls on the responses API path unless explicitly disabled. This should reduce serialized tool loops and prompt replay cost for Codex workflows.

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local Node/tsx run from clean worktrees
  • Model/provider: openai-codex/gpt-5.3-codex
  • Integration/channel (if any): none
  • Relevant config (redacted): isolated temp state dir with only openai-codex:default auth + model store; minimal config pinned to openai-codex/gpt-5.3-codex; plugins disabled

Steps

  1. Run the same real embedded Codex workflow from a clean origin/main worktree with isolated state.
  2. Run the same workflow from this branch with the same prompt, auth profile, and isolated state.
  3. Compare settled transcript files for assistant turns, toolUse turns, and summed assistant token usage.

Expected

  • The patched branch should complete the same workflow with fewer serialized assistant/tool rounds and lower total token usage.

Actual

  • Settled transcript comparison:
    • origin/main: 19 assistant turns, 17 toolUse turns, 1,414,601 assistant tokens
    • this branch: 13 assistant turns, 12 toolUse turns, 961,260 assistant tokens
    • delta: -31.6% assistant turns, -29.4% toolUse turns, -32.0% assistant tokens

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:
    • Confirmed origin/main excluded openai-codex-responses from parallel_tool_calls handling in src/agents/pi-embedded-runner/extra-params.ts.
    • Ran pnpm test -- src/agents/pi-embedded-runner-extraparams.test.ts after adding Codex regression coverage.
    • Ran one real isolated openai-codex/gpt-5.3-codex workflow on origin/main and on this branch, then recomputed metrics from the settled transcript files.
  • Edge cases checked:
    • Explicit parallel_tool_calls values for Codex responses.
    • Default-on behavior for openai-codex.
    • Explicit false still disables the default.
  • What you did not verify:
    • More than one live end-to-end Codex scenario.
    • Behavior of every ordering-sensitive tool sequence under parallel execution.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: set parallel_tool_calls: false for the affected Codex model/provider config, or revert this commit
  • Files/config to restore: src/agents/pi-embedded-runner/extra-params.ts
  • Known bad symptoms reviewers should watch for: ordering-sensitive Codex workflows behaving differently because tool calls are no longer serialized by default

Risks and Mitigations

List only real risks for this PR. Add/remove entries as needed. If none, write None.

  • Risk: some Codex workflows may implicitly rely on serialized tool execution order.
    • Mitigation: explicit parallel_tool_calls: false still disables the new default, and the patch scope is limited to openai-codex responses.
  • Risk: the live improvement can vary by prompt/workflow.
    • Mitigation: unit coverage verifies the config behavior directly, and this PR includes one real before/after Codex comparison with transcript-backed numbers.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Mar 24, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 24, 2026

Greptile Summary

This PR enables parallel_tool_calls: true by default for the openai-codex provider when using the openai-codex-responses API, reducing serialized tool round-trips for Codex coding workloads.

  • Adds openai-codex-responses to the API guard in createParallelToolCallsWrapper so the injection path is reachable for Codex models.
  • Introduces resolveDefaultParallelToolCalls(provider, modelApi) which returns true only when both provider === "openai-codex" and modelApi === "openai-codex-responses", keeping all other providers/APIs unaffected.
  • Adds modelApi? as a new trailing optional parameter to applyExtraParamsToAgent to preserve backward compatibility with all existing call sites.
  • Wires params.model.api through in attempt.ts so the production path receives the correct API string.
  • Adds 4 targeted unit tests (default-on, camelCase override, snake_case override, non-Responses API no-op).
  • Existing null-override suppression and camelCase/snake_case aliasing are fully preserved.

Confidence Score: 5/5

  • This PR is safe to merge; the change is well-scoped, backward-compatible, and fully covered by new and existing tests.
  • The implementation is minimal and surgical: a new optional parameter appended to the end of applyExtraParamsToAgent, a pure function resolveDefaultParallelToolCalls, and a one-line expansion of the API guard. All existing callers omitting modelApi continue to behave identically. The only production call site (attempt.ts) is updated correctly. Four new tests cover the happy path and all meaningful override combinations. No regressions are introduced.
  • No files require special attention.

Reviews (1): Last reviewed commit: "fix(test): pass modelApi through to appl..." | Re-trigger Greptile

@sasan1200 sasan1200 changed the title fix(agents): enable Codex parallel tool calls Agents: enable Codex parallel tool calls Mar 24, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f7c1b45b8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/pi-embedded-runner-extraparams.test.ts Outdated
@sasan1200 sasan1200 force-pushed the fix-codex-parallel-tool-calls branch from 3f7c1b4 to 894e6bb Compare April 1, 2026 17:57
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 894e6bb799

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/agents/pi-embedded-runner-extraparams.test.ts
@steipete
Copy link
Copy Markdown
Contributor

Closing this as implemented after Codex review.

Current main already covers this request. Codex Responses is treated as a supported parallel_tool_calls API, GPT-5/OpenAI and openai-codex defaults now set parallel_tool_calls: true, and current tests cover both configured and default Codex Responses behavior.

What I checked:

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review notes: reviewed against 8f64cd3e4d83; fix evidence: commit 40be5ad58187.

@steipete steipete closed this Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants