Skip to content

Bug: Config file in ~/.config/mycoder not properly recognized for provider selection #398

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

Open
bhouston opened this issue May 4, 2025 · 0 comments

Comments

@bhouston
Copy link
Member

bhouston commented May 4, 2025

Description

There is an issue with how MyCoder loads configuration files, specifically when a user configures OpenAI as the provider in ~/.config/mycoder/config.js but the tool still attempts to use Anthropic API.

Investigation Findings

After examining the codebase, I have found the following:

  1. Configuration Loading Mechanism:

    • MyCoder uses the c12 library to load configuration from multiple locations
    • The configuration search order is defined in packages/cli/src/settings/config.ts
    • The default provider is set to "anthropic" in the default configuration
  2. API Key Handling:

    • API keys are loaded from environment variables based on the provider
    • The CLI checks for API keys in packages/cli/src/commands/$default.ts
    • Each provider has its own environment variable (ANTHROPIC_API_KEY, OPENAI_API_KEY)
  3. Potential Issue:

    • When loading config from ~/.config/mycoder/config.js, it may not be properly merged with CLI options
    • The provider selection might be overridden by the default value or CLI arguments

Steps to Reproduce

  1. Create a config file at ~/.config/mycoder/config.js with provider: "openai"
  2. Run MyCoder without specifying a provider in the command line
  3. Observe that it still tries to use Anthropic API

Possible Solutions

  1. Add more debug logging to show which configuration files are being loaded and the merged configuration
  2. Verify the priority order of configuration sources is being respected
  3. Check if there is an issue with the c12 library configuration loading
  4. Add a CLI flag to explicitly show the active configuration that is being used

Related Files

  • /packages/cli/src/settings/config.ts - Configuration loading
  • /packages/cli/src/commands/$default.ts - API key handling
  • /packages/agent/src/core/llm/provider.ts - Provider configuration
  • /packages/cli/src/index.ts - Main entry point with dotenv loading

Would appreciate help from anyone who can test this locally or has encountered similar issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant