Skip to content

fix(engine): provider state rebuilds when stored credentials change on disk (#1848) - #1850

Merged
aarontrowbridge merged 1 commit into
mainfrom
fix/1848-provider-auth-refresh
Oct 23, 2026
Merged

aarontrowbridge merged 1 commit into
mainfrom
fix/1848-provider-auth-refresh

Conversation

@aarontrowbridge

Copy link
Copy Markdown
Member

Fixes #1848.

Problem

The fleet's engine shards (4094/4194/4294) share one auth.json, but each process caches its provider state per instance. Connecting Amazon Bedrock or OpenCode Go landed on one shard, which wrote the file and disposed only its own instance. The model picker then read /provider from whichever pool member the frontdoor picked, and the other shards were still serving their pre-connect provider lists. On the live hub: 4094 lists amazon-bedrock and opencode-go; 4194 and 4294 don't, and still list the removed openrouter.

Fix

Provider (overlay provider/provider.ts): the state records a fingerprint of the stored credentials it was built from. Every state read (list, getProvider, getModel, getLanguage, closest, getSmallModel, defaultModel) compares it with the on-disk fingerprint and invalidates and rebuilds only the provider state on drift. There's no instance dispose, so running sessions aren't cancelled. The provider state has no finalizers, so in-flight streams keep their existing SDK objects. If the auth file can't be read, nothing is rebuilt.

Tests

  • New: stored credentials written by another process reach a live instance. It builds the state, writes auth.json directly the way a sibling shard would, and asserts the provider shows up on connect and goes away on disconnect. Fails on base, passes with the fix.
  • test/provider/provider.test.ts: 101/0.
  • test/provider + test/server + session llm/prompt: 1391 pass. The 4 failures are the gate's known-environmental families (bounded fan-out, provider stream errors), plus a timing flake in sse-tick-telemetry that passed 4/4 on rerun with the fix.
  • Engine typecheck gate: clean (only the Base-pin drift: manifest upstream_base_sha stale vs absorbed overlay #1229 base-drift errors).

Deploy

Engine binary change, so it rides the staged engine rebuild (same swap window as the 03f8836f/ae93d3a3 provenance reconciliation). Once deployed, connects propagate to every shard on the next picker read without a restart.

Follow-up (not in this PR)

The app still calls instance.dispose() after auth.set (server-compat.ts, settings providers). In the fleet that lands on one pool member and cancels the running sessions in that shard's instance. With this fix the dispose is redundant against new engines, so it can go once no older engines remain.

…n disk — a connect on one shard reaches every shard (#1848)

The fleet engine shards share one auth.json, but each process caches its
provider state per instance. A connect (Amazon Bedrock, OpenCode Go) landed
on one shard, which wrote the file and disposed only its own instance, so the
picker kept getting pre-connect provider lists from the other shards (and the
removed openrouter stayed listed there).

Every provider state read now compares a fingerprint of the on-disk
credentials with the one the state was built from, and rebuilds that state
alone on drift. No instance dispose, so running sessions are untouched.
Regression test writes auth.json behind a live instance (connect and
disconnect); it fails on the base and passes with the fix.
@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ce768cf3-1bd3-48f0-8d2f-32ab85aa2535
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

bug(fleet): connecting a provider (Amazon Bedrock, OpenCode Go) succeeds but it never appears in the model picker — only one engine shard refreshes

1 participant