D4: token budget — rolling transcript summary keeps long sessions bounded
Director sessions can run for hours; the context would grow without bound. Now a fixed live window of recent turns is sent each turn, and older turns are folded into a rolling per-session summary. - planContext (pure): summary covers [0, summarizedThrough); the live window is the rest. Once the window exceeds windowSize + SUMMARIZE_BATCH, the oldest turns fold down to the last windowSize — never leaving a gap between summary and window. - maybeSummarize (after each turn): folds the batch into AiSession.summary via a separate complete() call when a key is set, else a deterministic compaction (one compact line per turn, capped) — bounded with or without an LLM. - The summary already rides in the system prompt (it never displaces the grounded roster), so the closed-set anti-hallucination anchor is preserved as history scrolls. Pure windowing + deterministic-summary covered by unit tests. 395 tests green; lint clean; build OK. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user