You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Codex hooks don't receive T3CODE_THREAD_ID, so they can't tell a delegate_task child from its parent
#39825
Hooks on Claude threads can read T3CODE_THREAD_ID. Hooks on Codex threads can't. So a Codex hook can't tell which T3 thread it runs in, or whether that thread is a delegate_task child (an id that starts with thread:delegated-task:).
I use this id to give different hook guidance to orchestrators and workers. A SessionStart or UserPromptSubmit hook reads the id and gives delegated children worker instructions instead of the orchestrator's. This works for Claude children. A Codex child's hook sees no id, so the child gets the orchestrator's guidance.
Cause
Claude: T3 sets T3CODE_THREAD_ID in the Claude process environment (apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts:1574 at v0.1.11). Hooks inherit it.
Codex hooks get neither. Codex builds each hook's environment from a snapshot of the app-server's own environment (std::env::vars_os() in codex-rs/hooks/src/registry.rs, used by codex-rs/hooks/src/engine/command_runner.rs, Codex rust-v0.170.0). It doesn't apply the thread's shell_environment_policy.
Steps to reproduce
Start T3 Code from an environment where T3CODE_THREAD_ID is not set. Configure a UserPromptSubmit hook that appends ${T3CODE_THREAD_ID:-unset} to a file, once for Codex and once for Claude Code. In Codex, trust the new hook in /hooks; untrusted hooks don't run.
In T3 Code, start a thread on each provider and ask it to run echo $T3CODE_THREAD_ID with the shell tool.
From each thread, start a child on the same provider with delegate_task, and give the child the same request in the task prompt.
In each of the four threads, compare the shell output with the line the hook wrote for that prompt.
Thread
Shell tool
Hook
Claude parent and child
the thread's own id
the thread's own id
Codex parent and child
the thread's own id
unset
The Codex hooks do run (a line is written for each prompt), but the value is unset. Expected: Codex hooks see the same id as the Codex shell.
Proposal
Any one of these would solve it:
Pass the id to Codex hooks per thread. Codex has no per-thread hook environment today, so this probably needs a Codex change, such as applying the thread's shell_environment_policy to hook commands.
A supported lookup from Codex ids to T3 threads. Codex hooks receive Codex's own thread id as session_id in the hook input. A lookup like the one MCP servers on Codex threads can't tell which T3 thread called them #37770 proposes for MCP servers (t3 thread show --provider-thread <id> --json) would let a hook find its T3 thread and check whether it is a delegated child. As a stopgap I read this mapping from the state database directly, which depends on internal schema.
A documented role signal. A supported way for any hook, on any provider, to tell that its session is a delegate_task child would cover this use case.
Related: #32870 (a documented way for hooks to detect a T3 session), #37770 (the same gap for MCP servers on Codex), #28542 / #28604 and #39375 / #39414 (the earlier Codex fixes for shells and stdio MCP servers).
Version
T3 Code 0.1.11, codex-cli 0.170.0, Linux.
Drafted by an AI agent (Claude Code) from the T3 Code 0.1.11 and Codex 0.170.0 sources.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Problem
Hooks on Claude threads can read
T3CODE_THREAD_ID. Hooks on Codex threads can't. So a Codex hook can't tell which T3 thread it runs in, or whether that thread is adelegate_taskchild (an id that starts withthread:delegated-task:).I use this id to give different hook guidance to orchestrators and workers. A
SessionStartorUserPromptSubmithook reads the id and gives delegated children worker instructions instead of the orchestrator's. This works for Claude children. A Codex child's hook sees no id, so the child gets the orchestrator's guidance.Cause
T3CODE_THREAD_IDin the Claude process environment (apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts:1574atv0.1.11). Hooks inherit it.thread/start,thread/resumeandthread/forkinstead:shell_environment_policy.set.T3CODE_THREAD_ID(fix(server): Codex sessions get T3CODE_THREAD_ID like Claude sessions #28604) andmcp_servers.<name>.env.T3CODE_THREAD_ID(fix(server): Codex stdio MCP servers receive T3CODE_THREAD_ID #39414), inCodexAdapterV2.ts:1551-1562. Shell commands and the stdio MCP servers T3 detects get the id.std::env::vars_os()incodex-rs/hooks/src/registry.rs, used bycodex-rs/hooks/src/engine/command_runner.rs, Codexrust-v0.170.0). It doesn't apply the thread'sshell_environment_policy.Steps to reproduce
T3CODE_THREAD_IDis not set. Configure aUserPromptSubmithook that appends${T3CODE_THREAD_ID:-unset}to a file, once for Codex and once for Claude Code. In Codex, trust the new hook in/hooks; untrusted hooks don't run.echo $T3CODE_THREAD_IDwith the shell tool.delegate_task, and give the child the same request in the task prompt.unsetThe Codex hooks do run (a line is written for each prompt), but the value is
unset. Expected: Codex hooks see the same id as the Codex shell.Proposal
Any one of these would solve it:
shell_environment_policyto hook commands.session_idin the hook input. A lookup like the one MCP servers on Codex threads can't tell which T3 thread called them #37770 proposes for MCP servers (t3 thread show --provider-thread <id> --json) would let a hook find its T3 thread and check whether it is a delegated child. As a stopgap I read this mapping from the state database directly, which depends on internal schema.delegate_taskchild would cover this use case.Related: #32870 (a documented way for hooks to detect a T3 session), #37770 (the same gap for MCP servers on Codex), #28542 / #28604 and #39375 / #39414 (the earlier Codex fixes for shells and stdio MCP servers).
Version
T3 Code 0.1.11, codex-cli 0.170.0, Linux.
Drafted by an AI agent (Claude Code) from the T3 Code 0.1.11 and Codex 0.170.0 sources.
All reactions