Open
Description
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:
-
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
- MyCoder uses the
-
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)
-
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
- When loading config from
Steps to Reproduce
- Create a config file at
~/.config/mycoder/config.js
withprovider: "openai"
- Run MyCoder without specifying a provider in the command line
- Observe that it still tries to use Anthropic API
Possible Solutions
- Add more debug logging to show which configuration files are being loaded and the merged configuration
- Verify the priority order of configuration sources is being respected
- Check if there is an issue with the
c12
library configuration loading - 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
Labels
No labels