fix(codex): use profile Codex home for app-server workers - #57792
Conversation
Kanban workers are spawned as hermes -p <profile> and inherit CODEX_HOME from the long-lived gateway service. That makes profile-scoped Codex permission config ineffective for Codex app-server workers. When the active HERMES_HOME contains codex-home/config.toml, pass that directory to CodexAppServerSession so the Codex app-server child uses the profile-local Codex home. Profiles without a codex-home continue to inherit the existing global CODEX_HOME behavior.
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the worker inheritance path. Current main does copy the gateway environment for workers while setting profile HERMES_HOME (hermes_cli/kanban_db.py:8085-8099), and the Codex runtime only overrides CODEX_HOME when codex_home is supplied (agent/transports/codex_app_server.py:118-122).
Problems
agent/transports/codex_app_server.py:146checks:danger-full-access, but the supported built-in unrestricted profile is:danger-no-sandbox(hermes_cli/codex_runtime_plugin_migration.py:629-637). The added test therefore does not cover a supported profile.- The same branch drops the narrow Kanban sandbox overrides. The current runtime documentation calls those overrides the intended alternative to
:danger-no-sandbox(website/docs/user-guide/features/codex-app-server-runtime.md:102). - The implicit
$HERMES_HOME/codex-homeconvention conflicts with the current documented explicit-CODEX_HOME profile-isolation contract (website/docs/user-guide/features/codex-app-server-runtime.md:296-309).
Suggested changes
- Keep the narrow Kanban sandbox or obtain an explicit security design for changing it; do not gate it on the unmatched profile name.
- Resolve and document the profile-Codex-home precedence contract, including auth/setup behavior, before adopting automatic discovery.
Automated hermes-sweeper review.
| default_permissions = _codex_home_default_permissions( | ||
| spawn_env.get("CODEX_HOME") | ||
| ) | ||
| if default_permissions == _DANGER_DEFAULT_PERMISSIONS: |
There was a problem hiding this comment.
:danger-full-access is not the built-in unrestricted profile Hermes documents or emits; hermes_cli/codex_runtime_plugin_migration.py:629-637 identifies :danger-no-sandbox. This condition therefore misses the supported configuration, while its body removes the Kanban sandbox protections. Please retain the narrow overrides or establish a supported, tested security contract first.
| if not hermes_home: | ||
| return None | ||
| try: | ||
| candidate = Path(hermes_home).expanduser() / "codex-home" |
There was a problem hiding this comment.
This adds implicit profile Codex-home discovery, but current documentation deliberately keeps Codex state shared by default and requires explicit CODEX_HOME for profile isolation (website/docs/user-guide/features/codex-app-server-runtime.md:296-309). Please resolve that precedence/design contract and document setup/auth behavior before introducing this convention.
Summary
$HERMES_HOME/codex-homefor Codex app-server sessions when the active Hermes profile definescodex-home/config.toml.CODEX_HOMEbut runs under a profile-scopedHERMES_HOME.Root Cause
Kanban workers are spawned as
hermes -p <profile> chat -q ...from the long-lived gateway process. They inherit the gateway service environment, including any globalCODEX_HOME, instead of going through profile-specific wrappers. As a result, Codex app-server workers could ignore profile-scoped Codex configuration, including permission profiles needed by coding workers.Fix
When the active profile home contains
codex-home/config.toml, pass that directory ascodex_hometoCodexAppServerSession. This keeps the override profile-scoped and leaves profiles withoutcodex-homeon the existing inherited/globalCODEX_HOMEpath.Validation
test_uses_profile_codex_home_when_profile_defines_onescripts/run_tests.sh tests/run_agent/test_codex_app_server_integration.py -q-> 29 passedruff check agent/codex_runtime.py tests/run_agent/test_codex_app_server_integration.py-> passed