Skip to content

fix(codex): use profile Codex home for app-server workers - #57792

Open
ljsdut wants to merge 2 commits into
NousResearch:mainfrom
ljsdut:codex/kanban-profile-codex-home
Open

fix(codex): use profile Codex home for app-server workers#57792
ljsdut wants to merge 2 commits into
NousResearch:mainfrom
ljsdut:codex/kanban-profile-codex-home

Conversation

@ljsdut

@ljsdut ljsdut commented Jul 3, 2026

Copy link
Copy Markdown

Summary

  • Prefer $HERMES_HOME/codex-home for Codex app-server sessions when the active Hermes profile defines codex-home/config.toml.
  • Keep existing behavior for profiles without a profile-local Codex home.
  • Add a regression test covering a gateway/kanban-style worker that inherits a global CODEX_HOME but runs under a profile-scoped HERMES_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 global CODEX_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 as codex_home to CodexAppServerSession. This keeps the override profile-scoped and leaves profiles without codex-home on the existing inherited/global CODEX_HOME path.

Validation

  • Red/green regression test: test_uses_profile_codex_home_when_profile_defines_one
  • scripts/run_tests.sh tests/run_agent/test_codex_app_server_integration.py -q -> 29 passed
  • ruff check agent/codex_runtime.py tests/run_agent/test_codex_app_server_integration.py -> passed

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.
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint codex labels Jul 3, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:146 checks :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-home convention 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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

: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.

Comment thread agent/codex_runtime.py
if not hermes_home:
return None
try:
candidate = Path(hermes_home).expanduser() / "codex-home"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
@teknium1 teknium1 added the area/profiles Multi-profile isolation, HERMES_HOME scoping label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/profiles Multi-profile isolation, HERMES_HOME scoping codex comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants