Skip to content

Conversation

@arvindcr4
Copy link

Summary

When a token account is selected, the environment override for the token was being applied first, but then ProviderConfigEnvironment.applyAPIKeyOverride() was called afterward, which would overwrite the token account's value with the config's root apiKey.

This caused issues when:

  1. A user has both a root apiKey and token accounts configured
  2. The root apiKey is invalid or doesn't have a plan
  3. The token account's token is valid

The fix returns early after applying the token account override, preventing the config's apiKey from overwriting it.

Changes

  • ProviderRegistry.makeEnvironment (app): Return early after applying token account override
  • TokenAccountCLIContext.environment (CLI): Same fix

Test Plan

  • Tested with ZAI provider having both root apiKey (invalid) and token account (valid)
  • Before fix: Shows "Failed to parse z.ai response: Missing data"
  • After fix: Shows correct usage limits from token account

When a token account is selected, the environment override for the token
was being applied first, but then ProviderConfigEnvironment.applyAPIKeyOverride()
was called afterward, which would overwrite the token account's value
with the config's root apiKey.

This caused issues when:
1. A user has both a root apiKey and token accounts configured
2. The root apiKey is invalid or doesn't have a plan
3. The token account's token is valid

The fix returns early after applying the token account override,
preventing the config's apiKey from overwriting it.

Fixes both ProviderRegistry.makeEnvironment (app) and
TokenAccountCLIContext.environment (CLI).
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.

1 participant