When pi session JSONL exceeds AGENT_SESSION_MAX_BYTES, the runner now
compacts instead of silently dropping the session. Old turns are
summarized via pi --print --no-session (with concatenation fallback),
stored in mevy_brain at importance=4, and the session file is rewritten
with a compaction header + last N recent turns at full fidelity.
If compaction fails, a memory handoff is injected into the system prompt
via <session-reset-context> so the fresh session has context carryover.
Also:
- Extract sanitizeInboundText/truncateUtf8ByBytes to src/sanitize.ts
- Fix mojibake (double-encoded U+2500 box-drawing) in telegram.ts
- Add /compact Telegram command (admin-gated, inline keyboard)
- Delete superseded docs/internal/compact-implementation-plan.md
- Add AGENT_SESSION_COMPACT_ENABLED/KEEP_TURNS/MIN_ENTRIES config vars
---
Build: pass | Tests: pending — FreeBSD validation needed (Sam & Claude)