Session prep sheet not pulling end of last session #271
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I'm trying to run the session prep sheet tool and it appears to only be pulling from the first paragraph of last session's summary.
Root-caused and fixed. Your read was exactly right, and the mechanism is a single shared constant.
Cause
recent_sessions_context(webapp/backend/app/services/generation_service.py:192) truncated every recent session summary to_DEFAULT_RECENT_SUMMARY_CHARS = 800. Real summaries on the live instance:So it was drafting prep from roughly the opening third — "the first paragraph", precisely as reported.
Two problems, not one
Raising the cap alone would have been a half-fix.
_truncatekeepstext[:limit]— the beginning. For a prep sheet the end of the previous summary is the most valuable sentence in it: the cliffhanger, the unresolved threat, the door that just opened. Head-truncation discarded exactly the part that informs what happens next, which is why the symptom read as "not pulling end of last session" rather than merely "truncated".Fix
Budget per position rather than one flat cap:
_truncate_keeping_endskeeps the opening and the closing with a visible[…]marker between them, weighted toward the tailDeliberately bounded rather than unlimited: worst case is 3000 + 2×1000 = 5000 chars (~1.2k tokens) of recent-session context. Prompt size is not free — oversized prompts are what drive this endpoint to emit malformed JSON (#279), and
session_prepis itself a JSON-returning tool. Tripling the cap unbounded would have traded a visible bug for a quieter one.Affects both consumers of the builder:
session_prep(n=2) andarc_suggester(n=3).Worth noting the codebase already disagreed with itself here — the "previously on" recap builder caps the same kind of content at 2000 (
generation_service.py:1493), while this path used 800.Tests
New
tests/test_recent_sessions_context.py— 10 tests, since this builder had no coverage at all. Covers a realistic-length summary surviving intact, both ends surviving when over budget, the tail being favoured over the head, older sessions getting the smaller budget, total boundedness, and the empty/no-summary paths.Full backend suite running; will confirm before the PR.