managarten/packages/shared-ai/src/planner
Till JS 8f283726b1 feat(agent-loop): activate retryLoopReminder via LoopState.recentCalls
Extends LoopState with a sliding window of the last N ExecutedCalls
(oldest-first), capped at LOOP_STATE_RECENT_CALLS_WINDOW = 5. The loop
maintains the window automatically; reminderChannel producers read it
without touching internal state.

This activates retryLoopReminder which was shape-only in faa472be9.
The guard now fires end-to-end: when round >= 3 and the tail-2 calls
both returned success:false, the LLM sees a "stop retrying, write a
summary instead" <reminder> on the next turn. The tail-2 check rather
than window-wide is deliberate — a flaky run with intermittent success
(F, F, F, OK, F) is not a retry loop, just flaky tools.

Why window=5: retry loops usually manifest within 2-3 consecutive
rounds; a 5-deep window gives room for burst-detection and
stale-tool heuristics without bloating the reminder channel. Cap
keeps the reminder producers O(5) regardless of loop length.

Tests: 3 new (sliding-window cap + slide + order in shared-ai, retry
composition + budget+retry chain + tail-only heuristic in mana-ai).
Total agent-loop tests now 74 across both packages.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 15:02:40 +02:00
..
index.ts feat(agent-loop): activate retryLoopReminder via LoopState.recentCalls 2026-04-23 15:02:40 +02:00
loop.test.ts feat(agent-loop): activate retryLoopReminder via LoopState.recentCalls 2026-04-23 15:02:40 +02:00
loop.ts feat(agent-loop): activate retryLoopReminder via LoopState.recentCalls 2026-04-23 15:02:40 +02:00
mock-llm.ts test(ai): promote MockLlmClient to a shared @mana/shared-ai export 2026-04-20 18:05:46 +02:00
parser.test.ts feat(shared-ai): extract planner + mission types to @mana/shared-ai 2026-04-15 00:01:57 +02:00
parser.ts feat(shared-ai): extract planner + mission types to @mana/shared-ai 2026-04-15 00:01:57 +02:00
prompt.ts chore(ai): P2 batch — prompt sync, perf, dedup, scope unification 2026-04-16 16:33:52 +02:00
system-prompt.ts feat(shared-ai): runPlannerLoop + compact system prompt for function calling 2026-04-20 15:31:01 +02:00
types.ts feat(ai): SSE streaming for foreground Mission Runner 2026-04-16 12:32:43 +02:00