Skip to content
This repository was archived by the owner on Jul 29, 2025. It is now read-only.

fix: tweak the logic to fix config merging #115

Merged
merged 1 commit into from
May 1, 2025

Conversation

rekram1-node
Copy link
Contributor

Should fix: #71

This fixes issues with merging configurations. Previously, If I didn't set an environment variable for say anthropic, but I had in my configuration file the following:

{
  "providers": {
      "anthropic": {
        "apiKey": "***",
        "disabled": false
      }
  }
}

The I would get "Error: model not supported"

These changes ensure that we read in the file configuration before setting defaults so a user won't have to explicitly configure every agent in their configuration file.

Also, setProviderDefaults will NOT override settings already configured because viper will check if the values have been set or not.

// Anthropic configuration
if apiKey := os.Getenv("ANTHROPIC_API_KEY"); apiKey != "" {
if viper.Get("providers.anthropic.apiKey") != "" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We set these values right at the beginning of setProviderDefaults

@kujtimiihoxha
Copy link
Collaborator

@rekram1-node I just merged another provider maybe we can update this to include all providers correctly now ?

@rekram1-node
Copy link
Contributor Author

@kujtimiihoxha added openrouter

@kujtimiihoxha
Copy link
Collaborator

@rekram1-node thanks

@kujtimiihoxha kujtimiihoxha merged commit e14de7a into opencode-ai:main May 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

won't launch with default configs
2 participants