Repository navigation
Studio: report a Claude reply cut off by the context window as truncated - #10557
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a5bd654d2
ℹ️ 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".
| const finalIncompleteReason = resolveIncompleteReason( | ||
| incompleteReason, | ||
| contextWindowExceeded, | ||
| ); |
There was a problem hiding this comment.
Preserve the context-window marker during durable recovery
When the tab reloads, closes, or otherwise hands an in-progress durable generation to scheduleGenerationRecovery, this live-adapter resolution is bypassed. The recovery loop in runtime-provider.tsx replays the new _toolEvent without recording it, and generationRecoveryMetadata stamps every completed run whose finishReason is "length" as { reason: "length" }; consequently, a recovered context-window-exhausted response is automatically continued up to three times—the behavior this change is intended to prevent. The durable recovery path must latch context_window_exceeded and persist context_window as well.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Checked, and this path cannot be reached: the two conditions are mutually exclusive.
context_window_exceeded has exactly one producer, _stream_anthropic (external_provider.py:3227), so it only ever rides an external-connection turn. Durable recovery only ever runs on a message whose metadata carries generationRunId (runtime-provider.tsx:1634 and :1981), and that id is assigned in a single place, chat-adapter.ts:6249, inside the durable admission branch. Admission requires generationCandidate, whose first clause is !isExternalRequest (chat-adapter.ts:4963).
So an external turn is never a durable candidate, never gets a generationRunId, and is never handed to scheduleGenerationRecovery -- generationRecoveryMetadata has no way to see a context-window-exhausted run and restamp it. If durable runs are ever extended to external connections the latch will have to travel with them, but today there is nothing to preserve here.
1a5bd65 to
00f5e1a
Compare
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Reproduction on GitHub Actions + before/after UI evidenceReviewed head The defect on Actions. Two branches off the same fresh upstream
What the user sees. The turn is driven for real through Studio's own backend; the connection's base URL points at a stand-in Messages API that streams a sentence ending mid-word and then reports
The reply itself is identical on both sides, ending at Verified against the API docs. Automatic continuation stays off it. Not reachable, checked: durable-run recovery cannot restamp such a turn as |
The stop_reason table falls back to finish_reason "stop", which is why a reply that filled the context window read as a finished answer until it was mapped. The fallback stays right for most reasons, but a truncating one added upstream is invisible until someone notices the symptom. Warn instead, naming the reason and the model. The context-window cases move in beside the refusal ones, which already cover streaming stop_reason translation through the same transport harness, rather than repeating that harness in a file of their own.
Mapping the stop reason to `length` made the turn read as truncated, but left it offering Continue, and left the reason itself easy to lose before the turn was saved. Continue cannot help here. Resuming replays the partial as more prompt against the window it just filled, and a hosted window is not the "Context Length" setting the other context messages point at, so the bar names the way out instead of offering the button. It is named even when nothing could be resumed: a tool-calling turn never can be, and Anthropic's hosted search and code execution make that the likeliest way to fill a window at all. The reason also has to survive to the saved turn. It now outranks whatever the client infers about how the stream ended, at every site that decides a reason, and is published the moment it arrives rather than at a terminal yield an abort skips -- with or without a body, since redacted thinking spends context while rendering as no text. `isProviderReportedReason` states the same rule for the bar, which holds a stamped reason rather than the latch.
|
Pushed two commits on top of your branch after reviewing it. Your commit is unchanged; this is a fast-forward.
The bar offered Continue for a cut that cannot be continued. Resuming replays the partial as more prompt against the window it just filled, which is the same reasoning behind keeping auto-continue off it, so the bar now names the way out instead of offering the button. It is named even when nothing could be resumed — The reason also had to survive to the saved turn. It was reaching the terminal yield and being dropped everywhere else: the error path reclassified it, an abort saved the reason latched before it arrived, and it was only published at a yield that nothing between the event and Not done, deliberately: Validation: backend 45 passed, frontend 1320/1321 (the failure is |
|
@codex review |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Lyxot
left a comment
There was a problem hiding this comment.
Approving. The stop reason is real and documented, the mapping is right, and the truncation now reaches the UI and OpenAI-compatible clients as a cut rather than a finished answer.
Note the last two commits are mine, so this approval is on the original change; a second maintainer eye on those two would be welcome.
CI is green apart from Repo tests (CPU), whose five failures (core-dump policy, installer handoff ordering, ROCm gfx1151) are pre-existing on main and unrelated to this branch.

When a long thread fills the context window, Anthropic ends the reply with a stop reason Studio did not know about, so it fell through to "stop". The message rendered as finished with no notice, and API clients got finish_reason stop for a reply that ended mid sentence.
It now maps to "length" like any other cut off reply, so the truncation notice and Continue button appear. Automatic continuation is not triggered, because replaying the partial into a full window fails the same way each time and would cost three extra requests.