Skip to content

[Provider] Antigravity session id keys on thread id alone, so parallel children of one parent share an upstream session #5033

Closed

Description

@lidge-jun

Client or integration

Codex CLI and Codex App, any flow that runs parallel subagents under one parent.

Provider or upstream service

Google Antigravity (Cloud Code Assist).

OpenCodex version

2.59.0 (dev).

Endpoint or capability

Upstream session identity for Cloud Code Assist requests.

Current behaviour

antigravitySessionId derives the upstream session from _clientThreadId alone. The general lane resolver deliberately keys on parent-plus-thread-id instead, because a thread id is only unique within its parent. The consequence is that parallel Codex children under one parent collapse onto a single upstream Antigravity session rather than getting one session each.

This is provable from source and does not need a reproduction: the two derivations are visibly different, and the general resolver's choice of parent-plus-thread is commented as deliberate.

It was found while investigating #5008 (intermittent first-send 400 on google-antigravity/gemini-3.8-flash). It is filed separately on purpose. It is a plausible amplifier for that report — collapsing concurrent turns onto one session lane is exactly the condition under which carried upstream state could interfere — but it has not been shown to be its cause, and it is worth fixing on its own terms regardless of how #5008 resolves.

Expected behaviour

Two concurrent children of the same parent should not share one upstream Antigravity session. The identity used here should be as unique as the one the general lane resolver builds, or there should be a recorded reason why this surface may key on less.

Minimal redacted request or reproduction

Static: compare the derivation in antigravitySessionId with the general lane resolver's parent-plus-thread-id key. No credentials or prompt content are involved.

Actual response or error

Not an error in itself. The observable effect is that concurrent children present as one upstream session.

Screenshots and supporting files

Not applicable.

Redacted configuration

Not applicable.

Activity

  1. added
    provider-compatibility
    provider
    on Sep 18, 2026
  2. Ingwannu commented on Sep 18, 2026

    @Ingwannu
    Owner

    Confirmed against current dev. The collision is real, and the narrow fix should not redefine _clientThreadId.

    request-prepare.ts currently sets _clientThreadId from x-codex-parent-thread-id, while antigravitySessionId() hashes that value through clientThreadAnchor(). In a fan-out, siblings therefore receive the same upstream session id. The general lane helper already has the correct identity rule: parent qualifies the child thread-id/session id, rather than replacing it.

    The safest implementation boundary is to derive a bounded provider-private Antigravity session scope from the inbound headers during request preparation (using the same parent-plus-specific precedence as sessionLaneIdFromRequest) and carry that scope into antigravitySessionId. Keep _clientThreadId unchanged because it also owns previous-response/replay semantics, and changing its meaning would widen the patch into continuation state.

    Required regressions:

    1. same parent plus different child thread ids produce different Antigravity session ids;
    2. the same parent/child pair remains stable across compaction and changed first-user text;
    3. parent-only clients retain their current stable identity;
    4. clients with no usable thread headers keep the existing first-user-text fallback;
    5. no raw parent or child id is emitted on the wire (only the existing bounded numeric hash).

    This should be fixed independently of #5008. Landing it removes a proven cross-child collision; it does not by itself prove or close the reporter's intermittent adjacency 400.

  3. added a commit that references this issue on Sep 18, 2026
    9939b88
  4. lidge-jun commented on Sep 18, 2026

    @lidge-jun
    OwnerAuthor

    Fixed on dev by #5054, merged as 9939b884f0.

    antigravitySessionId now anchors on the request's own thread-id, falling back to the parent id for clients that send only that. Your reading of the source was right: _clientThreadId carries x-codex-parent-thread-id, so every parallel child presented the same id.

    On the "or there should be a recorded reason why this surface may key on less" branch — it may not, but it also may not adopt the general lane key. codexConversationKeyFor is an HMAC under CODEX_LINEAGE_KEY = randomBytes(32), so it is process-random and changes across a proxy restart. This derivation's stated requirement is the opposite: identical on turn N and N+1, because the replay cache observes thought signatures on turn N's response and re-injects them on N+1's request. Taking the lane key would have fixed the sharing by introducing the instability the existing comment names as the failure mode. thread-id is Codex's own value and survives compaction and restart alike.

    Blast radius, stated exactly: a root turn presents thread-id equal to its parent id, so its anchor is byte-identical and nothing moves for a single-threaded conversation. A child's anchor moves once, at deploy, costing that conversation one turn of signature association. A client that sends no thread-id is unchanged.

    Also worth recording for whoever reads this next to #5008: this is now fixed, so if that report persists, collapsed session lanes are no longer available as the explanation.

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

    providerprovider-compatibility

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions