Skip to content

Native Codex (ChatGPT OAuth) turns fail when Langfuse tracing is on: trace metadata rejected by the Responses API #3928

Description

@mabry1985

Every turn fails on a native Codex (ChatGPT OAuth) model when Langfuse tracing is on.

graph/middleware/trace_context.py TraceContextMiddleware._with_trace stamps Langfuse trace context into extra_body["metadata"] on any model client that has an extra_body attribute (since #1880, v0.96.0). That's right for the LiteLLM gateway, which reads metadata for trace correlation — but the native Codex client (CodexChatOpenAI) also has extra_body, and the OpenAI SDK merges it into the Responses request to https://chatgpt.com/backend-api/codex/responses, which rejects it:

Error code: 400 - {'detail': 'Unsupported parameter: metadata'}

Found by a live smoke of the dev instance (default model openai-codex:gpt-5.6-sol, LANGFUSE_* set): every A2A, /v1, /api/chat, subagent and aside turn on that model failed. Only affects clients that don't talk to the LiteLLM gateway.

Fix: stamp the metadata only when the client targets the gateway (or: never for native OAuth clients — Codex, and check the native Anthropic/Claude OAuth client too). Tests: native Codex client → request body has no metadata; gateway client → still stamped.

Activity

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

    bugSomething isn't workingneeds-infoIssue is missing required sections — see CONTRIBUTING.md (silent issue gate).priority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions