Repository navigation
fix(codex): a Codex chat keeps its Orca identity when the user's Codex config strips command environment variables - #30406
Conversation
…stricted shell environment policy Codex rebuilds each command's environment from the user's shell_environment_policy, so inherit = "core" dropped the chat id, marker, launcher and instance pin Orca gives the app-server. orca orchestration then could not tell which chat was calling. Every thread start and resume now sends those values as shell_environment_policy.set overrides, which Codex applies after its filter and merges per key.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 50 seconds. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
e75dc5b8-bd31-4160-be85-4e50d99a72df
📒 Files selected for processing: 5
src/main/codex/codex-structured-real-cli-command-env.test.tssrc/main/codex/codex-structured-session-acquire.tssrc/main/codex/codex-structured-session-adapter.test.tssrc/main/codex/codex-structured-thread-open.tssrc/main/runtime/structured-session-child-env.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
…econd key list The seal now returns the session values it set (identity, a registered worker's own handle, the CLI launcher, the instance pin and the blanked remote selectors) as commandEnv, and the composed launch carries it. The Codex acquire sends that plus the chat's scratch folder from its own visuals. This deletes the hand-kept key list, the handle prefix test and the delete-list re-check, so a key later added to the seal reaches each command too, and an inherited worker handle the seal never named no longer does.
|
Codex chats could lose their Orca identity when a user limited shell commands to core environment variables. Codex filtered the values Orca put on its process, so a chat could fail to create an orchestration Run or act as another terminal. The branch passes the chat’s own identity and CLI connection values through Codex’s per-thread environment settings on start and resume. Commands can identify the chat again, and inline visuals retain their folder, without editing the user’s Codex configuration. Round 2 continues the original review. The independent re-review agreed that all three items were fixed: the launch seal now returns the values it writes instead of maintaining a second selection list; the real-binary test accurately describes its user-shell-command coverage; and the PR body labels the deliberate PATH omission. No proven new issue was found. Readiness and performance source checks passed on Verified on that commit:
Deferred: non-empty Electron QA passed on
Since QA: one test-only commit, |
…ity, held-send revert Sleep (#28445) closes a workspace's chats through the same abort a close gives a registered start, re-aborts a start registered while it waited for the lane, and judges its receipt once the start it aborted has settled, so only a newer start reads as later work. Each adapter's owned-acquisition check covers the child it owns between acquire and open. Main's Sleep cases from the deleted surface lifetime suite move to the workspace Sleep suite, plus one for a starting agent. Codex (#30406): the split open sends the chat's command env overrides when it opens the thread; the adapter test keeps that assertion on the open's request. Revert of #30134 (#30572): the event sink, exit observation, Pi held-send wrapper and adapter heldSends overrides go with it; Pi dispatch submits through its turns again and its idle report is wired back.
ELI5
Some people tell Codex to give the commands it runs only a few basic environment variables (
[shell_environment_policy] inherit = "core"in~/.codex/config.toml). Orca tells a chat's commands which chat they belong to through environment variables, so for those people everyorcacommand a Codex chat ran forgot which chat it was. Orca now tells Codex, for each chat thread, to always keep those few variables.What Changed
Before: with
inherit = "core"(or"none"), a Codex chat asked to coordinate other agents failed at the first step.orca orchestration run-createreturnedno_active_sender_terminaland told the agent to pass a terminal handle it doesn't have; the agent then tried to open a terminal. As a worker in a workspace with exactly one other terminal, a chat's reply went out under that terminal's name into the wrong Run (tracked in #30402). Inline chat visuals also lost their folder.After: the chat's commands see its identity whatever the user's Codex policy is, so orchestration and visuals work as they do for everyone else. The user's Codex config is not changed.
Mechanism: Codex rebuilds each command's environment from
shell_environment_policy;inherit = "core"keeps only PATH, HOME, USER and a few others, and drops everything Orca put on the Codex process. Every thread start and resume now also sends per-thread configshell_environment_policy.set.<KEY>for the chat's own values: its session id, the "this is a chat" marker, a dispatched worker's own handle, the Orca launcher path, this Orca's data folder, the blanked remote-host selectors, and the visuals folder. Codex appliessetafter its filter and merges these per key, so the user'sinheritand their ownsetentries stay as written. The step that seals every chat's child process now also returns exactly the values it wrote, and Codex sends those plus the chat's visuals folder, so there is one source of truth: a value later added to that step reaches the commands too, and nothing new is saved. A terminal handle is sent only when that step named one (a registered worker's own handle), never one inherited from the pane that started Orca.Why
This is the common pattern for a host app whose agent calls back into it through a CLI: hand the per-thread values to Codex as
shell_environment_policy.setoverrides on every thread open. Alternatives considered:Not covered:
inherit = "core", and a set PATH would freeze it over the login shell's PATH restore. The chat reaches this Orca through the absolute launcher path (ORCA_CLI_COMMAND) and the data-folder pin (ORCA_USER_DATA_PATH) instead.inherit = "all"withinclude_only = [..., "ORCA_*"].include_only: Codex filterssetkeys too, and overriding that list would replace the user's.Linked Issue
Linear STA-11090. Tracked in #30402 (the misrouted worker reply; the routing half of that issue is separate).
Visual Proof
Real Codex chat (Codex 0.163.0) in a test copy of Orca on macOS, with the chat's Codex home set to
[shell_environment_policy] inherit = "core", same inputs on main and this branch.Before (main): the chat's
orca statuscannot find this Orca andrun-createfails (the command lost both the chat id and the pin to this Orca instance; an install at the default path instead fails withno_active_sender_terminal, as in the original report).After (this branch):
orca statusnames the chat as the caller andrun-createcreates the Run; with one ordinary terminal open, a bareorca orchestration checkacts as the chat, not the terminal; a resumed chat in a fresh Codex process keeps its identity; inline visuals still get their folder.Testing
Reproduced before the change with the real Codex 0.162.1 app-server, a throwaway Codex home containing only
inherit = "core", and Orca's start and resume requests: commands saw noORCA_*values; with the overrides they did, on start and on resume.New opt-in test
codex-structured-real-cli-command-env.test.ts(ORCA_REAL_CODEX_CLI_TEST=1, POSIX only, no account or model): runs a user shell command (thread/shellCommand) and proves the policy strips the id, then that it survives a new thread and a cold resume. The model's own command tool reads the sameshell_environment_policy.setin Codex's source; that path needs a model, so the test doesn't drive it.Updated the adapter test that builds the launch the production way, so CI pins the overrides on the thread request.
Six named test files on macOS (M4Air), installed Codex 0.163.0: 64 passed, 0 skipped.
Electron QA on macOS with a real Codex chat under
inherit = "core", main vs branch (screenshots above): main fails; on the branch the chat is the caller, creates a Run, a barecheckacts as the chat with another terminal open, a cold resume keeps the identity, inline visuals work, normal turns complete (4/4).I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Author: Brennan Benson (@BrennanKB5)
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)