GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(openai-chat): complete streams that end after output without terminal by Wibias · Pull Request #773 · lidge-jun/opencodex

Conversation

@Wibias

@Wibias Wibias commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Finalize OpenAI-chat adapter streams when the upstream closes after output without a terminal chunk.
  • Extend openai-chat EOF regression tests.

Fixes #735

Test plan

  • �un run test (openai-chat-eof tests)

Security

  • none

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Wibias
fix: address issue #735
cc81b9c
Fixes #735
@Wibias
Wibias requested review from Ingwannu and lidge-jun as code owners July 30, 2026 22:21
@Wibias Wibias mentioned this pull request Jul 30, 2026
sub2api sometimes returns a stream without a terminal signal, causing opencodex to wait indefinitely #735
Closed
2 tasks done
@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Wibias, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 15 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ffb64d53-d80e-4757-9313-f1bc98ca707c

📥 Commits

Reviewing files that changed from the base of the PR and between be177ea and 38173bf.

📒 Files selected for processing (2)
  • src/adapters/openai-chat.ts
  • tests/openai-chat-eof.test.ts

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot]
chatgpt-codex-connector Bot reviewed Jul 30, 2026
View reviewed changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc81b9c6de

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/adapters/openai-chat.ts
const pendingToolCalls: PendingToolCall[] = [];
let toolCallSeq = 0;
const flushToolCalls = function* (): Generator<AdapterEvent> {
if (pendingToolCalls.length > 0) sawOutput = true;

@chatgpt-codex-connector chatgpt-codex-connector Bot Jul 30, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject unfinished buffered tool calls at EOF

When EOF arrives after a tool-call delta but before finish_reason or [DONE], flushToolCalls() now sets sawOutput, causing the truncation check to emit done with potentially incomplete arguments instead of an error. The existing case in tests/openai-chat-parallel-stream.test.ts lines 143-149 demonstrates this with {"a":; the focused test now fails because it receives done rather than error. Keep terminal-less buffered tool calls on the failure path while applying the new EOF tolerance only to output that is safe to finalize.

AGENTS.md reference: src/AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/adapters/openai-chat.ts
const delta = choices[0].delta;
if (delta) {
if (typeof delta.reasoning_content === "string" && delta.reasoning_content.length > 0) {
sawOutput = true;

@chatgpt-codex-connector chatgpt-codex-connector Bot Jul 30, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Do not complete reasoning-only EOFs

When an upstream disconnects after emitting reasoning_content but before producing answer text or a terminal frame, this assignment makes the adapter yield done. For the default request shape, parseRequest sets hideThinkingSummary, so the bridge suppresses that reasoning and emits response.completed with no user-visible answer; a truncated reasoning turn is therefore reported as a successful empty response instead of a retryable failure. Only user-facing output that is safe to finalize should enable the EOF fallback, while reasoning-only EOFs should retain the truncation path.

AGENTS.md reference: src/AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added the bug Something isn't working label Jul 30, 2026
@Wibias
fix(openai-chat): fail closed on EOF with pending tool calls
38173bf
Issue #735 accepts finish-less EOF when text was emitted, but mid-call tool assembly without finish_reason must still surface truncation as error.
@Wibias

Wibias commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

[shipping-github] Merge-ready

  • \mergeStateStatus: CLEAN after fix \38173bf\ (pending tool-call EOF guard)
  • Cross-platform CI: all jobs green on latest push
  • No \CHANGES_REQUESTED; CodeRabbit SUCCESS
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias
Wibias merged commit 5718d44 into lidge-jun:dev Jul 30, 2026
10 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Wibias
Wibias deleted the fix/735-openai-chat-eof branch July 30, 2026 23:54
@Wibias Wibias mentioned this pull request Jul 30, 2026
Revert "fix(openai-chat): complete streams that end after output without terminal" #792
Merged
@Wibias
Wibias restored the fix/735-openai-chat-eof branch July 30, 2026 23:55
@Wibias Wibias mentioned this pull request Jul 30, 2026
fix(openai-chat): complete streams that end after output without terminal #793
Merged
3 tasks
lidge-jun added a commit that referenced this pull request Jul 31, 2026
@lidge-jun
fix(openai-chat): fail a truncated tool call before it is flushed as …
38f711b
…complete

At reader EOF the adapter flushed buffered tool calls and only then judged
whether the stream had terminated cleanly. `flushToolCalls()` emits
`tool_call_end`, so a socket that died mid-argument handed the client
`{"cmd":"l` as a COMPLETED call: a truncation reported as a successful tool
invocation, which is worse than an error because nothing downstream can tell
it apart from a real one.

The integrity check now runs before the flush. This adapter can still decide
at that point because it buffers tool calls; the Anthropic adapter forwards
fragments live and genuinely cannot, which is why the equivalent fix there
was reverted (see devlog 260731_pr_merge_round/021).

A usage frame does not launder it either. Usage counts as a terminal signal
for text streams, and without the separate branch a provider that sent usage
after dying mid-tool would still flush the partial call.

What this deliberately does NOT do is the other half of #735. PR #793 (and
#773 before it, merged then reverted by #792 with no recorded reason)
additionally completes text-only streams that end without a terminal frame.
That is a policy change, not a bug fix: it inverts two existing fail-closed
assertions in tests/openai-chat-eof.test.ts, which currently pin "content
without a terminator is truncation". Whether a relay's dropped terminal frame
should be forgiven is the maintainer's call, and the missing revert rationale
on #792 is exactly the context needed to make it. Attempting both halves here
is how the previous round burned three repair rounds on the Anthropic side.

So the narrowing half lands and the widening half does not. #735 stays open.

Tests, verified by ablation (disable the guard -> 13 pass / 2 fail, restore ->
15/15):

- a half-assembled tool call at EOF errors, emitting no tool_call_end or done
- a trailing usage frame does not rescue it
- a tool call closed by finish_reason still completes normally -- the control,
  without which the guard could fire on every well-formed tool turn

Adjacent suites green: adapter-usage, openai-chat-parallel-stream.
@Wibias
Wibias deleted the fix/735-openai-chat-eof branch July 31, 2026 08:30
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
@Wibias
Merge pull request lidge-jun#773 from Wibias/fix/735-openai-chat-eof
6236c5c
fix(openai-chat): complete streams that end after output without terminal
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
@lidge-jun
fix(openai-chat): fail a truncated tool call before it is flushed as …
91b655d
…complete

At reader EOF the adapter flushed buffered tool calls and only then judged
whether the stream had terminated cleanly. `flushToolCalls()` emits
`tool_call_end`, so a socket that died mid-argument handed the client
`{"cmd":"l` as a COMPLETED call: a truncation reported as a successful tool
invocation, which is worse than an error because nothing downstream can tell
it apart from a real one.

The integrity check now runs before the flush. This adapter can still decide
at that point because it buffers tool calls; the Anthropic adapter forwards
fragments live and genuinely cannot, which is why the equivalent fix there
was reverted (see devlog 260731_pr_merge_round/021).

A usage frame does not launder it either. Usage counts as a terminal signal
for text streams, and without the separate branch a provider that sent usage
after dying mid-tool would still flush the partial call.

What this deliberately does NOT do is the other half of lidge-jun#735. PR lidge-jun#793 (and
lidge-jun#773 before it, merged then reverted by lidge-jun#792 with no recorded reason)
additionally completes text-only streams that end without a terminal frame.
That is a policy change, not a bug fix: it inverts two existing fail-closed
assertions in tests/openai-chat-eof.test.ts, which currently pin "content
without a terminator is truncation". Whether a relay's dropped terminal frame
should be forgiven is the maintainer's call, and the missing revert rationale
on lidge-jun#792 is exactly the context needed to make it. Attempting both halves here
is how the previous round burned three repair rounds on the Anthropic side.

So the narrowing half lands and the widening half does not. lidge-jun#735 stays open.

Tests, verified by ablation (disable the guard -> 13 pass / 2 fail, restore ->
15/15):

- a half-assembled tool call at EOF errors, emitting no tool_call_end or done
- a trailing usage frame does not rescue it
- a tool call closed by finish_reason still completes normally -- the control,
  without which the guard could fire on every well-formed tool turn

Adjacent suites green: adapter-usage, openai-chat-parallel-stream.
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
@Wibias
merge(dev): resolve openai-chat EOF conflict for lidge-jun#793
6213406
Keep the restored lidge-jun#773 finish-less EOF rules (answer text required;
pending tool calls fail closed before flush) while taking tip's clearer
mid-tool-call truncation message.
@luvs01 luvs01 mentioned this pull request Oct 24, 2026
perf(proxy): bound CONNECT header buffering and avoid repeated prefix copies #7663
Merged
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@chatgpt-codex-connector chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] left review comments
@lidge-jun lidge-jun Awaiting requested review from lidge-jun lidge-jun is a code owner
@Ingwannu Ingwannu Awaiting requested review from Ingwannu Ingwannu is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

bug Something isn't working

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Wibias
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.