Never compact. Not automatically, not manually. Instead, let it write ledgers and checklists or handover prompt if necessary, and start fresh sessions as often as possible.
Then you can let it run, and when it stops, point a fresh session to the ledger to pick up the work from where the previous one left off.
You can get more fancy by using something like GitHub issues for coordination too and have multiple sessions create issues and epics and others to work on that in isolated worktrees, but the spec-plan-ledger approach usually works great for small to medium large projects.