refactor(agent): inline turn-loop helpers; fix compact test cap regression - #228
Merged
Conversation
…ssion Inline the seven extracted private helpers (buildTurnSetup, streamLLM, recordAssistantMessage, checkMaxTurnsGuard, checkStuckLoopGuard, executeTurnTools, drainSnapshotWarnings) back into the main run() generator, collapsing an over-decomposed loop into one readable flow (PR #191 review follow-up). Behaviour is unchanged; agent.test.ts drops the now-obsolete unit tests that targeted those private methods. Also fix a self-inflicted regression in compact.test.ts: the "quotes the original first user task" test had its cap lowered to 5 (< KEEP_RECENT=10), which left an empty compaction head so compaction never ran and the assertion failed. Restore the cap to 25 (>KEEP_RECENT) with 50 messages so both pruning and compaction fire, as the original comment required. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
zjshen14
force-pushed
the
refactor/inline-agent-turn-loop
branch
from
June 6, 2026 16:28
0de5776 to
1a86802
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two things, both in the A5b context-management area:
Inline the turn-loop helpers —
buildTurnSetup,streamLLM,recordAssistantMessage,checkMaxTurnsGuard,checkStuckLoopGuard,executeTurnTools,drainSnapshotWarningsare folded back into the mainrun()generator (PR feat(A5b): auto-compact at turn boundary with safety gates #191 review follow-up). Behaviour unchanged;agent.test.tsdrops the unit tests that targeted those now-gone private methods. Net −95 lines.Fix a
compact.test.tsregression — the "quotes the original first user task" test had its cap lowered to5(belowKEEP_RECENT=10), which left an empty compaction head so compaction never ran and the assertion failed. Restored to cap25/ 50 messages so both pruning and compaction fire (as the original comment required).Why a fresh branch
This supersedes
fix/a5b-review-points, which had diverged (28 commits behind main, no open PR). This branch is the same refactor rebuilt cleanly on currentmain.Checks
typecheck·lint·format:check·test(665 passed) all green locally and via pre-push.🤖 Generated with Claude Code