fix(compaction): dispatch summarization through the model runtime - #544
Open
eddieparc wants to merge 2 commits into
Open
fix(compaction): dispatch summarization through the model runtime#544eddieparc wants to merge 2 commits into
eddieparc wants to merge 2 commits into
Conversation
Compaction failed for every model served by a provider registered through pi.registerProvider() — the builtin claude-agent-sdk provider and extension providers such as senpi-accounts' Kiro: compaction generator failed: No API provider registered for api: kiro-codewhisperer speculative.ts dispatched the summarization request with compat's stream(), and compat's api-registry only knows the 10 builtin api ids; runtime-registered providers live solely in ModelRuntime / provider-composer. Normal agent turns worked because they dispatch through agent.streamFunction = modelRuntime.streamSimple, so a session on such a provider ran fine until it needed to compact and then had no way out of the context window. Route the summarization stream through context.modelRegistry.modelRuntime.stream() when a registry is present, and keep the compat fallback for contexts constructed without one. Same fix shape as code-yeongyu#488 for /btw (ff48536); SpeculativeCompactionContext already carried modelRegistry for auth resolution. TDD: test/suite/regressions/543-compaction-runtime-provider.test.ts captured RED with the exact rejection message before the fix, GREEN after. Fixes code-yeongyu#543
Two more holes in the same class as the runtime-dispatch fix, both of
which left a provider that senpi considers fully usable for normal turns
unable to compact:
- runExtensionCompaction required a resolved apiKey, so a provider
authenticated only by a credential request header (models.json
`headers`, extension `headers` — a first-class, documented auth mode)
resolved {ok: true, apiKey: undefined} and compaction died with
"summarization credentials unavailable: no API key resolved". Accept a
credential header as resolved auth; a genuinely unconfigured provider
still raises the same typed auth error.
- openai-remote.ts defaulted both stream runners to compat streamSimple,
so an extension `openai-responses` proxy that owns its transport and
opts into compat.supportsRemoteCompactionV2 (a documented public
opt-in) had that transport bypassed on the native remote route. Route
through the model runtime, keeping the injected test runner first and
compat last.
TDD: both regressions captured RED before the change — the header-auth
case as a compaction rejection, the remote case as a never-invoked
runtime transport — GREEN after.
Refs code-yeongyu#543
Contributor
Author
|
Pushed
New coverage: the header-auth case in |
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.
Fixes #543
Problem
Compaction failed for every model served by a provider registered through
pi.registerProvider()— the builtinclaude-agent-sdkprovider and extension providers such assenpi-accounts' Kiro:compaction/speculative.tsdispatched the summarization request with compat'sstream(), and compat's api-registry only knows the 10 builtin api ids (packages/ai/src/compat.tsBUILTIN_APIS); runtime-registered providers live solely inModelRuntime/provider-composer. Normal agent turns worked because they dispatch throughagent.streamFunction=modelRuntime.streamSimple, so a session on such a provider ran fine until it needed to compact — then it had no way out of the context window.Change
Route the summarization stream through
context.modelRegistry.modelRuntime.stream()when a registry is present, keeping the compat fallback forSpeculativeCompactionContextvalues constructed without one.SpeculativeCompactionContextalready carriedmodelRegistry(it resolves summarization auth with it), so nothing new is threaded through. Same fix shape as #488 for/btw(ff48536).Tested
test/suite/regressions/543-compaction-runtime-provider.test.ts— new regression registering a provider whose api id exists only inModelRuntime, then compacting. Captured RED before the fix withcompaction generator failed: No API provider registered for api: runtime-only-compaction-api, GREEN after.npx vitest --run test/compaction test/suite/regressions— 604 passed. 4 pre-existing failures (0000-multi-session-theme-init,2791-fswatch-error-crash,codemode-builtin-dedupex2) reproduce identically on an unmodifiedorigin/maincheckout of the same worktree; unrelated to this change.npx tsgo --noEmitclean,biome check --error-on-warningsclean on the changed files, rootnpm run buildexit 0./compactapplies a summary instead of rejecting.Summary by cubic
Fixes compaction for runtime-registered providers by routing summarization through the model runtime, with compat as fallback. Adds support for header-auth providers and routes native remote compaction via the runtime. Fixes #543.
context.modelRegistry.modelRuntimewhen available; fallback to compat. Injected runners still win inopenai-remote.ts.apiKeyno longer required if headers are provided.test/suite/regressions/543-compaction-runtime-provider.test.ts,test/suite/regressions/543-remote-compaction-runtime-provider.test.ts.Written for commit 17b4eba. Summary will update on new commits.