Skip to content

Conversation

@toadlyBroodle
Copy link
Contributor

Description

This PR adds support for using different LLM models for planning vs code implementation phases, along with environment variable support for API keys. It also refactors duplicated code into shared utility functions.

Related Issues

  • Addresses the need for flexible model configuration (use powerful models for planning, faster models for coding)
  • Improves security by supporting environment variables over hardcoded secrets

Changes Made

Features

  • Add separate planning_model and implementation_model config options for all providers (Google, Anthropic, OpenAI)
  • Support GOOGLE_API_KEY, ANTHROPIC_API_KEY, OPENAI_API_KEY environment variables
  • Environment variables take precedence over mcp_agent.secrets.yaml values
  • Add .env.example template for easy setup

Refactoring

  • Add shared get_api_keys() and load_api_config() functions in utils/llm_utils.py
  • DRY up duplicated config loading code across workflow files (~40 lines removed)
  • Use lazy imports for anthropic and openai packages to make them optional dependencies
  • Remove hardcoded brave search server references, use config-based search_server_names

Config Changes

  • Add planning_model and implementation_model options for google, anthropic, and openai sections
  • Add mcp_agent.secrets.yaml to .gitignore (users should use .env instead)

Checklist

  • Changes tested locally
  • Code reviewed
  • Documentation updated (if necessary)
  • Unit tests added (if applicable)

Additional Notes

Breaking Changes: None. All changes are backward compatible - existing configurations continue to work.

Migration: Users can optionally:

  1. Copy .env.example to .env and add their API keys there
  2. Add planning_model and implementation_model to their config if they want different models for each phase

Example config:
google:
default_model: "gemini-3-pro-preview"
planning_model: "gemini-3-pro-preview" # Used for analysis
implementation_model: "gemini-2.5-flash" # Used for code generation

Features:
- Add separate planning_model and implementation_model for all providers
- Support GOOGLE_API_KEY, ANTHROPIC_API_KEY, OPENAI_API_KEY env vars
- Environment variables take precedence over mcp_agent.secrets.yaml
- Add .env.example template for easy setup

Refactoring:
- Add shared get_api_keys() and load_api_config() in llm_utils.py
- DRY up duplicated config loading code in workflow files
- Use lazy imports for anthropic/openai to make them optional
- Remove hardcoded brave search server, use config-based search

Config changes:
- Add planning_model/implementation_model options for google, anthropic, openai
- Add mcp_agent.secrets.yaml to .gitignore (use .env instead)
- Ignore deepcode_lab/, and logs/
@Zongwei9888 Zongwei9888 merged commit 29672e3 into HKUDS:main Jan 7, 2026
1 check failed
@toadlyBroodle toadlyBroodle deleted the feature/multi-model-support branch January 11, 2026 00:49
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.

2 participants