Skip to content

fix(agent-runtime): release an unclosed think-tag open as text at flush - #1161

Closed
nordicnode wants to merge 9045 commits into
CodebuffAI:mainfrom
nordicnode:oss/think-tag-unclosed-open-1155
Closed

fix(agent-runtime): release an unclosed think-tag open as text at flush#1161
nordicnode wants to merge 9045 commits into
CodebuffAI:mainfrom
nordicnode:oss/think-tag-unclosed-open-1155

Conversation

@nordicnode

Copy link
Copy Markdown

Summary

  • an explicit <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 at flush() when no close ever arrives
  • give the explicit open the same hold machinery the implicit head already uses (holdingForOpen): 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 text
  • the IMPLICIT_OPEN_BUDGET_CHARS give-up stays implicit-head-only — a genuine think block can legitimately run long, and only its close (or the end of the step) settles it
  • add regression tests for the prose-quoted open (Write <think> like this in your docs), the hold-until-close streaming shape, the native-reasoning disarm, and the flush release

This 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.ts
  • bun test packages/agent-runtime/src/__tests__/stream-parser-think-leak.test.ts
  • bun test packages/agent-runtime (585 pass; the 2 prompts-schema-handling failures and 2 agents-graveyard module-not-found errors pre-exist on main — verified by stashing this change)

Refs #1155

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants