Skip to content

[Bug]: Shadow-call interception reroutes gpt-6-luna user turns to the helper model #6921

Closed

Description

@witherhoard99

Client or integration

Codex CLI / direct HTTP reproduction

Area

Proxy and routing

Summary

With shadow-call interception enabled, ordinary gpt-6-luna user turns go to the helper target instead of OpenAI. Title helpers should use the configured target; user turns should retain their selected model.

Related to #2706. The self-target guard does not fix this when the target is a different model.

Reproduction

  1. Configure interception as shown below.
  2. Send a /v1/responses request with model: "gpt-6-luna" and this header:
    x-codex-turn-metadata: {"request_kind":"turn","thread_source":"user"}
    
  3. Check the usage ledger. The request goes to ninfer/qwen3.8-27b instead of openai/gpt-6-luna.

Version

Reproduced on 2.76.0 with Codex 0.162.0. The same interception conditions remain in v2.82.0 and the current dev branch, checked October 10, 2026.

Operating system

Fedora Linux 44

Provider and model

Requested OpenAI / gpt-6-luna; routed to ninfer / qwen3.8-27b.

Redacted configuration

{
  "shadowCallIntercept": {
    "enabled": true,
    "model": "ninfer/qwen3.8-27b"
  }
}

Cause and tested fix

Both interception paths in request-prepare.ts exclude spawned agents but do not check thread_source. Matching the model alone captures user conversations.

A local patch checks metadata before both the combo-target and concrete-target rewrites:

  • Exempt explicit user and subagent conversations.
  • Give explicit helper headers precedence, so title calls remain intercepted even when labelled request_kind: "turn".
  • Preserve interception when metadata is missing or malformed.

The patch passed 12 metadata cases and 10 routing cases. Live checks confirmed Luna user turns reached OpenAI and title helpers still reached ninfer. Interception stayed enabled.

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

  1. added
    bug
    proxy
    on Oct 10, 2026
  2. Ingwannu commented on Oct 11, 2026

    @Ingwannu
    Owner

    Confirmed by source inspection at trusted dev 433764e9d8: both intercept sites in src/server/responses/request-prepare.ts exclude spawned children, but neither uses an explicit user-thread source before rewriting a matching bare Luna model. src/lib/shadow-call.ts deliberately stopped exempting every request_kind: "turn" after #1684, so reverting to a request-kind-only exemption would regress real helpers.

    Your existing local fix/tests are useful evidence; please submit the focused patch as a PR against dev so we can review the actual header precedence and preserve your authorship. Keep user/subagent preservation and explicit helper detection together, with concrete-target and combo-target routing controls, missing/malformed metadata compatibility, and the existing self-target guard. Please name the exact helper headers/provenance in the PR rather than inferring helper identity from the slug alone.

    Also cover per-turn WebSocket metadata, not only the HTTP header: the bridge can retain connection-level headers while individual frames carry different metadata. A stale handshake user marker must not exempt later helper frames (nor should a helper handshake capture later user turns). No live provider call or fresh runtime reproduction was performed in this review; the reported live receipts remain yours.

  3. lidge-jun commented on Oct 11, 2026

    @lidge-jun
    Owner

    Fixed on dev by #6951 (b5f690b): explicit user turns and spawned children keep their selected model under shadow-call interception, and WebSocket uses per-frame turn metadata.

  4. witherhoard99 commented on Oct 11, 2026

    @witherhoard99
    Author

    Oh nice, I was still making the PR lol

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

    bugproxy

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions