Skip to content

fix(bookstack-agent): suppress reasoning text before tool calls#100

Merged
amrit110 merged 1 commit into
mainfrom
fix/bookstack-agent-suppress-thinking-text
Jun 16, 2026
Merged

fix(bookstack-agent): suppress reasoning text before tool calls#100
amrit110 merged 1 commit into
mainfrom
fix/bookstack-agent-suppress-thinking-text

Conversation

@amrit110

Copy link
Copy Markdown
Member

On-prem models like Qwen emit reasoning/thinking text in a plain text content block before using tools. Previously this appeared in the chat UI for the full duration of the tool-call turn, then vanished when the tool_use event finally arrived after get_final_message().

Root cause: text_chunk events fire in real-time but tool_use events (which clear the text) only fire after the complete response is received.

Fix:

  • In ask_stream, watch for content_block_start with type=tool_use inside the stream loop. When detected, immediately yield {"type": "text_clear"} and stop emitting text_chunk events for that turn.
  • In chat-page.tsx, handle text_clear by setting content: null.

The clear signal now arrives the moment the model begins a tool-call block — not after the full response — so transient reasoning text is never visible. Final-answer turns (no tool use) are unaffected and still stream character-by-character. Works with any model via the gateway.

On-prem models like Qwen emit reasoning/thinking text in a text content
block before using tools. Previously this appeared in the UI for the full
duration of the tool-call turn before being cleared by the tool_use event.

Fix: watch for content_block_start with type=tool_use inside the stream.
When detected, immediately yield a text_clear event so the UI discards any
rendered text, then suppress further text_chunk events for that turn.

The text_clear arrives as soon as the model signals a tool call — not after
the full response completes — so the transient reasoning text is never
visible to the user. Final-answer turns (no tool use) are unaffected and
still stream character-by-character.
@amrit110 amrit110 merged commit afc440e into main Jun 16, 2026
9 checks passed
@amrit110 amrit110 deleted the fix/bookstack-agent-suppress-thinking-text branch June 16, 2026 13:31
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.

1 participant