feat(external-llm): add external LLM integration (fc-004)
Implements external LLM routing via opencode CLI for: - GitHub Copilot (gpt-5.2, claude-sonnet-4.5, claude-haiku-4.5, o3, gemini-3-pro) - Z.AI (glm-4.7 for code generation) - OpenCode native (big-pickle) Components: - mcp/llm-router/invoke.py: Main router with task-based model selection - mcp/llm-router/delegate.py: Agent delegation helper (respects external mode) - mcp/llm-router/toggle.py: Enable/disable external-only mode - mcp/llm-router/providers/: CLI wrappers for opencode and gemini Features: - Persistent toggle via state/external-mode.json - Task routing: reasoning -> gpt-5.2, code-gen -> glm-4.7, long-context -> gemini - Claude tier mapping: opus -> gpt-5.2, sonnet -> claude-sonnet-4.5, haiku -> claude-haiku-4.5 - Session-start hook announces when external mode is active - Natural language toggle support via component registry Plan: gleaming-routing-mercury Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -143,6 +143,23 @@
|
||||
"block dangerous",
|
||||
"protect"
|
||||
]
|
||||
},
|
||||
"external-mode": {
|
||||
"description": "Toggle between Claude and external LLMs (Copilot, Z.AI, Gemini)",
|
||||
"script": "~/.claude/mcp/llm-router/toggle.py",
|
||||
"triggers": [
|
||||
"external",
|
||||
"use external",
|
||||
"switch to external",
|
||||
"external models",
|
||||
"external only",
|
||||
"use copilot",
|
||||
"use opencode",
|
||||
"back to claude",
|
||||
"use claude again",
|
||||
"disable external",
|
||||
"external mode"
|
||||
]
|
||||
}
|
||||
},
|
||||
"commands": {
|
||||
|
||||
5
state/external-mode.json
Normal file
5
state/external-mode.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"enabled": false,
|
||||
"activated_at": null,
|
||||
"reason": null
|
||||
}
|
||||
@@ -37,10 +37,11 @@
|
||||
"category": "integration",
|
||||
"title": "External LLM integration",
|
||||
"description": "Support for non-Claude models in the agent system",
|
||||
"priority": "low",
|
||||
"status": "deferred",
|
||||
"priority": "medium",
|
||||
"status": "planned",
|
||||
"created": "2024-12-28",
|
||||
"notes": "For specialized tasks or cost optimization"
|
||||
"plan": "gleaming-routing-mercury",
|
||||
"notes": "Cloud APIs via subscription (Copilot, Z.AI, Gemini). Uses opencode/gemini CLIs. Session toggle for external-only mode."
|
||||
},
|
||||
{
|
||||
"id": "fc-005",
|
||||
|
||||
@@ -113,5 +113,60 @@
|
||||
"default": "haiku",
|
||||
"escalate_on": ["insufficient_context", "reasoning_required", "user_dissatisfied"]
|
||||
}
|
||||
},
|
||||
"external_models": {
|
||||
"github-copilot/gpt-5.2": {
|
||||
"cli": "opencode",
|
||||
"cli_args": ["-m", "github-copilot/gpt-5.2"],
|
||||
"use_cases": ["reasoning", "fallback"],
|
||||
"tier": "opus-equivalent"
|
||||
},
|
||||
"github-copilot/claude-sonnet-4.5": {
|
||||
"cli": "opencode",
|
||||
"cli_args": ["-m", "github-copilot/claude-sonnet-4.5"],
|
||||
"use_cases": ["general", "fallback"],
|
||||
"tier": "sonnet-equivalent"
|
||||
},
|
||||
"github-copilot/claude-haiku-4.5": {
|
||||
"cli": "opencode",
|
||||
"cli_args": ["-m", "github-copilot/claude-haiku-4.5"],
|
||||
"use_cases": ["simple"],
|
||||
"tier": "haiku-equivalent"
|
||||
},
|
||||
"zai-coding-plan/glm-4.7": {
|
||||
"cli": "opencode",
|
||||
"cli_args": ["-m", "zai-coding-plan/glm-4.7"],
|
||||
"use_cases": ["code-generation"],
|
||||
"tier": "sonnet-equivalent"
|
||||
},
|
||||
"github-copilot/gemini-3-pro-preview": {
|
||||
"cli": "opencode",
|
||||
"cli_args": ["-m", "github-copilot/gemini-3-pro-preview"],
|
||||
"use_cases": ["long-context"],
|
||||
"tier": "opus-equivalent"
|
||||
},
|
||||
"github-copilot/o3": {
|
||||
"cli": "opencode",
|
||||
"cli_args": ["-m", "github-copilot/o3"],
|
||||
"use_cases": ["complex-reasoning"],
|
||||
"tier": "opus-equivalent"
|
||||
},
|
||||
"opencode/big-pickle": {
|
||||
"cli": "opencode",
|
||||
"cli_args": ["-m", "opencode/big-pickle"],
|
||||
"use_cases": ["general"],
|
||||
"tier": "sonnet-equivalent"
|
||||
}
|
||||
},
|
||||
"claude_to_external_map": {
|
||||
"opus": "github-copilot/gpt-5.2",
|
||||
"sonnet": "github-copilot/claude-sonnet-4.5",
|
||||
"haiku": "github-copilot/claude-haiku-4.5"
|
||||
},
|
||||
"task_routing": {
|
||||
"reasoning": "github-copilot/gpt-5.2",
|
||||
"code-generation": "zai-coding-plan/glm-4.7",
|
||||
"long-context": "github-copilot/gemini-3-pro-preview",
|
||||
"default": "github-copilot/claude-sonnet-4.5"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user