The schema overload detector counted ALL isError tool results toward the consecutive-failure cap, including bash commands that returned non-zero exit codes (e.g. rg/grep exit 1 = 'no matches'). Three consecutive exploratory searches with no matches would trigger the cap and abort the session. Root cause: the allToolsFailed check used toolResults.every(r => r.isError) which conflates preparation-phase errors (schema validation, tool-not-found, tool-blocked) with execution-phase errors (the tool ran successfully but returned a non-zero exit code). Fix: track preparationErrorCount alongside tool results. Only preparation errors (schema/validation failures) increment the consecutive failure counter. Tool execution errors — like bash exit code 1 — are valid usage and do not count toward the cap. Also fixes pre-existing StopReason type mismatches in agent-loop tests (end_turn → stop, tool_use → toolUse). |
||
|---|---|---|
| .. | ||
| agent-loop.test.ts | ||
| agent-loop.ts | ||
| agent.test.ts | ||
| agent.ts | ||
| index.ts | ||
| proxy.ts | ||
| types.ts | ||