Skip to content

Commit 69839dc

Browse files
committed
fix litellm model issue
1 parent 8b5e408 commit 69839dc

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

front_end/panels/ai_chat/agent_framework/ConfigurableAgentTool.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,10 @@ export class ConfigurableAgentTool implements Tool<ConfigurableAgentArgs, Config
460460
const apiKey = callCtx.apiKey;
461461
const provider = callCtx.provider;
462462

463-
// Check if this provider requires an API key
464-
// BrowserOperator doesn't require an API key (endpoint is hardcoded)
465-
const requiresApiKey = provider !== 'browseroperator';
463+
// Check if API key is required based on provider
464+
// LiteLLM and BrowserOperator has optional API keys
465+
// Other providers (OpenAI, Groq, OpenRouter) require API keys
466+
const requiresApiKey = provider !== 'litellm' && provider !== 'browseroperator';
466467

467468
if (requiresApiKey && !apiKey) {
468469
const errorResult = this.createErrorResult(`API key not configured for ${this.name}`, [], 'error');
@@ -499,15 +500,17 @@ export class ConfigurableAgentTool implements Tool<ConfigurableAgentArgs, Config
499500
// Resolve model name from context or configuration
500501
let modelName: string;
501502
if (this.config.modelName === MODEL_SENTINELS.USE_MINI) {
502-
if (!callCtx.miniModel) {
503-
throw new Error(`Mini model not provided in context for agent '${this.name}'. Ensure context includes miniModel.`);
503+
// Fall back to main model if mini model is not configured
504+
modelName = callCtx.miniModel || callCtx.mainModel || callCtx.model || '';
505+
if (!modelName) {
506+
throw new Error(`Mini model not provided in context for agent '${this.name}'. Ensure context includes miniModel or mainModel.`);
504507
}
505-
modelName = callCtx.miniModel;
506508
} else if (this.config.modelName === MODEL_SENTINELS.USE_NANO) {
507-
if (!callCtx.nanoModel) {
508-
throw new Error(`Nano model not provided in context for agent '${this.name}'. Ensure context includes nanoModel.`);
509+
// Fall back through nano -> mini -> main model chain
510+
modelName = callCtx.nanoModel || callCtx.miniModel || callCtx.mainModel || callCtx.model || '';
511+
if (!modelName) {
512+
throw new Error(`Nano model not provided in context for agent '${this.name}'. Ensure context includes nanoModel, miniModel, or mainModel.`);
509513
}
510-
modelName = callCtx.nanoModel;
511514
} else if (typeof this.config.modelName === 'function') {
512515
modelName = this.config.modelName();
513516
} else if (this.config.modelName) {

0 commit comments

Comments
 (0)