fix(agent-runtime): release an unclosed think-tag open as text at flush - #1173
Open
nordicnode wants to merge 1 commit into
Open
fix(agent-runtime): release an unclosed think-tag open as text at flush#1173nordicnode wants to merge 1 commit into
nordicnode wants to merge 1 commit into
Conversation
An explicit <think> open committed the rest of the step to the thinking box unconditionally, so when a model wrote the tag as prose (docs, quoted templates, a broken chat template) the visible answer landed in the thinking box and the user saw an empty or short reply. Give the explicit open the same treatment the implicit head already has: hold until a close settles the block as reasoning, and release the hold as text when the step ends without one — an answer is delayed, never swallowed. The budget stays implicit-head-only: a genuine think block can legitimately run long, and only its close (or flush) settles it. Refs CodebuffAI#1155
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
<think>open in the content stream no longer commits the rest of the step to the thinking box unconditionally: the hold is released as text atflush()when no close ever arrivesholdingForOpen): a close settles the held content as reasoning, a native reasoning chunk disarms it, and a step that ends without a close releases it as textIMPLICIT_OPEN_BUDGET_CHARSgive-up stays implicit-head-only — a genuine think block can legitimately run long, and only its close (or the end of the step) settles itWrite <think> like this in your docs), the hold-until-close streaming shape, the native-reasoning disarm, and the flush releaseThis addresses the answer-swallowing part of #1155 (the unclosed-think-tag bug): whenever a model emits the tag as prose — writing docs, quoting a template, or a lane whose chat template is broken — the visible answer landed in the thinking box and the user saw an empty or short reply. History still stores the raw text, so this is a display/reclassification fix, not context loss.
Validation
Re-run on the new main after the history rewrite:
bun test packages/agent-runtime/src/util/__tests__/think-tag-stream.test.ts— 24 pass, 0 failRefs #1155
Replaces #1161 — auto-closed when the repo history was force-pushed (the original commits no longer exist in the new history). Rebased onto the new main per the maintainer's request; picking the review up here.