Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Add a stdio MCP server to
~/.codex/config.tomlthat logsparams._meta["x-codex-turn-metadata"]on eachtools/call. - In T3 Code, open a Codex thread and have it call that tool.
- From that thread, start a Codex child with
delegate_taskand have the child call the same tool.
Expected behavior
The child's tool calls carry "thread_source": "subagent", so an MCP server can tell a delegated child from a thread the user opened.
Claude children can already be told apart: their processes get T3CODE_THREAD_ID=thread:delegated-task:…, while threads the user opens get a plain id.
Actual behavior
Neither call's turn metadata has a thread_source key, so the child looks exactly like a top-level thread. An MCP server has no other way to tell:
- its environment is the shared app-server's;
T3CODE_THREAD_IDreaches only shell commands, throughshell_environment_policy.set(fix(server): Codex sessions get T3CODE_THREAD_ID like Claude sessions #28604);- hooks don't have it either.
Cause. codexThreadRuntimeParams in apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts builds the thread/start params for ensureThread, and it never sets threadSource. The app-server already takes ThreadStartParams.threadSource ("client-supplied analytics source classification"), and T3's generated schema (packages/effect-codex-app-server/src/_generated/schema.gen.ts) already has the field.
Check. I drove codex app-server 0.169.0 directly:
thread/startwiththreadSource: "subagent": every later tool call'sx-codex-turn-metadatacarries"thread_source": "subagent";- the same call without the field, as T3 sends it: the key is absent.
Suggested fix. When the thread being started is a delegate_task child, add threadSource: "subagent" to its thread/start params. Leave threads the user opens unchanged.
Impact
Minor bug or occasional failure
Version or commit
T3 Code 0.1.9 (desktop); code read at main @ 2dd6cdd
Environment
macOS, codex-cli 0.169.0 (app-server), Claude Code 2.1.325
Logs or stack traces
Without threadSource, as T3 starts threads today:
"x-codex-turn-metadata": {
"session_id": "01a1d755-d21b-76d0-982f-dd6fb5c71ac3",
"thread_id": "01a1d755-d21b-76d0-982f-dd6fb5c71ac3",
"turn_id": "01a1d755-d259-7e73-8901-54d089438af1",
"codex_version": "0.169.0"
}With threadSource: "subagent":
"x-codex-turn-metadata": {
"session_id": "01a1d755-f399-7962-a6f4-99de55160382",
"thread_id": "01a1d755-f399-7962-a6f4-99de55160382",
"turn_id": "01a1d755-f3ca-7bf3-8272-63ce8886ca75",
"thread_source": "subagent",
"codex_version": "0.169.0"
}(Fields unrelated to this issue are trimmed.)
Screenshots, recordings, or supporting files
No response
Workaround
None on the MCP server side: no per-thread marker reaches its process or its hooks.
Investigated with Claude (an AI assistant): T3 source read at main @ 2dd6cdd, and Codex app-server behavior checked live.
Activity
juliusmarminge commentedon Nov 14, 2026
A fix for this was proposed in #36535, but when the reported steps were run in the real app the problem did not appear.
What was run on
a8e60d4602, the commit before this change:On each commit, configure the same stdio MCP logger for params._meta["x-codex-turn-metadata"]. Open a new Codex thread through the web client. Submit the same prompt asking the parent to call the logger with label parent, then use T3 delegate_task to create one new Codex child using gpt-6-luna without a worktree, have it call the same logger with label child, and wait for completion. Compare the actual logged metadata. Both base and head omitted thread_source for the parent and included thread_source: "subagent" for the child.
How: Manual real-app comparison: separate worktrees running vp run dev, fresh isolated T3 databases with T3CODE_DEV_SEED=0, synthetic project, isolated Codex homes, real Codex CLI 0.169.0 using gpt-6-luna. Web client driven through the preview browser at 1280x800 in light theme. Replay scenarios were unsuitable because this requires Codex-specific MCP behavior. Both recordings and screenshots were inspected; final screenshots matched a second capture taken at least 500 ms later. Servers, tabs, worktrees and scratch state were cleaned up.
Could you share the exact steps, what you see, and the version and platform you are on? The pull request is closed for now; the fix is picked up again once the problem can be shown.