Repository navigation
Description
Client or integration
Codex App
Area
Provider adapter / Chat Completions → Responses bridge
Summary
A terminal assistant answer from an openai-chat provider can be rendered twice in Codex App when the synthesized Responses message omits phase.
The duplicated copies are separated by the App's processing summary (for example, "Processed 23s"), so the first copy appears to be classified as processing/commentary and the second as the final answer.
Only one upstream request and one assistant answer were produced. The duplication occurs while the App consumes the Responses-shaped events generated by OpenCodex.
Reproduction
- Configure a generic OpenAI-compatible Chat Completions provider with the
openai-chatadapter. - Expose a placeholder model such as
example-chat-modelto Codex App through OpenCodex's/v1/responsesendpoint. - Start a turn that returns one plain-text terminal answer and no tool calls.
- In an affected turn, observe the same answer once above the processing summary and again below it.
This may be timing-sensitive; the affected turn completed in about 23 seconds.
Version
@bitkyc08/opencodex 2.7.41
Operating system
macOS 26.4
Provider and model
Redacted generic OpenAI-compatible Chat Completions provider / example-chat-model
Redacted evidence
For the affected turn:
upstream HTTP requests: 1
upstream status: 200
agent_message events: 1
assistant response_item items: 1
task_complete events: 1
all recorded message texts: identical
assistant message phase: null / omitted
The single answer is represented in the session as:
event_msg.agent_message (live event)
response_item.message (persisted assistant item)
task_complete.last_agent_message (completion metadata)
The App displayed the live copy and then displayed the persisted/final copy again.
A native Responses comparison carries:
{"type":"message","role":"assistant","phase":"final_answer"}The bridged Chat Completions output carries the same message without phase.
The reasoning item in the affected turn contained only a blank summary, so the duplicate was not generated reasoning content. No retry or second upstream completion occurred.
Expected behavior
One terminal assistant answer should be rendered once as the final answer.
OpenCodex should preserve or synthesize enough phase information for Codex App to classify bridged output consistently.
Suggested mapping / implementation notes
The Chat Completions parser currently emits text deltas without a phase, and the Responses bridge only includes phase when the adapter event supplies one.
A safe fix likely needs turn-aware classification rather than assigning every text delta to final_answer:
- intermediate text before a tool call →
commentary - terminal assistant text after successful completion, with no pending tool call →
final_answer - keep
phaseconsistent acrossresponse.output_item.added,response.output_item.done, and the terminal response snapshot
A client-side deduplication fallback would also be useful, but OpenCodex owns the synthesized Responses shape for this adapter.
Relevant public source locations:
src/adapters/openai-chat.tssrc/bridge.ts
Upstream documentation
- OpenAI Chat Completions API: https://platform.openai.com/docs/api-reference/chat
- OpenAI Responses API: https://platform.openai.com/docs/api-reference/responses
Checks
- I searched existing issues and documentation.
- The request and response evidence is redacted.
- No secrets, account details, request IDs, conversation IDs, local paths, provider names, or private model names are included.
- The expected behavior is based on a concrete Codex App compatibility problem.
Activity
github-actions commentedon Jul 27, 2026
Ingwannu commentedon Jul 27, 2026
Confirmed against current
dev: this is a real bridge bug.openai-chatemits unphasedtext_deltaevents, andbridgeToResponsesSSE()currently finalizes the corresponding message without a phase in bothresponse.output_item.doneand the terminalresponse.completed.outputsnapshot. The non-streaming builder has the same omission. That matches the redacted session evidence and leaves Codex App to classify the live and persisted forms differently.Implementation plan:
commentary, while the current text closed by a clean successfuldonebecomesfinal_answer. Explicit adapter-provided phases remain unchanged.response.output_item.doneand the terminal response snapshot, using the same item ID, and mirror the rule in non-streaming JSON. The initial streamingoutput_item.addedmust remain unphased until the future boundary is known; buffering the whole answer just to label that provisional event would regress live streaming.dev.Ingwannu commentedon Jul 27, 2026
Fixed and pushed to
devind2cc3f65.The bridge now keeps unphased live Chat Completions text provisional and assigns the authoritative phase at the boundary where it becomes knowable:
commentary;donefinalizes the current text asfinal_answer;The inferred phase is preserved on the same message ID in
response.output_item.doneandresponse.completed.output, and the non-streaming JSON path uses the same rule. The initialoutput_item.addedremains unphased rather than buffering and delaying the live stream.Regression coverage includes one unphased terminal answer, pre-tool commentary, and explicit-phase preservation. Validation passed: 118 focused tests, typecheck, and the full pre-push gate (
5,022 passed / 0 failed), including GUI lint and privacy scan. Closing as fixed.