fix(compression): protect the summary call from mid-flight interrupts (#23975) - #49928
Merged
Conversation
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-attribute |
2 |
First entries
run_agent.py:2984: [unresolved-attribute] unresolved-attribute: Object of type `Self@get_credits_spent_micros` has no attribute `_credits_session_start_micros`
tests/run_agent/test_credits_notices_toggle.py:76: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_credits_session_start_micros` on type `AIAgent`
✅ Fixed issues (1):
| Rule | Count |
|---|---|
invalid-assignment |
1 |
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to attribute `_credits_session_start_micros` of type `int`
Unchanged: 5914 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
Context compression is atomic, but a gateway interrupt (an incoming user message while the agent is busy) could abort the in-flight summary call. The Codex Responses aux stream polls the thread interrupt flag and raised InterruptedError unconditionally — so compression fell back to a degraded static 'summary unavailable' marker, losing the real handoff (#23975). Add a thread-local interrupt-protection flag (aux_interrupt_protection context manager) in auxiliary_client; the Codex stream's cancellation check honors it. The compressor wraps its summary call_llm in the context manager. Timeouts still fire (a hung call must die) and all other aux tasks (vision, web_extract, title_generation, …) stay interruptible. Re-entrant, so the main-model retry recursion is safe. Co-authored-by: konsisumer <der@konsi.org>
teknium1
force-pushed
the
fix/compression-interrupt-protection
branch
from
June 21, 2026 04:22
3eaa563 to
6332527
Compare
This was referenced Jun 21, 2026
12 tasks
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.
Summary
Context compression's summary call is now protected from a mid-flight gateway interrupt (#23975). Previously, an incoming user message while the agent was busy could abort the in-flight summary, causing compression to fall back to a degraded static "summary unavailable" marker — losing the real handoff.
Root cause: the Codex Responses auxiliary stream's cancellation check polls the thread interrupt flag and raised
InterruptedErrorunconditionally (agent/auxiliary_client.py). Compression is atomic — it must either complete the summary or cleanly defer — but the interrupt reached the in-flight call and triggered the fallback path.Changes
agent/auxiliary_client.py: add a thread-localaux_interrupt_protection()context manager +_aux_interrupt_protected()helper. The Codex stream's cancellation check now skips the interrupt poll when protection is active (is_interrupted() and not _aux_interrupt_protected()). Timeouts still fire (a hung call must die) and all other aux tasks (vision, web_extract, title_generation, …) stay interruptible.agent/context_compressor.py: wrap the summarycall_llminaux_interrupt_protection(). Re-entrant, so the main-model retry recursion is safe.Behavior
Verified the compressor wiring test fails without the
withwrap and passes with it. 107 passing across the compressor + interrupt-protection suites; 375 passing on the auxiliary-client surface.Credit
Salvaged the thread-local interrupt-protection approach from @konsisumer's PR #24001. Authorship preserved via co-author trailer; that PR closes pointing here.
Infographic