[PR #779] feat: Improve fallback provider selection with API key validation #829

Open
opened 2026-02-16 08:15:54 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/open-swe/pull/779
Author: @open-swe[bot]
Created: 8/19/2025
Status: 🔄 Open

Base: mainHead: open-swe/7c26b94f-e0cd-4a20-ba06-eaada1d0dc87


📝 Commits (6)

📊 Changes

2 files changed (+88 additions, -3 deletions)

View changed files

📝 apps/open-swe/src/utils/llms/model-manager.ts (+51 -0)
📝 apps/open-swe/src/utils/runtime-fallback.ts (+37 -3)

📄 Description

Fixes #777

Owner: @bracesproul

Changes

This PR implements a robust mechanism to filter fallback providers based on API key availability:

  • Added hasApiKeyForProvider() method to ModelManager to safely check API key configuration
  • Modified getModelConfigs() to skip providers without valid API keys
  • Enhanced FallbackRunnable error handling to provide clear feedback when no fallback providers are available

Key Improvements

  • Prevent attempting to use providers without configured API keys
  • Add logging for skipped providers
  • Improve error messages when no valid fallback options exist
  • Maintain support for allowed users

Technical Details

  • Updated /src/utils/llms/model-manager.ts

    • New hasApiKeyForProvider() method
    • API key availability filtering in fallback provider selection
  • Updated /src/utils/runtime-fallback.ts

    • Improved error handling for fallback scenarios
    • Added checks for provider API key availability

Testing

  • Verified API key validation works correctly
  • Ensured allowed users can still use the system
  • Confirmed clear error messaging when no fallbacks are available

Resolves the issue of indiscriminate provider fallback when API keys are not configured.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/open-swe/pull/779 **Author:** [@open-swe[bot]](https://github.com/apps/open-swe) **Created:** 8/19/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `open-swe/7c26b94f-e0cd-4a20-ba06-eaada1d0dc87` --- ### 📝 Commits (6) - [`e1c870a`](https://github.com/langchain-ai/open-swe/commit/e1c870a6fb3d1b073569eaebdee28746260dc05d) Apply patch [skip ci] - [`f809ece`](https://github.com/langchain-ai/open-swe/commit/f809ece72241162f2b0edc0d14b69376853b467f) Apply patch [skip ci] - [`5bf522a`](https://github.com/langchain-ai/open-swe/commit/5bf522ad38fbd437f00285cf88818c7831f0a3f3) Apply patch [skip ci] - [`5246daf`](https://github.com/langchain-ai/open-swe/commit/5246daf7c5d67119ba23f4ed930fc09b96a70035) Apply patch [skip ci] - [`c9adc6c`](https://github.com/langchain-ai/open-swe/commit/c9adc6cec591e520e3f105ec3044dd740c158351) Apply patch [skip ci] - [`aaca2e6`](https://github.com/langchain-ai/open-swe/commit/aaca2e600cab3c1549fa09abf4193fcff51db8b9) Empty commit to trigger CI ### 📊 Changes **2 files changed** (+88 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `apps/open-swe/src/utils/llms/model-manager.ts` (+51 -0) 📝 `apps/open-swe/src/utils/runtime-fallback.ts` (+37 -3) </details> ### 📄 Description Fixes #777 Owner: @bracesproul ### Changes This PR implements a robust mechanism to filter fallback providers based on API key availability: - Added `hasApiKeyForProvider()` method to `ModelManager` to safely check API key configuration - Modified `getModelConfigs()` to skip providers without valid API keys - Enhanced `FallbackRunnable` error handling to provide clear feedback when no fallback providers are available ### Key Improvements - Prevent attempting to use providers without configured API keys - Add logging for skipped providers - Improve error messages when no valid fallback options exist - Maintain support for allowed users ### Technical Details - Updated `/src/utils/llms/model-manager.ts` - New `hasApiKeyForProvider()` method - API key availability filtering in fallback provider selection - Updated `/src/utils/runtime-fallback.ts` - Improved error handling for fallback scenarios - Added checks for provider API key availability ### Testing - Verified API key validation works correctly - Ensured allowed users can still use the system - Confirmed clear error messaging when no fallbacks are available Resolves the issue of indiscriminate provider fallback when API keys are not configured. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 08:15:54 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/open-swe#829