Repository navigation
feat(kagent): compact long homelab-agent chats on qwen - #2240
Merged
Merged
Conversation
Backport kagent-dev/kagent#2791 (Go-runtime context compaction) into our agent runtime build, which moves a2a-go to v2.5.0 where #414 applies unmodified. homelab-agent folds all but its last 24 events into a rolling summary after any turn whose prompt reached 70k tokens.
myoung34
marked this pull request as ready for review
October 15, 2026 18:04
This was referenced Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A long homelab-agent chat on qwen grows until it hits the 131k context. Ollama then keeps 4 tokens plus the newest ~65k and silently drops the system prompt and tool definitions. kagent supports
spec.declarative.context.compaction, but the 0.10.3 Go runtime ignores it. The controller still writes the settings into the agent config and only reports them as "ignored" in theUnsupportedFeaturescondition.Solution
images/kagent-adk: addkagent-pr2791.patch, the agent-code part of kagent#2791, an open backport of #2790 (merged on main). It wires compaction into the Go runtime and bumpsgoogle.golang.org/adk/v22.1.0 → 2.3.0 (session/compaction) anda2a-go/v22.3.1 → 2.5.0.a2a-go-pr414.patchis now the upstream diff with no backport edit.context.compactionwithtokenThreshold: 70000andeventRetentionSize: 24. After a turn whose prompt reached 70k tokens, everything but the last 24 events folds into one rolling summary written by qwen (ADK's default prompt).0.10.3-a2a414-cap-compact. Also corrects the agent's stale "tools eat ~64k" comment: the measured fixed cost is ~31k.Notes
runner.go:319), so it can't rescue one long turn. The tool-result cap covers that.-fullimages build after thetrailing-whitespacehook. Inside the build, a2a-go's queue tests (with-race) and the wedge repro pass on v2.5.0, along with kagent'sadk/pkg/a2a,agent(including #2791's compaction tests) andrunner.kustomize build --enable-helmrenders the tag and the compaction block.Context compaction enabledat startup and append a compaction summary event once a turn passes 70k.kagent-pr2791.patchonce a kagent release includes #2790/#2791.