Skip to content

fix(cli): invalidate provider state after auth changes#8898

Merged
marius-kilocode merged 3 commits intomainfrom
fix/invalidate-provider-state-on-auth-change
Apr 14, 2026
Merged

fix(cli): invalidate provider state after auth changes#8898
marius-kilocode merged 3 commits intomainfrom
fix/invalidate-provider-state-on-auth-change

Conversation

@marius-kilocode
Copy link
Copy Markdown
Collaborator

Summary

  • Invalidate InstanceState (provider cache) after auth changes so the hasKey check re-evaluates with updated credentials
  • After the Effect migration in OpenCode v1.3.14 #8870, the provider hasKey decision was cached via ScopedCache and never refreshed — causing authenticated users to be stuck on the free model when auth state changed after provider init

Relates to #8870

After the Effect migration in #8870, provider state is cached via
InstanceState/ScopedCache. The hasKey check that determines which
models are available ran once at init and was never re-evaluated.
When auth changed (login, logout, org switch), only ModelCache was
cleared but the provider state retained the stale hasKey decision,
causing authenticated users to be stuck on the free model.
Instance: {
readonly directory: string
readonly project: { readonly id: string }
disposeAll(): Promise<void>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: This widens the exported route dependency contract

createKiloRoutes() is part of @kilocode/kilo-gateway's public API, and its deps shape inherits this ImportDeps.Instance type. Making disposeAll() required will break existing TypeScript callers that pass the previous Instance object shape even though importSessionToDb() still only uses directory and project.id. Consider keeping this requirement in the route-layer deps instead of the shared import deps so this fix doesn't introduce an undocumented source-breaking change.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Apr 14, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • .changeset/fix-provider-auth-invalidation.md
  • packages/kilo-gateway/src/server/routes.ts
  • packages/opencode/src/kilocode/server/server.ts
  • packages/opencode/src/provider/auth.ts
  • packages/opencode/src/server/server.ts

Reviewed by gpt-5.4-20260305 · 444,393 tokens

@marius-kilocode marius-kilocode enabled auto-merge (squash) April 14, 2026 10:48
@marius-kilocode marius-kilocode merged commit 4a69a3e into main Apr 14, 2026
16 checks passed
@marius-kilocode marius-kilocode deleted the fix/invalidate-provider-state-on-auth-change branch April 14, 2026 10:57
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.

2 participants