Skip to content

fix: keep "Building…" visible during tool calls + recover from empty responses#13

Merged
DoyleDev merged 1 commit into
mainfrom
fix/agent-loop-ux
May 20, 2026
Merged

fix: keep "Building…" visible during tool calls + recover from empty responses#13
DoyleDev merged 1 commit into
mainfrom
fix/agent-loop-ux

Conversation

@DoyleDev
Copy link
Copy Markdown
Collaborator

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:

  • Detect empty text response, surface a clear in-chat error ("Model returned an empty response — likely hit its token budget. Try sending 'continue' to resume…"). Message branches on whether the conversation had prior tool calls.
  • Bump `max_tokens` from 4096 → 16384 for chat completions and `max_output_tokens` 4096 → 16384 for Responses API. Gives Opus 4.7 (and others with extended thinking) breathing room. Also reduces tool-call argument truncation (the earlier sanitize-arguments fix dealt with the symptom; this raises the ceiling so it's less likely to happen).

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

  • Multi-step Opus 4.7 conversation that calls 5+ tools in sequence — bricks visible the whole time, no empty-response stall.
  • Sonnet conversation with a long stdio MCP call — bricks visible during the wait.
  • Intentionally low-budget request (e.g. paste a huge file into the chat) — if the model returns empty, user sees the error hint, not silence.

This pull request and its description were written by Isaac.

…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
@DoyleDev DoyleDev merged commit c1fda4c into main May 20, 2026
0 of 3 checks passed
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