Skip to content

[Bug]: Codex delegate_task children start with no threadSource, so their MCP servers see them as user threads #36520

Closed

Description

@ibanezji

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

  1. Add a stdio MCP server to ~/.codex/config.toml that logs params._meta["x-codex-turn-metadata"] on each tools/call.
  2. In T3 Code, open a Codex thread and have it call that tool.
  3. From that thread, start a Codex child with delegate_task and 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:

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/start with threadSource: "subagent": every later tool call's x-codex-turn-metadata carries "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

  1. juliusmarminge commented on Nov 14, 2026

    @juliusmarminge
    Member

    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.

  2. added
    needs more info
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs more info

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions