-
Notifications
You must be signed in to change notification settings - Fork 52
fix LiteLLM model issue #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -460,9 +460,10 @@ export class ConfigurableAgentTool implements Tool<ConfigurableAgentArgs, Config | |
| const apiKey = callCtx.apiKey; | ||
| const provider = callCtx.provider; | ||
|
|
||
| // Check if this provider requires an API key | ||
| // BrowserOperator doesn't require an API key (endpoint is hardcoded) | ||
| const requiresApiKey = provider !== 'browseroperator'; | ||
| // Check if API key is required based on provider | ||
| // LiteLLM and BrowserOperator have optional API keys | ||
| // Other providers (OpenAI, Groq, OpenRouter) require API keys | ||
| const requiresApiKey = provider !== 'litellm' && provider !== 'browseroperator'; | ||
|
|
||
| if (requiresApiKey && !apiKey) { | ||
| const errorResult = this.createErrorResult(`API key not configured for ${this.name}`, [], 'error'); | ||
|
|
@@ -499,15 +500,17 @@ export class ConfigurableAgentTool implements Tool<ConfigurableAgentArgs, Config | |
| // Resolve model name from context or configuration | ||
| let modelName: string; | ||
| if (this.config.modelName === MODEL_SENTINELS.USE_MINI) { | ||
| if (!callCtx.miniModel) { | ||
| throw new Error(`Mini model not provided in context for agent '${this.name}'. Ensure context includes miniModel.`); | ||
| // Fall back to main model if mini model is not configured | ||
| modelName = callCtx.miniModel || callCtx.mainModel || callCtx.model || ''; | ||
| if (!modelName) { | ||
|
Comment on lines
501
to
+505
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new fallback for Useful? React with 👍 / 👎. |
||
| throw new Error(`Mini model not provided in context for agent '${this.name}'. Ensure context includes miniModel or mainModel.`); | ||
| } | ||
|
Comment on lines
+503
to
507
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include ‘model’ in USE_MINI failure message to match actual fallback chain Code falls back to callCtx.model, but the error mentions only miniModel/mainModel. Update message for accuracy. - throw new Error(`Mini model not provided in context for agent '${this.name}'. Ensure context includes miniModel or mainModel.`);
+ throw new Error(`Mini model not provided in context for agent '${this.name}'. Ensure context includes miniModel, mainModel, or model.`);🤖 Prompt for AI Agents |
||
| modelName = callCtx.miniModel; | ||
| } else if (this.config.modelName === MODEL_SENTINELS.USE_NANO) { | ||
| if (!callCtx.nanoModel) { | ||
| throw new Error(`Nano model not provided in context for agent '${this.name}'. Ensure context includes nanoModel.`); | ||
| // Fall back through nano -> mini -> main model chain | ||
| modelName = callCtx.nanoModel || callCtx.miniModel || callCtx.mainModel || callCtx.model || ''; | ||
| if (!modelName) { | ||
| throw new Error(`Nano model not provided in context for agent '${this.name}'. Ensure context includes nanoModel, miniModel, or mainModel.`); | ||
| } | ||
|
Comment on lines
+509
to
513
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include ‘model’ in USE_NANO failure message to match actual fallback chain The code falls back nano → mini → main → model; error omits model. - throw new Error(`Nano model not provided in context for agent '${this.name}'. Ensure context includes nanoModel, miniModel, or mainModel.`);
+ throw new Error(`Nano model not provided in context for agent '${this.name}'. Ensure context includes nanoModel, miniModel, mainModel, or model.`);🤖 Prompt for AI Agents |
||
| modelName = callCtx.nanoModel; | ||
| } else if (typeof this.config.modelName === 'function') { | ||
| modelName = this.config.modelName(); | ||
| } else if (this.config.modelName) { | ||
|
|
@@ -525,16 +528,25 @@ export class ConfigurableAgentTool implements Tool<ConfigurableAgentArgs, Config | |
| if (callCtx.model && !this.config.modelName) { | ||
| modelName = callCtx.model; | ||
| } | ||
|
|
||
|
|
||
| // Update context with resolved fallback models for tools to use | ||
| // This ensures tools that check ctx.miniModel or ctx.nanoModel get the fallback | ||
| if (this.config.modelName === MODEL_SENTINELS.USE_MINI && !callCtx.miniModel) { | ||
| callCtx.miniModel = modelName; // Use the resolved fallback | ||
| } | ||
| if (this.config.modelName === MODEL_SENTINELS.USE_NANO && !callCtx.nanoModel) { | ||
| callCtx.nanoModel = modelName; // Use the resolved fallback | ||
| } | ||
|
|
||
| // Validate required context | ||
| if (!callCtx.provider) { | ||
| throw new Error(`Provider not provided in context for agent '${this.name}'. Ensure context includes provider.`); | ||
| } | ||
|
|
||
| const temperature = this.config.temperature ?? 0; | ||
| const systemPrompt = this.config.systemPrompt; | ||
| const tools = this.getToolInstances(); | ||
|
|
||
| // Prepare initial messages | ||
| const internalMessages = this.prepareInitialMessages(args); | ||
| const runnerConfig: AgentRunnerConfig = { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2967,8 +2967,8 @@ Important guidelines: | |
| return { error: 'Missing LLM context (provider/model) for ObjectiveDrivenActionTool' }; | ||
| } | ||
|
|
||
| // BrowserOperator doesn't require API key | ||
| const requiresApiKey = providerForAction !== 'browseroperator'; | ||
| // LiteLLM and BrowserOperator have optional API keys | ||
| const requiresApiKey = providerForAction !== 'litellm' && providerForAction !== 'browseroperator'; | ||
|
|
||
| if (requiresApiKey && !apiKey) {return { error: 'API key not configured.' };} | ||
|
Comment on lines
+2970
to
2973
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normalize provider; also update 404 confirmation path to honor LiteLLM/BrowserOperator exemption First, normalize here: - // LiteLLM and BrowserOperator have optional API keys
- const requiresApiKey = providerForAction !== 'litellm' && providerForAction !== 'browseroperator';
+ // LiteLLM and BrowserOperator have optional API keys
+ const p = String(providerForAction || '').toLowerCase();
+ const requiresApiKey = p !== 'litellm' && p !== 'browseroperator';Additionally, confirmWith404LLM currently bails out if no API key even for litellm/browseroperator. Apply the same exemption there to enable 404 checks without a key: // Inside confirmWith404LLM(...)
const apiKey = agentService.getApiKey();
const p = String(ctx?.provider || '').toLowerCase();
const requiresApiKey = p !== 'litellm' && p !== 'browseroperator';
if (requiresApiKey && !apiKey) {
logger.warn('No API key available for 404 confirmation');
return false;
} |
||
| if (typeof objective !== 'string' || objective.trim() === '') { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reorder provider validation before API‑key gating to avoid misleading errors
If provider is undefined, the current order can return “API key not configured” instead of the clearer “Provider not provided…”. Validate provider first, then compute requiresApiKey.
Also applies to: 541-545
🤖 Prompt for AI Agents