Repository navigation
feat: implement Codex as sandbox external agent (#2422) - #2536
Merged
Merged
Conversation
Add agentKind 'codex' as a first-class external sandbox runtime alongside Claude Code, Cursor, and Hermes: - Codex adapter (services/platform/lib/agent-adapters/codex/): headless `codex exec --json` with every posture key on -c overrides (the only config surface fresh + resume share), prompt on stdin behind the '-' sentinel, systemPromptAppend via developer_instructions, managed gateway via a custom Responses-API model provider whose bearer key rides env_key (never argv), BYO against OpenAI's own API with OPENAI_API_KEY, MCP servers with env_vars-whitelisted secrets, native web_search disabled for managed runs unless nativeWebTools. - JSONL parser mapped to AgentEvent (thread/turn/item events, usage on turn.completed, no zero-token usage rows), with a fixture captured from a real codex-cli 0.142.5 run. - Schema/UI/runtime wiring: agentKind literals, readiness, agent editor kind picker, model selector types, capability-based turn lifecycle. - Harden stored-kind coercions (steer delivery, turn recovery) with a PRODUCT_AGENT_SLUGS membership guard instead of per-slug ternaries. - Sandbox image installs pinned @openai/codex; container test covers it. - builtin-configs/agents/chat/codex.json composer agent; gpt-5.5 catalog entries carry nativeModelId for the BYO vendor-native dialect. - Docs (en/de/fr) + tale-daemon cross-links + locale strings. Closes #2422
yannickmonney
enabled auto-merge (squash)
July 7, 2026 06:04
yannickmonney
added a commit
that referenced
this pull request
Jul 7, 2026
…leet The budget was set at 4400 MB when the image was ~4.0 GB; the six external agent CLIs added since (Cursor #2481, Hermes #2500, Gemini #2535, Codex #2536, Pi #2550, OpenClaw #2555) grew it to ~4.9 GB and none of those PRs updated the budget, so the Validate images gate is red on main too. Document the fleet as a named cost and restore the ~10% headroom convention at 5400.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agentKind: codexas a first-class external sandbox runtime alongside Claude Code, Cursor, and Hermes (Claude Code parity for the chat composer path).buildExec+--jsonJSONL parser) underservices/platform/lib/agent-adapters/codex/, wired through the capability-based turn lifecycle, schema, agent editor, model selector, readiness, docs (en/de/fr), locales, and a shippedbuiltin-configs/agents/chat/codex.jsoncomposer agent.@openai/[email protected]; no wrapper needed — the CLI's native JSONL is the parse contract.Design decisions (each verified against the pinned codex-cli 0.142.5 binary locally)
codex exec … -reads the prompt from stdin; leading-dash prompts can't parse as flags and argv never leaks the prompt.-coverrides —codex exec resumeis a subcommand with a narrower flag surface (no-s/-C/--add-dir), so posture (approval_policy="never",sandbox_mode="danger-full-access"), provider, web-search denial,developer_instructions, and MCP servers all ride-c, identical for fresh and resumed turns.wire_api = "chat"was REMOVED in this Codex version (startup error); the adapter definesmodel_providers.talewithbase_url = <gateway>/openai/v1,wire_api = "responses", andenv_key = "TALE_GATEWAY_TOKEN"so the session virtual key rides env, never argv. Verified live against a mock Responses endpoint:Authorization: Bearer <VK>, full turn incl. real command execution.systemPromptAppend→developer_instructions— lands verbatim as a developer message in the request (verified in captured request bodies); never dropped.web_searchdefaults to LIVE under a full-access sandbox, so managed runs setweb_search="disabled"unlessnativeWebTools === true; BYO keeps native tools. The interactiverequest_user_inputtool needs no denial:codex execauto-declines it ("unavailable in Default mode", verified) — no hang, the agent asks in prose.codex exec resume <thread_id>verified end-to-end: samethread_idre-emitted, prior turns present in the next request;CODEX_HOME=/user/.runtime/home/.codexkeeps the session store on the /user volume.credentialPolicy.byoModelIdSource: 'vendor-native'(BYO talks to OpenAI's own API via a custom provider +OPENAI_API_KEYenv_key — nocodex loginstate); the shippedopenai/gpt-5.5(-pro)catalog entries now carrynativeModelIdso catalog refs translate correctly.mcp_servers.<id>.env_varswhitelist (verified: Codex forwards only whitelisted vars to MCP stdio servers).turn.completedonly; zero-token turns emit no usage event. No fallback-model claims anywhere: Codex has no availability chain and the docs say so.steer_delivery.tsandrecover_external_agent_turns.tscoerced stored agent kinds with=== 'cursor' ? … : 'claude-code'ternaries, which misroute every newer runtime (Hermes today, Codex now) — replaced with aPRODUCT_AGENT_SLUGSmembership guard (isProductAgentSlug).codex exec --jsonrun (sanitized); other item shapes are tested inline from the@openai/codex-sdktypings, which version with the CLI.Test plan
vitest --project server lib/agent-adapters(101 tests, incl. new Codex adapter/parse suites + chunk-split fixture replay)agentKind: codex(managed + byo); invalid-kind guard updatedvitest --project server --project pii— 74 860 passedmodel-selector, chat components, dashboard routes) — 339 passedbun run migrations:check(config snapshot data-safe), docs suite (166), i18n parity,tsc,oxlint,oxfmt, knipcontainer-sandbox-runtime-test.ts(needs Docker/CI)/openai/v1/responsesroute (needs a deployed stack)Closes #2422