feat: implement Unified Model Selection Configuration#26
feat: implement Unified Model Selection Configuration#26Leoyzen wants to merge 1 commit intophil65:mainfrom
Conversation
Implement unified model selection across AgentPool protocol servers (ACP, OpenCode) to respect model_variants configuration from manifest.yml. Changes: - Add shared model utilities (src/agentpool_server/shared/model_utils.py) - _extract_provider(): Extract provider from AnyModelConfig - _build_providers_from_tokonomics(): Build providers from discovery - _apply_configured_variants(): Merge configured with discovered models - Update OpenCode server (config_routes.py) - Implement 4-tier fallback: config → tokonomics → agent modes → empty - Remove hardcoded _get_dummy_providers() - Add _get_configured_variants() and _build_providers_with_fallback() - Update ACP server (acp_agent.py) - get_session_model_state(): Include configured variants in session state - set_session_model(): Validate against both tokonomics and configured variants - Add comprehensive tests (test_model_utils.py, 29 tests) Configured variants take precedence over discovered models with the same ID. Backward compatible: existing configs work unchanged.
02de7e5 to
6eef318
Compare
|
Can you explain what the aim is? Right now we expose thinking modes as variants I think, and it is also already possible to define "custom" models. Does this offer anything new compared to that? |
|
@phil65 The core goal of this PR is to address model management challenges in multi-source and private deployment scenarios. Key Use Cases:
Distinction from existing features:
Why this is a practical need: |
|
Ok. Not really a fan of all these different concepts living next to each other, but I will think about it. |
Unified Model Selection Configuration
Summary
This PR implements unified model selection support across AgentPool's protocol servers. Users can now define custom model variants in their manifest configuration, which will be exposed through both OpenCode and ACP server endpoints.
What's New
Shared Model Utilities (
src/agentpool_server/shared/)extract_provider(): Extract provider names from any model configuration type (OpenAI, Anthropic, Gemini, etc.)build_providers_from_tokonomics(): Convert tokonomics discovery results into server-compatible provider objectsapply_configured_variants(): Merge user-defined model variants with auto-discovered modelsOpenCode Server Updates (
opencode_server/routes/config_routes.py)model_variantsfrom manifest (preferred)ACP Server Updates (
acp_server/acp_agent.py)get_session_model_state(): Now includes configured variants in session state responsesset_session_model(): Validates model IDs against both tokonomics discovery and configured variantsExample Configuration
Key Behaviors
Testing
Files Changed: 5
Additions: 788 lines
Deletions: 71 lines