Skip to content

Commit e5a16b9

Browse files
Skobeltsynclaude
andcommitted
refactor(#2791): extract seedMessages/BudgetTracker/handleToolCalls — loop is now orchestration
Slice 2 (final) of decomposing the executeAgentic god-function. Slice 1 (#188) shipped snapshotOf + the exhaustive BudgetDecision when; this completes the remaining acceptance, behavior-preserving: - BudgetTracker (new) — the invocation's mutable budget state (turns/toolCalls/ totalTokens + effective caps + consecutive-tool counter + #966 threshold bookkeeping), the Stop/Extend/Checkpoint cap dispatch (resolveCapDecision), and the one SessionSnapshot builder. Counters that were ~15 loose `var`s + 3 local closures now live in one testable class. - seedMessages (new) — the fresh-run message seeding (system prompt + custom cache segments + user message + image-attachment dereference), symmetric to the existing restoreFromSnapshot. - handleToolCalls (new, ToolCallHandling.kt) — the ~185-line LlmResponse.ToolCalls arm, further split into dispatchToolCall / handleUnknownTool / emitToolOutcome / buildInterrupt so each unit stays well under the complexity thresholds. - accumulateUsage (new) — the cumulative TokenUsage merge, named. executeAgentic loop file: 739 -> 352 lines; the loop body reads as orchestration. No behavior change — every counter, listener, audit event, and ordering is preserved (full suite green). New BudgetTrackerTest (9) unit-tests the lifted state directly; LongParameterList stays off so the wide internal seams are fine. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d3c3352 commit e5a16b9

5 files changed

Lines changed: 654 additions & 443 deletions

File tree

0 commit comments

Comments
 (0)