Repository navigation
fix: prevent premature compaction on cold gateway resume - #1546
Merged
Merged
Conversation
Prevent provisional 128k fallback compaction while model discovery is pending. Add cold-restart integration, failure recovery, and admission publication regressions. Co-Authored-By: OpenAI <[email protected]>
jhrozek
approved these changes
Sep 15, 2026
jhrozek
left a comment
Contributor
There was a problem hiding this comment.
Panel review complete across four axes (spec, standards, test-adequacy, domain: architecture/security/reuse/duplication). No blockers on any axis.
- Spec: all three compaction-driving entry points gated; bounded-wait, override-preservation, and honest-unknown-model requirements verified and test-pinned.
- Standards: composition-only wiring confirmed (engine/agent untouched), ADR 0342 well-formed and correctly indexed, generated SDK artifacts consistent.
- Test adequacy: all 7 ACs covered; mutation-resistance to dropping the admission callback holds structurally.
- Domain: no Critical/High findings. A handful of Low/advisory polish items (variadic-as-optional-param, a 3x repeated resolveWindowCore call, a small tolerated duplication) — none blocking.
Approving.
Preserve updated gateway documentation alongside context-window admission and retry guidance. Co-Authored-By: OpenAI <[email protected]>
jhrozek
approved these changes
Sep 15, 2026
This was referenced Sep 15, 2026
Closed
Merged
This branch was successfully deployed
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
Fixes #1541.
Prevent the first prompt after a gateway-session restart from compacting history against the provisional 128k context-window fallback while live model discovery is still pending.
context_window_unavailable(HTTP 503 / gRPC Unavailable) when discovery fails or returns an empty inventory without establishing the selected window; a later prompt retry can refresh and recover.Regression evidence
The committed integration test runs under the existing
internal/appCI test suite; no live gateway/model credentials are required.It uses two real
app.Buildinstances, durable JSONL session recovery, offline TLS model discovery, and mock inference. Withstacklok-gateway/gpt-5.6-sol(1,050,000 tokens) and ~150k tokens of history:Additional tests cover atomic publication, caller cancellation, the operation-wide recovery deadline, known-window/override bypasses, effective plan-model identity, failed-step retry preservation, and awaiting approval preservation.
The integration test observes the real Build-wired admission callback and completes the same cold-admitted prompt after releasing metadata. A disposable Go-overlay mutation removing that callback makes the test fail.
Verification
Passed locally:
-race -count=3.internal/appandinternal/adapter/serverpackage tests (race runs also performed during development).task lint.task docs.task site:build.go run ./cmd/mecademo.git diff --check.Full
task testwas green earlier in implementation. Subsequent full runs encountered resource/time limits and intermittent failures in unchanged tests. The latest run hitTestHeadlessCredentialStorage_Scenario1_HelperFailuresFailClosed; its isolated rerun on this branch passed, and isolated baseline repetitions passed. Root cause of that full-suite-only failure remains unconfirmed.Final CI verification: head
de5fe7bf845abfc42f3adce85dc722072a32a6a8has 32 passing checks, 4 intentionally skipped, and no failures or pending checks. This includes all race partitions (the committedinternal/appregression runs here), build, analysis, docs/site, SDK checks, module/API compatibility, performance gate, and kind e2e. The branch incorporates current main through a merge commit and is mergeable.Review and workflow
Independent spec, standards, test-adequacy, architecture, security, reuse, and API/UX reviews were performed. Correctness blockers were repaired and re-reviewed. The existing generic TUI error presentation remains; the new server error and docs supply recovery instructions rather than adding a separate retry UI in this bug fix.
The directing user explicitly waived the acceptance-plan spine for #1541: “we should just do the fix and fix the docs instead.” This is the single test + fix + documentation PR. Human merge remains required.