fix(agent-runtime): release an unclosed think-tag open as text at flush - #1161
Closed
nordicnode wants to merge 9045 commits into
Closed
fix(agent-runtime): release an unclosed think-tag open as text at flush#1161nordicnode wants to merge 9045 commits into
nordicnode wants to merge 9045 commits into
Conversation
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
bun test packages/agent-runtime/src/util/__tests__/think-tag-stream.test.tsbun test packages/agent-runtime/src/__tests__/stream-parser-think-leak.test.tsbun test packages/agent-runtime(585 pass; the 2prompts-schema-handlingfailures and 2agents-graveyardmodule-not-found errors pre-exist onmain— verified by stashing this change)Refs #1155