Repository navigation
fix: preserve native gateway discovery during background refresh - #1798
Merged
Merged
Conversation
Do not publish a configured native-provider floor as freshly fetched data. A late background refresh could otherwise overwrite successful on-demand model discovery, erase context-window metadata and listing evidence, and reject the first prompt on a fresh startup. Add deterministic regressions for both publication orders, native-only startup, picker inventory, and admission without an extra discovery call. Co-Authored-By: mecatl <[email protected]>
This was referenced Sep 23, 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.
Summary
Fix a fresh-startup race that could reject the first prompt with
context window discovery unavailableeven after successful native-gateway discovery.The TUI's on-demand model listing can publish live native-provider metadata before an unrelated background refresh finishes. That background refresh skips authenticated native discovery, but previously included the configured native-model placeholder in its publication. Publishing it replaced the live inventory and cleared successful-listing evidence.
Development stage
Contract linkage
b0cf03a423df907e07269e085105fda2dc81ea47.Interface conformance
No API, configuration, authentication, retry/cooldown, or admission-policy changes. Native authenticated discovery remains on demand. Failed/empty discovery is not made admissible by this fix.
Issue relationship
Reported and reproduced during fresh-startup debugging; no linked GitHub issue.
Type of change
Test plan
-race -count=10.go run ./cmd/mecademo): passed, including tool execution, permission approval, and terminal result.git diff --check.task lint): local run exceeded its 600-second limit; CI required.task test GOPROXY=off): local run exceeded its 600-second limit; CI required.The operator explicitly requested submitting the PR and relying on CI rather than continuing heavyweight local gates. Local timeouts are not reported as passes. No tracked Markdown, generated contracts, or engine API changes; docs/site/API-update gates are not applicable to this internal repair.
User-facing change
A late unrelated background refresh no longer erases already-discovered native-gateway metadata and causes a spurious first-prompt context-window error.
Special notes for reviewers
The tests establish publication ordering with channels, not sleeps. They cover the real refresh/publication/admission functions; existing native-gateway Build tests cover the authenticated on-demand wiring. This fixes the reproduced metadata-loss race, not every possible discovery outage. Retry and cooldown behavior intentionally remain unchanged.