Skip to content

[BUG] Codex WebSocket session metrics lose model attribution after model switch #3027

Description

@GilKorzen

Description

When a Codex conversation switches models while keeping the same WebSocket connection open, Headroom can record the response metrics under unknown instead of the model that handled each turn. This makes per-model usage, savings, and cost reports inaccurate.

Reproduce Steps

  1. Run the OpenAI Responses WebSocket proxy.
  2. Keep one WebSocket session open.
  3. Send a turn using model-a and complete it.
  4. Send another turn on the same session using model-b and complete it.
  5. Inspect the recorded request metrics.

Minimal client frames:

{"type":"response.create","response":{"model":"model-a","input":"first turn"}}
{"type":"response.create","response":{"model":"model-b","input":"second turn"}}

Expected Behavior

The recorded models should be model-a, then model-b.

Actual Behavior

Before the fix, the same session recorded unknown, unknown. The failure was reproduced against an archived copy of main.

Code Sample

response.completed.response.model = model-a
response.completed.response.model = model-b
recorded metrics = [model-a, model-b]

Error Output

No exception is raised. The failure is incorrect telemetry attribution:

assert ['unknown', 'unknown'] == ['model-a', 'model-b']

Environment

  • Headroom version: source checkout at the pre-fix main revision
  • Python version: 3.13.3
  • OS: Windows (win32)
  • LLM Provider: OpenAI Codex Responses WebSocket

Additional Context

Codex can keep one connection open for a multi-turn conversation while the user changes models. Each completed turn should be attributed to the model that handled it so the dashboard and reports remain accurate across model changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions