Skip to content

Conversation

@amitksingh1490
Copy link
Contributor

Changes

Use AgentProviderResolver for models fetching to ensure OAuth tokens are automatically refreshed before expiry, consistent with chat calls.

Details

  • Updated get_models() method to use AgentProviderResolver::get_provider(None)
  • This ensures OAuth tokens are checked and refreshed (with 5-minute buffer) before fetching models
  • Aligns models API behavior with chat API which already uses this mechanism

Fixes #2017

Co-Authored-By: ForgeCode noreply@forgecode.dev

Use AgentProviderResolver for models fetching to ensure OAuth tokens
are automatically refreshed before expiry, consistent with chat calls.

Fixes #2017

Co-Authored-By: ForgeCode <noreply@forgecode.dev>
@github-actions github-actions bot added the type: fix Iterations on existing features or infrastructure. label Nov 28, 2025
.await
.context("Failed to fetch models")?;

Ok(self.services.models(provider).await?)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The service should guarantee in this case, that creds will be refreshed. Caller should not be responsible.

)
.await?)
// Use AgentProviderResolver to ensure OAuth tokens are refreshed if needed
let agent_provider_resolver = AgentProviderResolver::new(self.services.clone());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove cred related code from ProviderResolver.

@tusharmath tusharmath enabled auto-merge (squash) November 29, 2025 07:14
@tusharmath tusharmath merged commit 4dc12f4 into main Nov 29, 2025
9 checks passed
@tusharmath tusharmath deleted the fix/oauth-token-refresh-models branch November 29, 2025 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OAuth token not auto-refreshed for models API calls

3 participants