feat: add X-Cagent-Compacting header for session-compaction LLM calls - #3777
Merged
Conversation
Mirrors the existing X-Cagent-GeneratingTitle marker. DMR also skips model reconfiguration when compacting, matching title-generation behaviour. Assisted-By: Claude
Assisted-By: Claude
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The implementation is clean and correct. The X-Cagent-Compacting header follows the established X-Cagent-GeneratingTitle pattern faithfully across all five touch-points: the new WithCompacting()/Compacting() option pair, FromModelOptions propagation, the refactored GatewayHTTPOptions (nil-safe, emits both headers), the DMR skip-reconfiguration guard extension, and the compactor clone site. No bugs found in the changed code.
aheritier
approved these changes
Jul 21, 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.
Session-compaction (summary) LLM calls are currently indistinguishable from ordinary chat completions at the AI gateway layer. This means gateway-side policies — rate limiting, routing, cost attribution — cannot treat them differently from user-facing conversation turns. Adding an explicit marker gives the gateway a reliable signal it can act on, mirroring the already-established
X-Cagent-GeneratingTitlepattern.The change introduces an
X-Cagent-Compacting: 1HTTP header on gateway-bound requests that originate from the compactor. A newWithCompacting()option andCompacting()getter are added topkg/model/provider/options, andFromModelOptionsensures the flag survives provider cloning.GatewayHTTPOptionsin the base gateway is refactored to accept*options.ModelOptionsinstead of a baregeneratingTitle bool, which lets it emit both the title and compacting headers from a single options struct and treat a nil pointer as zero options. The anthropic, openai, and gemini gateway clients are updated accordingly, and the compactor clones its summary model withoptions.WithCompacting(). The DMR client's skip-reconfiguration guard is extended to cover compaction clones, which also overridemax_tokens.No breaking changes. The new header is purely additive; gateways that do not inspect it are unaffected.