fix: keep "Building…" visible during tool calls + recover from empty responses#13
Merged
Conversation
…rom empty responses
Two real symptoms users hit during agentic loops:
1. The brick animation went away while tools were running. addMessageEl
for the "Calling tool: X" line removed the indicator and it didn't
come back until the whole iteration's tools finished. For slow
stdio MCP calls (3-10s), users saw "Calling tool:" then static
silence and assumed Mason was wedged.
2. Sometimes Opus 4.7 returned an *empty* text response after a tool
loop — extended thinking burned through the 4096 max_tokens budget
before any visible output. Mason silently rendered an empty
assistant bubble and exited the loop, looking dead.
Changes:
- src/chat.ts: call showThinking() right after the "Calling tool:"
message, so the brick stays visible while the tool actually runs.
- src/chat.ts: detect empty text response in result.type === "text"
and surface a clear in-chat error explaining the likely cause
("Model returned an empty response — likely hit its token budget").
Different message if there were prior tool calls (suggesting
'continue' to resume) vs not (suggesting retry or switch models).
- src/main.ts: bump max_tokens 4096 -> 16384 (both chat-completions
max_tokens and Responses API max_output_tokens). Gives extended-
thinking models like Opus 4.7 headroom before content output, and
reduces tool-call argument truncation (see prior sanitize fix).
Co-authored-by: Isaac
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
Two symptoms users hit during agentic tool loops, no version bump — meant to land on top of v1.4.1 (rebuild + re-release).
1. The brick indicator disappeared during tool execution. `addMessageEl("tool-call", "Calling tool: X")` removes the indicator. For slow stdio MCP calls (3-10s), users saw "Calling tool:" → static silence → result, and assumed Mason was stuck. Now `showThinking()` fires right after the "Calling tool:" line, so the bricks stay visible while the tool runs.
2. Opus 4.7 sometimes returned an empty text response after a tool loop. Extended-thinking models count thinking tokens against `max_tokens`; with the budget at 4096 and a complex multi-step request, the model burned the budget thinking and produced no visible output. Mason rendered an empty bubble and exited the loop — looked dead.
Fixes:
Lands on top of v1.4.1 — keeping the version at 1.4.1 per user request; user will rebuild and re-release.
Test plan
This pull request and its description were written by Isaac.