Skip to content

Commit 63d7801

Browse files
rahulnakmolampagent
andcommitted
feat(opencode): add ui-balanced and ui-intelligence gateway modes
- Replace the ui agent with two OpenCode 2.0 agents (native agents key, system prompts): ui-balanced routes to private_gateway/gemini-4-argon at high reasoning effort, ui-intelligence to private_gateway/claude-fable-5-1 at medium effort. The #variant is sent to the gateway as reasoning_effort. - The gateway no longer serves the gemini-4-argon-high alias (upstream 404), so balanced mode selects gemini-4-argon with the high variant. - Launcher: OpenCode 2.0.30 ignores an agent's model for `run --agent NAME` (anomalyco/opencode#42561), so pass the agent's model from the global config unless -m/--model is given. - Policy validator: check models of native agents and assert both UI routes. Co-authored-by: Amp <[email protected]> Amp-Thread-ID: https://ampcode.com/threads/T-01a14955-cfea-74a8-88d8-e35b48bdeda5
1 parent b2d7128 commit 63d7801

4 files changed

Lines changed: 51 additions & 13 deletions

File tree

‎docs/modules/opencode.md‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,21 @@ run without the launcher has no usable provider. The launcher's generated config
4949
provider from the live gateway catalog and sets the default model chosen during setup. The
5050
built-in `opencode` (Zen) provider and any credentials in `opencode auth` are never enabled.
5151

52-
| Agent | Purpose |
53-
|-------|---------|
54-
| `quick` | Fast, concise answers |
55-
| `pro` | Complex architecture, debugging, deep analysis |
56-
| `ui` | Frontend/UI work |
52+
| Agent | Purpose | Model |
53+
|-------|---------|-------|
54+
| `quick` | Fast, concise answers | gateway default |
55+
| `pro` | Complex architecture, debugging, deep analysis | gateway default |
56+
| `ui-balanced` | Frontend/UI work, balanced mode | `private_gateway/gemini-4-argon#high` (Gemini 4 Argon, high reasoning effort) |
57+
| `ui-intelligence` | Frontend/UI work, intelligence mode | `private_gateway/claude-fable-5-1#medium` (Claude Fable 5.1, medium reasoning effort) |
5758

58-
Each agent has a custom system prompt tailored to its role and uses the gateway default model.
59+
Each agent has a custom system prompt tailored to its role. The `#variant` suffix is sent to the
60+
gateway as `reasoning_effort`; the gateway accepts `low`, `medium`, `high`, `xhigh` and `max`.
61+
62+
OpenCode 2.0.30 ignores an agent's model in `opencode run --agent NAME` (anomalyco/opencode#42561)
63+
and falls back to the default model. The launcher therefore adds `--model` from the agent's entry
64+
in the global config unless the command already passes `-m`/`--model`.
65+
66+
Use `opencode --agent ui-balanced` or `opencode run --agent ui-intelligence '...'` to pick a mode.
5967

6068
## TUI Settings
6169

‎opencode/.config/opencode/opencode.json‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,28 @@
44
"enabled_providers": [
55
"private_gateway"
66
],
7-
"agent": {
7+
"agents": {
88
"quick": {
99
"description": "Fast, concise answers through the private AI gateway",
1010
"mode": "primary",
11-
"prompt": "You are a fast, concise coding assistant. Keep responses short and actionable. Prioritize speed over exhaustive detail."
11+
"system": "You are a fast, concise coding assistant. Keep responses short and actionable. Prioritize speed over exhaustive detail."
1212
},
1313
"pro": {
1414
"description": "Expert coding agent for complex architecture, debugging, and deep code analysis",
1515
"mode": "primary",
16-
"prompt": "You are an expert software engineer. Think deeply before acting. Use extended reasoning for complex problems. Focus on correctness, edge cases, and production-quality code. When debugging, be methodical and trace through the full execution path."
16+
"system": "You are an expert software engineer. Think deeply before acting. Use extended reasoning for complex problems. Focus on correctness, edge cases, and production-quality code. When debugging, be methodical and trace through the full execution path."
1717
},
18-
"ui": {
19-
"description": "UI/UX focused agent for frontend, design systems, layout, and visual work",
18+
"ui-balanced": {
19+
"description": "UI/UX work, balanced mode: Gemini 4 Argon (high)",
2020
"mode": "primary",
21-
"prompt": "You are a frontend and UI/UX specialist. Focus on component architecture, responsive design, accessibility, and visual polish. Leverage your multimodal capabilities to understand design references, screenshots, and mockups. Prefer modern patterns: CSS Grid/Flexbox, design tokens, component composition."
21+
"model": "private_gateway/gemini-4-argon#high",
22+
"system": "You are a frontend and UI/UX specialist. Focus on component architecture, responsive design, accessibility, and visual polish. Leverage your multimodal capabilities to understand design references, screenshots, and mockups. Prefer modern patterns: CSS Grid/Flexbox, design tokens, component composition."
23+
},
24+
"ui-intelligence": {
25+
"description": "UI/UX work, intelligence mode: Claude Fable 5.1 at medium reasoning effort",
26+
"mode": "primary",
27+
"model": "private_gateway/claude-fable-5-1#medium",
28+
"system": "You are a frontend and UI/UX specialist. Focus on component architecture, responsive design, accessibility, and visual polish. Leverage your multimodal capabilities to understand design references, screenshots, and mockups. Prefer modern patterns: CSS Grid/Flexbox, design tokens, component composition."
2229
}
2330
},
2431
"permission": {

‎scripts/setup-private-ai-gateway.sh‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,24 @@ unset OPENCODE_CONFIG_DIR
329329
OPENCODE_CONFIG_CONTENT=\$(<$(printf '%q' "$OPENCODE_CONFIG"))
330330
# The gateway catalog is inline, so skip the models.dev/api.opencode.ai fetch.
331331
export OPENCODE_CONFIG_CONTENT OPENCODE_DISABLE_AUTOUPDATE=1 OPENCODE_DISABLE_MODELS_FETCH=1
332+
# OpenCode 2.0.30 ignores an agent's configured model for \`run --agent NAME\`
333+
# (anomalyco/opencode#42561) and uses the default model. Pass the agent's
334+
# model and variant explicitly unless the command already chooses one.
335+
if [[ \${1:-} == run ]]; then
336+
agent="" model_set=0 prev=""
337+
for arg in "\$@"; do
338+
[[ \$prev == --agent ]] && agent=\$arg
339+
case \$arg in
340+
-m|--model|--model=*|-m?*) model_set=1 ;;
341+
--agent=*) agent=\${arg#--agent=} ;;
342+
esac
343+
prev=\$arg
344+
done
345+
if [[ -n \$agent && \$model_set == 0 ]]; then
346+
agent_model=\$($(printf '%q' "$jq_bin") -r --arg a "\$agent" '.agents[\$a].model // empty' "\$global_config")
347+
[[ -n \$agent_model ]] && set -- run --model "\$agent_model" "\${@:2}"
348+
fi
349+
fi
332350
exec $(printf '%q' "$opencode_bin") "\$@"
333351
EOF
334352

‎scripts/validate-agent-policy.mjs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,12 @@ function checkGatewayOnly() {
251251
else fail("gateway", "opencode enabled_providers must be exactly [\"private_gateway\"]", enabled);
252252
if ("autoupdate" in oc) fail("gateway", "opencode uses the deprecated autoupdate key; OpenCode 2.0 uses update");
253253
else ok("gateway", "opencode has no deprecated autoupdate key");
254-
const ocModels = JSON.stringify([oc.model, oc.small_model, ...Object.values(oc.agent || {}).map((a) => a.model)]);
254+
const ocModels = JSON.stringify([oc.model, oc.small_model, ...Object.values({ ...(oc.agent || {}), ...(oc.agents || {}) }).map((a) => a.model)]);
255+
const ui = { "ui-balanced": "private_gateway/gemini-4-argon#high", "ui-intelligence": "private_gateway/claude-fable-5-1#medium" };
256+
for (const [name, model] of Object.entries(ui)) {
257+
if (oc.agents?.[name]?.model === model) ok("gateway", `opencode agent ${name} routes to ${model}`);
258+
else fail("gateway", `opencode agent ${name} must use ${model}`, oc.agents?.[name]?.model);
259+
}
255260
if (/"(?!private_gateway\/)[^"/]+\//.test(ocModels)) fail("gateway", "opencode references a non-gateway provider model", ocModels);
256261
else ok("gateway", "opencode references no non-gateway provider model");
257262

0 commit comments

Comments
 (0)