fix(codex): preserve dynamic Hermes MCP context - #66170
Conversation
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Fix preserves dynamic Hermes MCP context (HERMES_KANBAN_*) when Codex starts stdio MCP servers as child processes. The HERMES_TOOLS_DYNAMIC_ENV_VARS allowlist explicitly excludes credential-adjacent variables (API_KEY, AUTH_TOKEN, BASE_URL suffixes), preventing cross-process credential leakage. Good security boundary design.
Reviewed by Hermes Agent
teknium1
left a comment
There was a problem hiding this comment.
Thanks for addressing the dynamic MCP environment handoff. The underlying issue is present on current main: hermes_cli/codex_runtime_plugin_migration.py:596-601 emits the managed stdio entry without Codex env_vars, so Codex has no configured forwarding allowlist.
Problems
HERMES_TOOLS_DYNAMIC_ENV_VARSomitsHERMES_KANBAN_CLAIM_LOCK. The dispatcher injects that value for each worker athermes_cli/kanban_db.py:8238-8239;kanban_heartbeatpasses it toheartbeat_claimattools/kanban_tools.py:776-782.heartbeat_claimonly renews when the supplied value matches the task's stored lock (hermes_cli/kanban_db.py:3694-3709), so the MCP child cannot extend the dispatched claim without this variable.
Suggested changes
- Add
HERMES_KANBAN_CLAIM_LOCKto the managed allowlist and cover it intests/hermes_cli/test_codex_runtime_plugin_migration.py.
Automated hermes-sweeper review.
| out: dict[str, Any] = { | ||
| "command": sys.executable, | ||
| "args": ["-m", "agent.transports.hermes_tools_mcp_server"], | ||
| "env_vars": list(HERMES_TOOLS_DYNAMIC_ENV_VARS), |
There was a problem hiding this comment.
Please also allowlist HERMES_KANBAN_CLAIM_LOCK. The dispatcher injects it for each worker, and kanban_heartbeat needs the identical lock to renew the claim; without it the MCP child falls back to its own host:pid and cannot update the dispatcher's claim.
What does this PR do?
Preserves Hermes' dynamic Kanban/runtime context when
hermes codexcreates or repairs the managedhermes-toolsMCP entry.The migration previously generated the managed MCP command and arguments but omitted the environment variables used to identify the active task, worker, profile, project, and launch context. Codex workers could therefore connect to
hermes-toolswhile losing the runtime context that makes native Kanban operations act on the correct task.This change makes those variables product-generated configuration. It preserves existing user-provided
env_vars, refreshes Hermes-managed dynamic values from the current process environment, and removes stale managed values when they are no longer present.Related Issue
None. Reproduced on v2026.7.7.2 and current
main; no matching issue or PR was found.Type of Change
Changes Made
hermes_cli/codex_runtime_plugin_migration.py.How to Test
scripts/run_tests.sh.bash scripts/run_tests.sh tests/hermes_cli/test_codex_runtime_plugin_migration.py.Also exercised on Ubuntu under WSL2 with a real Codex app-server worker: the generated MCP configuration carried the active Hermes context and native Kanban operations resolved the intended task without a shell fallback.
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass (focused mandatory-wrapper suite run: 67 passed)Documentation & Housekeeping
cli-config.yaml.exampleif I added/changed config keys (N/A; no user config key added)CONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows (N/A)Screenshots / Logs
Focused validation: 67 passed, 0 failed.