Commit Graph

5 Commits

Author SHA1 Message Date
Jack Chen 8e6bf9bde1
chore: cosmetic polish following #161 (#162)
- Restore backticks around `prompt` in `Agent.prompt()` comment.
- Drop two stray blank lines around `mergedRecent` in `summarizeMessages`.
- Collapse deliberation comments in the new context-strategy test to one line.
- Add JSDoc note on `contextStrategy.custom.compress` that it fires every turn including the first; implementations must self-gate.
2026-04-24 02:30:50 +08:00
Mark Galyan 11a1fb0ced
fix: resolve context compaction persistence and turn dropping (#161)
Replace `slice(initialMessages.length)` with an explicit `newMessages` accumulator so summarize/custom/sliding-window strategies that shrink conversation history no longer drop newly generated turns. Drops the `turns > 1` gate so oversized initial prompts can trigger compaction before the first LLM call.

Fixes #152.
2026-04-24 02:19:42 +08:00
JackChen 6de7bbd41f
feat: add rule-based compact context strategy (#111) (#119)
* feat: add rule-based compact context strategy (#111)

Add `contextStrategy: 'compact'` as a zero-LLM-cost alternative to `summarize`.
Instead of making an LLM call to compress everything into prose, it selectively
compresses old turns using structural rules:

- Preserve tool_use blocks (agent decisions) and error tool_results
- Replace long tool_result content with compact markers including tool name
- Truncate long assistant text blocks with head excerpts
- Keep recent turns (configurable via preserveRecentTurns) fully intact
- Detect already-compressed markers from compressToolResults to avoid double-processing

Closes #111

* fix: remove redundant length guard and fix compact type indentation
2026-04-16 23:34:50 +08:00
MrAvalonApple 629d9c8253 feat: implement synthetic framing for user messages and enhance context strategy handling 2026-04-12 00:18:36 +03:00
MrAvalonApple eb484d9bbf feat: add context management strategies (sliding-window, summarize, custom) to prevent unbounded conversation growth 2026-04-09 19:40:15 +03:00