singularity-forge/packages
Tom Boucher db7a6372a6 fix: cap consecutive tool validation failures to prevent stuck-loop (#3301)
* fix: cap consecutive tool validation failures to prevent stuck-loop (#2783)

When the LLM repeatedly emits tool calls with arguments that fail schema
validation, the agent loop retries indefinitely — each failed validation
returns an error tool result, the LLM retries with the same broken args,
and the cycle burns budget with no progress.

Add a consecutive-failure counter in runLoop that tracks turns where ALL
tool calls fail. After MAX_CONSECUTIVE_VALIDATION_FAILURES (3) consecutive
all-error turns, the loop emits a diagnostic stop message and terminates
cleanly. The counter resets whenever any tool call in a turn succeeds, so
intermittent failures do not trigger early termination.

Closes #2783

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: retrigger CI

* fix(test): repair agent-loop.test.ts — close unclosed blocks, merge imports

Two test suites were concatenated without closing the first suite's
it+describe blocks, placing the second suite's imports inside a function
body and triggering 'Unexpected "{" ' from esbuild. Merged into a single
well-structured file with consolidated imports and proper closings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: trek-e <trek-e@users.noreply.github.com>
2026-04-05 01:04:58 -04:00
..
daemon wip: M005 daemon — orchestrator, event bridge, formatter, batcher improvements (#2929) 2026-03-27 20:22:30 -06:00
mcp-server feat(mcp-server): add 6 read-only tools for project state queries (#3515) 2026-04-04 16:41:24 -05:00
native fix: align @gsd/native module type with compiled output (#3253) 2026-03-30 13:51:57 -06:00
pi-agent-core fix: cap consecutive tool validation failures to prevent stuck-loop (#3301) 2026-04-05 01:04:58 -04:00
pi-ai fix(pi-ai): extend repairToolJson to handle XML tags and truncated numbers 2026-04-04 03:59:55 -07:00
pi-coding-agent fix(extensions): use bundledExtensionKeys for conflict detection instead of broken path heuristic (#3305) 2026-04-05 01:04:50 -04:00
pi-tui fix: skip TUI render loop on non-TTY stdout to prevent CPU burn (#3095) (#3263) 2026-03-30 13:49:55 -06:00
rpc-client feat: Headless Integration Hardening & Release (M002) (#2811) 2026-03-26 23:33:22 -06:00