Skip to content

fix(compaction): dispatch summarization through the model runtime - #544

Open
eddieparc wants to merge 2 commits into
code-yeongyu:mainfrom
eddieparc:fix/compaction-runtime-provider-dispatch
Open

fix(compaction): dispatch summarization through the model runtime#544
eddieparc wants to merge 2 commits into
code-yeongyu:mainfrom
eddieparc:fix/compaction-runtime-provider-dispatch

Conversation

@eddieparc

@eddieparc eddieparc commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #543

Problem

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 rejected: compaction generator failed: No API provider registered for api: kiro-codewhisperer

compaction/speculative.ts dispatched the summarization request with compat's stream(), and compat's api-registry only knows the 10 builtin api ids (packages/ai/src/compat.ts BUILTIN_APIS); 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 — 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 for SpeculativeCompactionContext values constructed without one. SpeculativeCompactionContext already carried modelRegistry (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 in ModelRuntime, then compacting. Captured RED before the fix with compaction 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-dedupe x2) reproduce identically on an unmodified origin/main checkout of the same worktree; unrelated to this change.
  • npx tsgo --noEmit clean, biome check --error-on-warnings clean on the changed files, root npm run build exit 0.
  • Real surface: local senpi built from this branch, running on the Kiro provider with a Claude model, /compact applies 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.

  • Bug Fixes
    • Route summarization and remote-compaction streams via context.modelRegistry.modelRuntime when available; fallback to compat. Injected runners still win in openai-remote.ts.
    • Accept credential request headers as valid auth for summarization; apiKey no longer required if headers are provided.
    • Added regression tests: 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.

Review in cubic

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
@eddieparc

Copy link
Copy Markdown
Contributor Author

Pushed 17b4eba16: two more holes in the same class, so the fix is actually generic rather than kiro-shaped.

  • Summarization no longer requires a resolved apiKey — a credential request header counts as resolved auth, so headers-authenticated providers (models.json headers, extension headers) can compact. The typed auth error for an unconfigured provider is unchanged.
  • openai-remote.ts resolves its stream runner through the model runtime (resolveRemoteStreamRunner), so an extension openai-responses proxy that opts into compat.supportsRemoteCompactionV2 keeps its own transport on the native remote route. Injected dependencies.streamRunner still wins; compat is last.

New coverage: the header-auth case in 543-compaction-runtime-provider.test.ts and 543-remote-compaction-runtime-provider.test.ts, both captured RED before their fix. test/compaction + test/suite/regressions: 129 files / 610 tests passing. tsgo --noEmit, biome, and root npm run build clean. Detail in #543 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compaction fails for runtime-registered providers: No API provider registered for api: <api> (claude-agent-sdk, kiro)

1 participant