Skip to content

Bug: Anthropic API key check runs regardless of selected LLM provider #115

Closed
@bhouston

Description

@bhouston

Bug: Anthropic API key check runs regardless of selected LLM provider

Description

Users are encountering an error about the Anthropic API key not being set, even when they've selected a different LLM provider (like OpenAI, Ollama, etc.). This happens because there's a hardcoded check for the Anthropic API key in the tool agent implementation that runs regardless of which provider is configured.

Current Behavior

  • Even when a non-Anthropic provider is selected, the CLI throws an error if the Anthropic API key is not set
  • The error occurs because of a hardcoded check in packages/agent/src/core/toolAgent/toolAgentCore.ts (lines 33-34):
    const apiKey = process.env.ANTHROPIC_API_KEY;
    if (!apiKey) throw new Error(getAnthropicApiKeyError());

Expected Behavior

  • The CLI should only check for the API key of the currently selected LLM provider
  • If the required API key is missing, it should display a helpful error message with a link to provider-specific documentation
  • For example: "OpenAI API key not found. Please see https://mycoder.ai/docs/getting-started/openai for setup instructions."

Proposed Solution

  1. Remove the hardcoded Anthropic API key check from toolAgentCore.ts
  2. Ensure API key checks are provider-specific and only run for the selected provider
  3. Improve error messages to include links to provider-specific documentation pages:
    • mycoder.ai/docs/getting-started/anthropic
    • mycoder.ai/docs/getting-started/openai
    • mycoder.ai/docs/getting-started/ollama
    • etc.

Additional Notes

  • The provider-specific documentation pages don't exist yet, but should be created as part of this fix
  • The CLI command handler in packages/cli/src/commands/$default.ts already has provider-specific API key checks, but the redundant check in the tool agent is causing this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions