What variant of Codex are you using?
CLI
What feature would you like to see?
Problem
All hook events (SessionStart, PreToolUse, PostToolUse, UserPromptSubmit, Stop) fire identically for both the main agent and subagent sessions. The hook input JSON contains no field to distinguish between the two, making it impossible for hook scripts to apply logic only to the main session or only to subagents.
Claude Code already solves this
Claude Code includes agent_id and agent_type as common fields on all hook event inputs. From the hooks documentation: these fields are present for subagents and --agent sessions, allowing hook scripts to filter, route, or log differently based on context. This was added in v2.1.69: "Added agent_id (for subagents) and agent_type (for subagents and --agent) to hook events".
Codex already knows when a session is a subagent (SessionSource::SubAgent(...) at codex-rs/protocol/src/protocol.rs:2365) and already has a stable thread/session ID for each child session (e.g. codex-rs/core/src/tools/handlers/multi_agents/spawn.rs:163). Hooks just don't receive that metadata.
Additional information
No response
What variant of Codex are you using?
CLI
What feature would you like to see?
Problem
All hook events (SessionStart, PreToolUse, PostToolUse, UserPromptSubmit, Stop) fire identically for both the main agent and subagent sessions. The hook input JSON contains no field to distinguish between the two, making it impossible for hook scripts to apply logic only to the main session or only to subagents.
Claude Code already solves this
Claude Code includes
agent_idandagent_typeas common fields on all hook event inputs. From the hooks documentation: these fields are present for subagents and--agentsessions, allowing hook scripts to filter, route, or log differently based on context. This was added in v2.1.69: "Addedagent_id(for subagents) andagent_type(for subagents and--agent) to hook events".Codex already knows when a session is a subagent (
SessionSource::SubAgent(...)atcodex-rs/protocol/src/protocol.rs:2365) and already has a stable thread/session ID for each child session (e.g.codex-rs/core/src/tools/handlers/multi_agents/spawn.rs:163). Hooks just don't receive that metadata.Additional information
No response