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. |
|
@phil65 Thank you for the feedback. Let me clarify the original motivation behind this PR. The primary goal was to provide a centralized place for custom model configuration that can be exposed to external applications like OpenCode, Zed, and other IDEs—allowing users to select models dynamically rather than being limited to a hardcoded list. Real-world use case:
Currently, AgentPool doesn't support model selection in TUI/GUI or WebUI interfaces—users are stuck with whatever is hardcoded or auto-discovered. This PR bridges that gap by:
I completely understand your concern about architectural complexity—having multiple overlapping concepts ( If you have a better proposal for unifying these concepts or a cleaner approach to achieve the same goal, I'm happy to close this PR and implement the alternative solution. Just let me know your preferred direction! |
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