Skip to content

fix: bounded context assembly for analyzing and vision-check phases#225

Merged
gregario merged 2 commits into
mainfrom
fix/cycle-context-overflow-223
May 5, 2026
Merged

fix: bounded context assembly for analyzing and vision-check phases#225
gregario merged 2 commits into
mainfrom
fix/cycle-context-overflow-223

Conversation

@gregario

@gregario gregario commented May 5, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #223cycle_context.json exceeds 25k token read limit after ~5 stories, breaking the analyzing and vision-check phases.

  • Extends the V2 context assembly pattern with assembleAnalysisContext() and assembleVisionCheckContext() — bounded focused views for the two phases that lacked them
  • Adds compactOlderStories() — compacts factory_decisions (handles both array and string alternatives_considered), implemented items, and story_results at story boundaries
  • Wires assembly into rouge-loop.js phase dispatch and compaction after story completion
  • Updates analyzing and vision-check prompts to read assembled views instead of raw cycle_context
  • 18 new tests covering compaction idempotency, field preservation, and assembly correctness

Tested 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)
  • Projected after fix stories complete (~90 decisions): ~14-15k tokens

Test plan

  • 2,013 tests pass, 0 failures, 0 regressions
  • Assembly functions tested with real Irish Planning data
  • Compaction handles both array and string alternatives_considered patterns
  • Analyzer and vision-check prompt behavioral tests pass
  • Resume Irish Planning loop — will exercise new code paths when fix stories complete and milestone re-evaluates

🤖 Generated with Claude Code

gregario and others added 2 commits May 5, 2026 00:29
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>
@gregario gregario merged commit ec210b1 into main May 5, 2026
1 of 3 checks passed
@gregario gregario deleted the fix/cycle-context-overflow-223 branch May 5, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: cycle_context.json exceeds phase agent read limits after ~5 stories

1 participant