Skip to content

fix: respect excludeProviders in API-level stream wrapper#4

Open
higorprado wants to merge 1 commit intoMasuRii:mainfrom
higorprado:main
Open

fix: respect excludeProviders in API-level stream wrapper#4
higorprado wants to merge 1 commit intoMasuRii:mainfrom
higorprado:main

Conversation

@higorprado
Copy link
Copy Markdown

excludeProviders was only preventing pi.registerProvider() for excluded providers, but not registerApiProvider() which registers a global stream handler per API.

When an excluded provider shares an API with a managed provider and lacks its own streamSimple, requests fall through to the global wrapper. The wrapper then tries to rotate credentials for the unmanaged provider and fails.

Fix: pass the excludeProviders set to createRotatingStreamWrapper. When a request originates from an excluded provider, delegate directly to the base API provider — bypassing credential rotation entirely.

Changes in src/provider.ts:

  • Added excludedProviders?: ReadonlySet<string> parameter
  • Added passthrough check: if provider is excluded, call base provider directly
  • Passed excludeSet from registerMultiAuthProviders to the wrapper

Typecheck, lint, and tests all pass (158/158).

Providers excluded via config were still intercepted at the API level
because registerApiProvider registered a global stream handler for each
API used by non-excluded providers. When an excluded provider (e.g.
zai-glm) shared an API (e.g. anthropic-messages) with a managed
provider but lacked its own streamSimple, requests fell through to the
global wrapper which tried to rotate credentials for the unmanaged
provider and failed.

Pass the excludeProviders set to createRotatingStreamWrapper and
delegate directly to the base API provider when the request originates
from an excluded provider, bypassing credential rotation entirely.
@MasuRii MasuRii self-assigned this May 8, 2026
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