Skip to content

Child agent turns overwrite the parent conversation's Anthropic reasoning-replay provenance #8632

Closed

Description

@CATMIAOZHI

Client or integration

Codex App

Area

Provider adapter

Summary

In a Claude conversation, spawning a subagent on another model costs the parent its replayed
thinking signatures: the parent's next request no longer matches the prefix it just sent.

Main thread runs anthropic/claude-opus-5-5; a spawn_agent child runs gpt-6-astra. The
child's request carries thread-id: <child> and x-codex-parent-thread-id: <parent>.
reasoningReplayConversationIdFromResponsesRequest
(src/server/request-log-conversation.ts:149) prefers clientThreadId over the request's own
thread-id, and request-prepare.ts:434 sets that from x-codex-parent-thread-id. Both turns
therefore resolve to the parent's replay scope.

When the child is served, commitReasoningReplayServingIdentity
(src/responses/reasoning-replay-cache.ts:271) records the child's provider/adapter/model tuple
under [principal, parent-thread] (servingIdentityFor). On the parent's next Claude turn,
reasoningReplayServingIdentityChange reports modelChanged/adapterChanged, and
core-replay.ts:163 sets _stripReasoningEncryptedContent, so every replayed thinking signature
is removed from the history.

Expected: a child turn changes only the child's own replay record. The parent's next request is
byte-identical to its previous one.

Reproduction

Offline; mock the Anthropic and chat upstreams and send three bodies to /v1/responses.

// 1. parent: Claude, with a replayed thinking envelope
send(claudeBody, { "thread-id": "parent-thread" });

// 2. child: another model, same prompt_cache_key, parent header present
send(gptBody, { "thread-id": "child-thread", "x-codex-parent-thread-id": "parent-thread" });

// 3. parent again: same body as (1)
send(claudeBody, { "thread-id": "parent-thread" });

expect(bodies[2].messages).toEqual(bodies[0].messages);

Observed on 2.97.0: body 3 differs from body 1, and the reasoning item's encrypted_content /
signature is gone.

The same defect reproduces on dev d1f36eda2 with a standalone script that calls
reasoningReplayConversationIdFromResponsesRequest and the serving-identity store directly.
No network and no provider call; the proxy config dir was pointed at a throwaway directory:

parent replay key: parent-thread
child  replay key: parent-thread
parent sees route change: {
  providerChanged: true,
  destinationChanged: true,
  adapterChanged: true,
  modelChanged: true,
  credentialChanged: true
}

A one-line check of the same defect:

reasoningReplayConversationIdFromResponsesRequest({
  clientThreadId: "parent-thread",
  threadIdHeader: "child-thread",
}); // returns "parent-thread"

Proposed fix

Prefer the request's own thread-id, then clientThreadId, then Cursor, then session_id.
clientThreadId stays the fallback, so d1edf0d's intent still holds: mixed headers that
describe one conversation keep sharing a record. A child carrying both headers simply stops
writing the parent's record. Log conversation ids and pool affinity are untouched.

Version

2.97.0 locally; the affected ordering is still present on dev d1f36eda2 (2.100.x).

Operating system

Windows 11.

Provider and model

Anthropic Messages adapter, anthropic/claude-opus-5-5, with a gpt-6-astra subagent.

Logs or error output

Sanitized difference between the parent's two bodies (body 1 -> body 3):

- { "type": "reasoning", "encrypted_content": "<env: signature>" }
+ (reasoning item dropped; signature no longer replayed)

Activity

  1. github-actions commented on Nov 13, 2026

    @github-actions
    Contributor

    Issue reopened

    The report now contains the information required by the automated check. Thanks for updating it.

  2. added
    bug
    provider
    on Nov 13, 2026
  3. Ingwannu commented on Nov 13, 2026

    @Ingwannu
    Owner

    The current shared helper still prefers the parent namespace when both headers are present, so the reported parent/child serving-provenance collision matches current source. #8634 is the focused fix under review; it has not landed.

    I reviewed that four-file change and allowed its existing matching-head CI. The remaining request is to update the owning reasoning/compact scope contract and add an offline parent A → child B → parent A serving-cache regression, retaining separate parent-only fallback and unchanged routing/cohort identity. This concerns reasoning provenance, not a blanket change to default-v1 previous_response_id ownership. No history/cache cleanup, native client invocation or paid model request is needed for that regression.

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

    bugprovider

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions