Skip to content

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

Open
@bhouston

Description

@bhouston

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions