[Bug] processToolUse never sets isError for a non-zero shell exit, so --json and ACP report failed commands as successful
Description
processToolUse sets ToolResult.isError in only two places: a blocked pre-tool-use gate and the catch for a thrown handler. A shell command that runs and exits non-zero returns normally from execute_bash as a plain string, so isError stays undefined and the result is byte-for-byte indistinguishable from a clean run.
This is the same root cause as #1371, but on a different path. #1371's fix (#1390) sets isError in the streamed bash runner, which executeApprovedTool only uses when a live display area exists (tool-executor.tsx:104). Every other surface goes through processToolUse and is still affected.
Steps to Reproduce
const tm = new ToolManager();
setToolRegistryGetter(() => tm.getToolRegistry());
const result = await processToolUse({
id: 'c1',
function: {name: 'execute_bash', arguments: '{"command":"exit 7"}'},
});
Expected Behavior
result.isError === true for a command that exited non-zero.
Actual Behavior
isError = undefined
starts with Error: = false
content = "EXIT_CODE: 7\n"
clean run isError = undefined
Impact
--plain / --json plain/conversation.ts:712 counts a failed command as a successful lifecycle tool, and :729 files its output under result instead of error in the JSON report. A CI consumer parsing that output cannot tell a passing build from a failing one.
ACP acp-conversation.ts:726 derives the tool-call status directly from result.isError, so a client like Zed shows a failed build as completed.
(The subagent executor doesn't special-case bash or sniff Error: ; it likely needs the same treatment but I haven't confirmed it.)
Root Cause
execute_bash's handler returns a string, so the exit code never reaches the ToolResult that processToolUse builds. The exit code is present in the content as EXIT_CODE: n, but parsing it back out would just be more of the string-sniffing #1371 set out to remove.
Suggested Fix
Let a handler report failure without throwing, by widening the structured-output contract in types/core.ts:
export interface StructuredToolOutput {
llmContent: string;
structured?: JSONValue; // now optional
isError?: boolean; // new
}
processToolUse propagates it alongside structuredContent, and execute_bash's handler returns {llmContent, isError: bashRunFailed(result)} reusing the predicate #1390 adds.
Note the cost, which is why this was split out of #1390 rather than folded in: changing that handler's return type from string to an object breaks 17 tests in execute-bash.spec.tsx, including one named execute_bash returns plain string not JSON whose premise is the contract being changed. The model still receives plain text either way, since processToolUse unwraps llmContent — but the assertions need rewriting at the ToolResult level, and that deserves its own review.
Additional Context
Blocked on / follows #1390.
I would want to work on this, @will-lamerton @akramcodez please assign me the same if possible
Picking this up - a fix will follow shortly.