Skip to content

Go: Phase 6 — Compaction#4

Open
juliomenendez wants to merge 2 commits intoagent-framework-golang-phase5from
agent-framework-golang-phase6
Open

Go: Phase 6 — Compaction#4
juliomenendez wants to merge 2 commits intoagent-framework-golang-phase5from
agent-framework-golang-phase6

Conversation

@juliomenendez
Copy link
Copy Markdown
Owner

Summary

  • CompactionStrategy interface with Compact(ctx, messages) ([]Message, bool, error)
  • Tokenizer interface + CharEstimatorTokenizer (1 token per 4 chars)
  • TruncationStrategy — keeps last N non-system messages, always preserves system messages
  • SlidingWindowStrategy — drops oldest non-system messages until under token budget
  • SummarizationStrategy — uses a ChatClient to summarize older messages, keeps recent N untouched
  • PipelineStrategy — chains multiple strategies, stops at first that compacts
  • WithCompactionStrategy AgentOption — compaction runs in runCore before LLM call, doesn't affect history storage

Test plan

  • go test ./... -count=1 — all tests pass across 4 packages
  • go vet ./... — no issues
  • go mod tidy — module is clean
  • CharEstimatorTokenizer tests
  • TruncationStrategy tests (compaction, no-op, system-only)
  • SlidingWindowStrategy tests (token budget, no-op, system preservation)
  • SummarizationStrategy tests (LLM summary, no-op under budget)
  • PipelineStrategy tests (chain execution, no-op)
  • Agent integration tests (compaction reduces messages, no strategy = all messages)

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant