codemap icon indicating copy to clipboard operation
codemap copied to clipboard

hooks: agent id ignores --agent and mislabels sessions when one agent is launched from another

Open JordanCoin opened this issue 1 month ago • 0 comments

Symptom

Handoff history (`agent_history`) and session leases record a Codex session as `claude-code` when Codex was launched from a shell that already carries the Claude Code environment variable (for example from inside a Claude Code session). The reverse direction can mislabel too.

Cause

`detectAgentID` checks inherited environment variables in a fixed order and never looks at the explicit `--agent=` flag that the hook command line already carries.

Fix

Have the hook entrypoint export the agent it was invoked for and let `detectAgentID` prefer that over inherited environment.

JordanCoin avatar Oct 30 '26 19:10 JordanCoin