Skip to content

Add provider field support for explicit provider selection#48

Merged
yinwm merged 1 commit intosipeed:mainfrom
victorhdchagas:fix/provider-field-support
Feb 12, 2026
Merged

Add provider field support for explicit provider selection#48
yinwm merged 1 commit intosipeed:mainfrom
victorhdchagas:fix/provider-field-support

Conversation

@victorhdchagas
Copy link
Contributor

This is an automated message generated during a code contribution process.

Issue/Demand

When using the provider field in the configuration file, the picoclaw agent was unable to use the configured API keys unless the model name included the provider prefix (e.g., groq/llama-3.1-8b-instant). This prevented users from using clean model names like llama-3.1-8b-instant even when explicitly setting the provider in the config.

Problem Summary

The agent.defaults.provider field existed in the JSON configuration schema but was not being used by the code. The provider was only detected from the model name string, which caused issues because the prefix was being sent to the API as part of the model name, resulting in errors like:

no API key configured for model: llama-3.1-8b-instant

Solution Implemented

  1. Added Provider field to AgentDefaults struct in pkg/config/config.go
  2. Modified CreateProvider() function in pkg/providers/http_provider.go to:
    • First: Check cfg.Agents.Defaults.Provider if explicitly set
    • Then: Fallback to existing model name detection logic (backward compatible)
    • Support aliases: openai/gpt, anthropic/claude, google/gemini, zhipu/glm

Files Changed

  • pkg/config/config.go: Added Provider field to struct and default config
  • pkg/providers/http_provider.go: Modified CreateProvider() to use explicit provider field

Testing

✅ Successfully reads API key from providers.groq.api_key when provider: "groq" is set
✅ Correct API base: https://api.groq.com/openai/v1
✅ Model name sent without prefix: llama-3.1-8b-instant
✅ Successfully makes API calls (only error was rate limit, not configuration)
✅ Existing tests continue to pass

Benefits

  • Users can now use the provider field from config as originally intended
  • No need to prefix model names with provider in the config file
  • Fully backward compatible with existing configurations
  • Supports all providers: groq, openai, anthropic, openrouter, zhipu, gemini, vllm

- Add Provider field to AgentDefaults struct
- Modify CreateProvider to use explicit provider field first, fallback to model name detection
- Allows using models without provider prefix (e.g., llama-3.1-8b-instant instead of groq/llama-3.1-8b-instant)
- Supports all providers: groq, openai, anthropic, openrouter, zhipu, gemini, vllm
- Backward compatible with existing configs

Fixes issue where models without provider prefix could not use configured API keys.
@lahcim
Copy link

lahcim commented Feb 12, 2026

Great change! Can we take this in?

@victorhdchagas
Copy link
Contributor Author

Great change! Can we take this in?

Yes! It's my first contribution... 🥉

@yinwm
Copy link
Collaborator

yinwm commented Feb 12, 2026

thanks for the pr

@yinwm yinwm merged commit 2fb2604 into sipeed:main Feb 12, 2026
@Zepan
Copy link
Contributor

Zepan commented Feb 13, 2026

Thanks for your contribution! We are forming the PicoClaw Dev Group to accelerate the evolution of the project. Any developer with more than one merged PR is invited to join.

Would you like to join the PicoClaw Dev Group? If so, please send an email to support@sipeed.com with the subject line: [Join PicoClaw Dev Group] + Your GitHub account. We will send the Discord invite link to your inbox.

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

Successfully merging this pull request may close these issues.

4 participants