_error_detail() compared containment both ways to skip a rejection the CLI
had already reported. The reverse direction is wrong: a short errors[] entry
such as "Error" is a substring of every rejection, so the only mention of
the refused tool was dropped. That is the same silence #2539 is about.
Compare one way instead, after stripping the "Error: " prefix the CLI wraps
around the sentence it also reports. The intended dedupe still holds, and
both directions now have a regression test.
Layer the parts of #2546 that #2543 does not cover on top of #2543:
- Rewrite the system prompt's tool manifest so every advertised name is
the reachable mcp__deeptutor__<name> form, prune entries for tools the
call did not mount, and state plainly when no tools are mounted. A
bare-name call is rejected by the CLI, which is what kills the turn.
- Collect error text from tool_result blocks so a turn that dies right
after a rejected tool call still names it; the CLI's own errors[] /
result / subtype priority from #2543 is kept, rejections are appended
as evidence and never repeated.
Signed-off-by: evan188199-tech <evan188199-tech@users.noreply.github.com>
Verified against a live claude-agent-sdk 0.2.x run. A turn that ends on
the turn limit emits:
subtype='error_max_turns' is_error=True result=None
errors=['Reached maximum number of turns (1)']
result is None on that path, so the first version of this fix (which read
only result and subtype) produced our own paraphrase instead of the CLI's
sentence. It also missed the API-failure path entirely: that one arrives
as subtype='success' with is_error=True and the 'API Error: ...' prose in
result, so preferring the subtype would render a self-contradictory
'success'.
_result_detail() now follows the same order the SDK's own
_error_result_text() uses: errors[], then result, then a non-success
subtype, then api_error_status. Frames captured from the live run are
pinned as tests.
The Claude Code and CodeBuddy providers report failure as
finish_reason="error" with the reason carried in the result message's
text. The CLI only fills that text when the turn produced assistant
output, so a turn that dies on a rejected tool call or on max_turns ended
empty and reached the operator as a bare "Error calling Claude Code: "
with nothing after the colon (#2539).
- sdk_bridge: render a blank result through a new _result_detail(), which
keeps the CLI's own wording when present, maps the SDK's subtype
(error_max_turns / error_during_execution / error_max_budget_usd) to a
sentence, and never returns an empty string.
- claude_code / codebuddy providers: _friendly_error() names the exception
type for a blank exception instead of echoing nothing.
Both SDK backends share the bridge, so one fix covers both.