Skip to content

codex: opt-in route where incode's toolbox runs every tool call; team identity reaches codex's MCP server - #17

Merged
blockmandev merged 2 commits into
mainfrom
claude/laughing-darwin-hyqkjj
Oct 20, 2026
Merged

blockmandev merged 2 commits into
mainfrom
claude/laughing-darwin-hyqkjj

Conversation

@blockmandev

Copy link
Copy Markdown
Member

Summary

codex through incode's tools (codex_tools: "incode" in admin.json, or INCODE_CODEX_TOOLS=incode)

  • Codex runs as the model only. Its own tools are switched off, and every tool call comes back over the existing MCP tool bridge to incode's toolbox, as the Claude route already does.
  • So incode's permission rules, guards, custom-command allowed-tools, hooks, sandbox and the memory engine's checks now apply to codex. runs_tools_here() is true on this route, so the "not enforced" notices stop.
  • Off by default (own): with it off, codex starts exactly as before, and a test pins the old command line on both the fresh and the resumed spawn.
  • How codex's tools are switched off (each override checked against codex 0.163.0 by watching the tool list it sends, because codex silently ignores unknown -c keys):
    • features.shell_tool, view_image, web_search, goals, request_user_input, sub-agents, apps, plugins, browser and computer use are switched off;
    • --ignore-user-config stops codex reading the operator's own config and MCP servers;
    • env_vars hands the bridge address and token to the tool server;
    • default_tools_approval_mode="approve" stops codex refusing incode's calls itself;
    • omit_tools_from=["deferred"] keeps incode's tools from being hidden behind codex's tool search.
  • apply_patch can't be removed (the model catalogue decides), so codex runs with sandbox_mode="read-only", which rejects a patch before it is applied (seen live).
  • Shared code: the bridged turn loop moved from claude_code.rs to tool_bridge.rs and is shared; the Claude route's behaviour is unchanged.
  • agy can't be bridged: it has no flag to switch its tools off, and takes MCP servers only through a persistent agy mcp add. Now written in agy.rs and the README.
  • Docs: README section "The codex route: whose tools", an evidence table in docs/ARCHITECTURE.md §5a, and docs/ROADMAP.md.

Fix: team messages from codex were unrouted

  • Codex gives an MCP stdio server only HOME, PATH and a few others, plus the variables named in env_vars. INCODE_TEAM_AS never reached the team server, so codex's messages were filed as unrouted.
  • The team server's override now names it. Older codex versions ignore the key.

Test plan

  • scripts/test-all.sh, all parts pass:
    • fmt, clippy -D warnings, cargo test --lib (2,117), --bins (52), sbx_engine, -p incord-sandbox;
    • the Python SDK, TypeScript SDK and VS Code extension suites.
  • Command lines: the old one pinned on both spawn paths; the bridged one checked, including what must not be passed.
  • The setting resolves through every layer, round-trips through admin.json and shows in --admin.
  • Codex 0.163's mcp_tool_call output parses; each call is shown once, under incode's id.
  • Flow test (Unix) with a stand-in codex calling Write over MCP: one write lands through incode's toolbox, and one is refused by a Write(secret.txt) deny rule with nothing written.
  • End to end with the real codex 0.163.0 binary through incode -t, against a local stand-in model endpoint
  • A turn with a real OpenAI model (needs a codex login). That's why the default stays own.
  • codex 0.145 and 0.153 binaries (covered from source only)

Generated by Claude Code

With `codex_tools: "incode"` in admin.json (or INCODE_CODEX_TOOLS=incode),
codex is driven like the Claude route: a model only, its own tools switched
off by `-c` overrides, `--ignore-user-config`, read-only + approval never,
and one MCP server — `incode --tool-server` — reached over the tool bridge.
runs_tools_here() is true there, so allowed-tools, permission rules, guards,
hooks, the engine and the OS sandbox apply and the "not enforced" notice
stops. The default stays `own`, byte-identical (argv pinned by a test),
until a turn with a real model has run this way.

Every override was read from codex's source (rust-v0.163.0, checked against
0.153.4 and 0.145.0) and measured on the 0.163.0 binary against a stand-in
Responses endpoint that recorded the tool list, then end to end through
`incode -t`: a scripted Write ran in the toolbox, a deny rule refused one,
and apply_patch (no switch exists) was rejected unrun.

- tool_bridge: the turn loop (Incoming, pump, Turn::open, drive, CANCELLED)
  factored out of claude_code and shared.
- codex: CodexTools, MODEL_ONLY_OVERRIDES, the bridge registration
  (env_vars — codex passes a stdio server only listed variables —, approve,
  required, tool_timeout_sec, omit_tools_from), bridged_command, run_bridged,
  toolbox forwarding, one line reader for both routes that does not show
  codex's echo of incode's own calls twice.
- admin: codex_tools, resolve_codex_tools, the report line.
- cli: codex_backend builds either route.
- agy: why it cannot be bridged. README, ARCHITECTURE §5a, ROADMAP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011DiH8n52ifWoCd5Kx2aHwT
Codex starts an MCP stdio server with only HOME, PATH and a few others plus
the variables named in its env_vars (codex rmcp-client/src/utils.rs), so
INCODE_TEAM_AS, set on codex's own process, never reached incode's team
server and its messages were filed as unrouted. The override now names it.
Found while bridging codex's tools; an older codex ignores the key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011DiH8n52ifWoCd5Kx2aHwT
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