Skip to content

Responses duplicate when Stream assistant messages is on #349

Closed

Description

@vertopolkaLF
Image

Activity

  1. jmbenedetto commented on Mar 7, 2026

    @jmbenedetto

    Confirmed from raw Codex session logs on macOS.

    In the local session JSONL, each assistant message is recorded twice in sequence:

    • event_msg with payload.type: "agent_message"
    • response_item with payload.type: "message", role: "assistant"

    I checked four sessions for the same repo on 2026-03-07 and all show a strict 1:1 duplicate-pair pattern:

    • session A: 17 duplicate pairs
    • session B: 21 duplicate pairs
    • session C: 4 duplicate pairs
    • session D: 6 duplicate pairs

    So this does not look like the model independently generating the same text twice. It looks like the UI/log consumer is rendering both record types when stream assistant messages is enabled.

    Environment details from the session metadata:

    • Codex CLI 0.111.0
    • observed with session sources exec and vscode

    If useful, I can provide a small repro parser against the JSONL format, but the key signal is that each duplicated visible message corresponds to one agent_message record immediately followed by one assistant response_item with identical text.

  2. ishaanrajiv commented on Mar 7, 2026

    @ishaanrajiv

    I can reproduce as well, on v0.0.4

    From what I can see, here's the root cause:

    • live assistant_text deltas are emitted and rendered incrementally during streaming
    • later, item.completed may arrive with payload.detail containing the full assistant message text
    • the completion path treats that detail as fallback content even when text was already emitted from streaming

    As a result, the full assistant response gets appended again on completion

    Have raised a PR for a fix: #381, but not sure if they are accepting external contributions.

  3. fabmnt commented on Mar 8, 2026

    @fabmnt

    I noticed the same bug on Windows 11. In the Codex app, the same thread looks fine, but in the t3code the response is duplicated (I have streaming responses enabled).

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions