Skip to content

fix(codex): restore flattened optimized tool calls to their namespace - #2901

Merged
jlcodes99 merged 2 commits into
jlcodes99:mainfrom
jamie950315:fix/codex-optimized-tool-identity
Oct 27, 2026
Merged

jlcodes99 merged 2 commits into
jlcodes99:mainfrom
jamie950315:fix/codex-optimized-tool-identity

Conversation

@jamie950315

@jamie950315 jamie950315 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The native gateway restores a flattened upstream call such as
collaboration-optimize__wait_agent to collaboration__wait_agent, without a
namespace. Codex declares this tool as namespace: "collaboration" and
name: "wait_agent", so the restored call is rejected with:

unsupported call: collaboration__wait_agent

This breaks multi-agent coordination when an upstream provider returns the
flattened wire form. A chained CPA can also perform its own restoration first,
returning collaboration__wait_agent to Cockpit; that form needs the same
canonical identity when the original request declared the namespaced tool. The same restoration code is present in v1.3.73 and the
current main branch.

Changes

  • Restore the double-underscore wire form to a separate namespace and tool name,
    matching the existing dotted-name restoration.
  • Require a nonempty tool-name suffix.
  • Recover already-restored collaboration__tool calls from a chained CPA only
    when this request declared that collaboration tool and no explicit flat-name
    declaration conflicts. Unknown tools and other namespaces remain unchanged.
  • Update the completed-response regression assertion and cover flattened
    spawn/message/followup/wait calls in SSE item-added and item-done events.
  • Reuse the existing isolated official Codex CLI lifecycle fixture for both
    canonical and flattened upstream calls. Keep request-context gating, call IDs,
    arguments, input, and tool-result payloads intact.

Validation

Before the fix, the new restoration assertions fail and the flattened CLI
fixture reproduces unsupported call: collaboration__wait_agent.
After the fix:

  • 26 multi-agent compatibility tests pass, including the chained-CPA case,
    undeclared names, conflicting flat declarations, namespace isolation, and
    opaque payload preservation.
  • Both JSON/SSE/WebSocket lifecycle tests pass.
  • Canonical and optimized-flat official Codex CLI lifecycle cases passed.
  • An additional official CLI lifecycle case now passes with the chained CPA
    returning collaboration__tool. The parent reaches PARENT_DONE after actual
    child-runtime creation and continuation without an unsupported-call error.

The CLI cases use an installed official CLI with temporary homes/workspaces and
a scripted loopback provider under the existing macOS network sandbox; they do
not use live model inference or account credentials.

cargo test --manifest-path src-tauri/Cargo.toml --lib multi_agent_compat::tests -- --test-threads=1
cargo test --manifest-path src-tauri/Cargo.toml --lib multi_agent_lifecycle -- --test-threads=1
COCKPIT_PLAN_CODEX_BIN=/path/to/official/codex cargo test --manifest-path src-tauri/Cargo.toml --lib multi_agent_lifecycle_real_codex_cli_ -- --ignored --test-threads=1

cargo fmt --package cockpit-tools -- --check reports repository-wide formatting
differences, including untouched files. This PR keeps unrelated formatting out
of the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants