0.2.5
Fix
Infinite tool-call loop from evicting mid-turn agentic steps
In agentic mode, each tool-call step is a separate assistant message sharing the same parentID as the current user message. As steps accumulated, the cumulative token cost could exceed the gradient's rawBudget, causing tryFit to set a cutoff that dropped earlier steps from the current turn. The model saw only the most recent step(s) + the original user request, had no memory of prior work, and re-issued the same tool call — infinite loop.
Fix: tryFit now identifies the current turn (last user message + all following assistant messages) and treats it as an atomic protected unit:
- Reserves budget for the entire current turn upfront
- Returns
null(escalates to next layer) if the current turn alone exceedsrawBudget - Fills remaining budget with older messages — these are the only ones that can be evicted
- Marks current-turn messages as strip-protected for tool-output stripping
tryFitStable inherits the fix via its tryFit fallback.