Repository navigation
fix(headroom): don't let trailing cache_control make compression a no-op #42948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5787c87
c2b7c98
e67ca82
b588587
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -807,6 +807,14 @@ async def apply_guardrail( | |
| protected_indices: Final = _protected_indices(messages, raw_retrieve_call_ids) | ||
| compressible: Final = [m for i, m in enumerate(messages) if i not in protected_indices] | ||
| if not compressible: | ||
| # Match the other early returns: leave a breadcrumb when compression | ||
| # is a no-op so Cost Optimization / DEBUG is not left with a silent | ||
| # "0 tokens compressed" and no explanation (#42939). | ||
|
Comment on lines
+810
to
+812
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Context Used: AGENTS.md (source) Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| verbose_proxy_logger.debug( | ||
| "Headroom: nothing compressible (protected=%s/%s); skipping compression", | ||
| len(protected_indices), | ||
| len(messages), | ||
| ) | ||
| return inputs | ||
|
|
||
| model: Final = self.headroom_model or request_data.get("model") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compress()can replace the result with a stub while retaining its top-level marker. The changed content can turn a cache read into a writeKnowledge Base Used: Protect cache-marked history during compression
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!