Skip to content

fix(core): reuse models across credential switches - #49109

Closed
opencode-agent[bot] wants to merge 1 commit into
v2from
connect-perf
Closed

opencode-agent[bot] wants to merge 1 commit into
v2from
connect-perf

Conversation

@opencode-agent

Copy link
Copy Markdown
Contributor

What changed

Provider snapshots now retain their identity when only the active credential changes and the available provider definitions remain identical. This prevents every retained Location from rebuilding and freezing its full active model catalog during /connect account changes.

Real provider availability changes and account-bound inventory changes still produce a new snapshot and rebuild models.

Performance

A focused 6,000-model credential-switch repro dropped from roughly 84 ms to 2.5 ms per Location.

Verification

  • bun test test/catalog.test.ts test/model-plugins.test.ts (27 passed)
  • bun typecheck in packages/core
  • bun run lint -- packages/core/src/provider.ts packages/core/test/catalog.test.ts

Requested by: @thdxr (dax via Slack)

Credential changes altered the provider snapshot even when the available provider definitions stayed identical. That forced every retained Location to rematerialize its full active model catalog. Reuse the snapshot when availability is unchanged, while preserving rebuilds for real provider and account-bound inventory changes.
@thdxr

thdxr commented Sep 16, 2026

Copy link
Copy Markdown
Member

Superseded by #49255, which landed the same availability-keyed snapshot cache plus copy-on-write model materialization so a genuinely new provider is also cheap. Closing.

from OpenCode

@thdxr thdxr closed this Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant