-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
[Bug]: Codex runtime delays inbound user transcript writes until turn end, so WebChat/Control UI cannot see external messages immediately #83528
Copy link
Copy link
Closed
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
When a Feishu DM is routed to a session that runs on
Runtime: OpenAI Codex, the inbound user message is not mirrored into the session transcript immediately. As a result, WebChat / Control UI usually does not show the new inbound message until the Codex turn finishes and the assistant reply is mirrored.This makes external-channel sessions feel delayed or invisible from WebChat even though the gateway has already received and dispatched the inbound message.
Environment
2026.5.12OpenAI Codexsession.dmScope:per-channel-peeragent:main:feishu:direct:<open_id>Reproduction
Runtime: OpenAI Codex.Actual behavior
gateway.logshows the inbound message is received and dispatched immediately:received message from ...dispatching to agent (session=agent:main:feishu:direct:...)role=userentry at inbound time.Expected behavior
The inbound
role=usermessage should be appended to the session transcript as soon as the external message is accepted for the target session, so WebChat / Control UI can show it immediately. Assistant / tool results can continue to append later as the turn progresses or finishes.Root cause
The channel-turn record path updates session metadata / lastRoute, but does not append the actual inbound user transcript entry:
dist/kernel-5-rDHkvC.jsdist/session-BGECYHCy.jsdist/store-3qAZ3Zl6.jsFor Codex sessions, the real transcript write happens later through the Codex app-server transcript mirror:
mirrorTranscriptBestEffort(...)is called after the turn ends indist/run-attempt-DValQTsj.jsbuildResult()constructsmessagesSnapshotonly at that pointSo the inbound user message is effectively mirrored at turn-finalization time, not at inbound-dispatch time.
Why this looks wrong in UI
WebChat / Control UI reads the session transcript projection (
chat.historyrebuilt from durable transcript), not the raw external-channel inbound webhook stream. If the transcript does not receive the user message immediately, the UI has nothing durable to show for that inbound turn.Suggested fix
For Codex app-server turns:
turnId, append the inbound prompt to the transcript immediately with the same logical mirror identity used later:${turnId}:prompt.mirrorTranscriptBestEffort(...)call.This preserves the current end-of-turn mirror flow while making inbound messages visible immediately in WebChat / Control UI.
Related note
Using
Date.now()insidebuildResult()for the synthesized user message also means the mirrored user timestamp reflects turn-finalization time rather than true inbound time. Even if the delayed mirror is intentional, the timestamp is still misleading.