singularity-forge/packages/pi-agent-core/src
frizynn cd14a4c765 fix(agent-loop): schema overload cap ignores bash execution errors (#3618)
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).
2026-04-06 11:35:41 -03:00
..
agent-loop.test.ts fix(agent-loop): schema overload cap ignores bash execution errors (#3618) 2026-04-06 11:35:41 -03:00
agent-loop.ts fix(agent-loop): schema overload cap ignores bash execution errors (#3618) 2026-04-06 11:35:41 -03:00
agent.test.ts fix(footer): display active inference model during execution (#1982) 2026-03-22 17:06:49 -06:00
agent.ts feat(agent-core): add externalToolExecution mode for external providers 2026-03-25 12:57:47 -06:00
index.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
proxy.ts fix: handle pause_turn stop reason to prevent 400 errors with native web search (#2869) (#3248) 2026-03-30 13:51:18 -06:00
types.ts feat(agent-core): add externalToolExecution mode for external providers 2026-03-25 12:57:47 -06:00