Commit 31c881e
committed
refactor(server): replace custom compaction with AI SDK guided pruning
Collapse the four-stage compaction pipeline (prune, tool-output reduction,
LLM summarization, sliding-window fallback) into the shape the AI SDK
compaction guide recommends: one trigger threshold, one prune pass, one
deterministic prune-only fallback.
The sliding-window fallback is replaced by pruneMessages hard mode at all
four of its former call sites, which cannot orphan a tool call from its
result. LLM summarization and the split-turn dual-summary path are removed.
Token estimation stays image-aware rather than adopting the guide's
JSON.stringify heuristic, which would read a single base64 screenshot as
roughly 250K tokens.
Fixes three latent issues along the way: the chars-per-token constant was 3
in the estimator and 4 in the inflation guard, the fallback targeted a
looser budget than the trigger so a compaction could succeed and re-fire
immediately, and a zero or negative client-supplied context window produced
a threshold every request exceeded.1 parent 2a753f9 commit 31c881e
7 files changed
Lines changed: 767 additions & 2859 deletions
File tree
- packages/browseros-agent
- apps/server
- src/agent
- compaction
- tests/agent
0 commit comments