fix: bounded context assembly for analyzing and vision-check phases#225
Merged
Conversation
Phase logs are append-mode — multiple runs write to the same file. parseRealCostFromLog() was regex-matching ALL input_tokens/output_tokens across the entire file, inflating cumulative_tokens to billions. Fix: pass logSizeAtStart (already tracked) as startOffset to the parser, which slices the content to only the current run's output. Also fix fallbackTokens to use thisPhaseBytes instead of total log size. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…223) cycle_context.json exceeds 25k token read limit after ~5 stories, breaking phases that lack focused views. Extends the V2 context assembly pattern: - Add assembleAnalysisContext() and assembleVisionCheckContext() to produce bounded focused views (~18k and ~19k tokens vs 32k+ raw) - Add compactOlderStories() — compacts factory_decisions (array and string alternatives_considered), implemented items, and story_results at story boundaries - Wire assembly into rouge-loop.js phase dispatch and compaction after story completion - Update analyzing and vision-check prompts to read assembled views - 18 new tests covering compaction and assembly Tested against Irish Planning's real 154KB cycle_context.json — both assembled views stay under 25k limit even projected to 20-story milestones. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes #223 —
cycle_context.jsonexceeds 25k token read limit after ~5 stories, breaking the analyzing and vision-check phases.assembleAnalysisContext()andassembleVisionCheckContext()— bounded focused views for the two phases that lacked themcompactOlderStories()— compacts factory_decisions (handles both array and stringalternatives_considered), implemented items, and story_results at story boundariesrouge-loop.jsphase dispatch and compaction after story completionTested against production data
Irish Planning's real 154KB
cycle_context.json(32k+ tokens):analysis_context.json: 18,307 tokens ✓ (under 25k)vision_check_context.json: 19,521 tokens ✓ (under 25k)Test plan
alternatives_consideredpatterns🤖 Generated with Claude Code