Repository navigation
Description
Summary
The opencode adapter unconditionally strips the first /-segment of an explicit --model argument before invoking opencode. This breaks any user-defined custom provider in ~/.config/opencode/opencode.json (e.g. a local ohm proxy), because the resulting model string drops the provider that opencode actually needs to look up.
For us this manifested as every agentctl launch opencode --model "ohm/moonshotai/Kimi-K2.6" dying within 30s on 2026-05-04, with the wrapper log showing:
ProviderModelNotFoundError: ProviderModelNotFoundError
data: {
providerID: "moonshotai",
modelID: "Kimi-K2.6",
suggestions: [],
}
Error: Model not found: moonshotai/Kimi-K2.6.
agentctl had stripped ohm/ and then passed moonshotai/Kimi-K2.6 to opencode, which interpreted moonshotai as a (non-existent) provider.
Root cause
dist/adapters/opencode.js ~line 138 inside resolveOpenCodeModel:
if (opts.model) {
if (isModelCompatible(opts.model)) {
return opts.model;
}
validateApiKeyForModel(opts.model, env);
// 👇 strips first `/` segment unconditionally
return opts.model.split("/").slice(1).join("/");
}The strip assumes the prefix is one of the standard provider IDs (openai/, anthropic/, ...) that opencode auto-recognises and would reject. But opencode's provider map in opencode.json is user-extensible — ohm/..., togetherai/..., etc. are valid <provider>/<model> pairs that opencode resolves correctly when passed through verbatim.
When the workspace config supplies the model (no explicit --model), the adapter takes a different path (readWorkspaceModel) that does not strip, and everything works. So the inconsistency is: explicit --model ohm/... ❌, workspace-config ohm/... ✅.
Reproduction
- Configure
~/.config/opencode/opencode.jsonwith a custom provider, e.g. anohmblock pointing at a local OpenAI-compatible gateway withmodels: { "moonshotai/Kimi-K2.6": {...} }. agentctl launch opencode --model "ohm/moonshotai/Kimi-K2.6" --cwd /tmp -p "say hi"— dies fast.agentctl launch opencode --cwd /tmp -p "say hi"(no--model, workspace config value"ohm/moonshotai/Kimi-K2.6") — works.
Wrapper diff:
- Failing:
opencode 'run' '--model' 'moonshotai/Kimi-K2.6' '--' 'say hi'(prefix stripped) - Working:
opencode 'run' '--model' 'ohm/moonshotai/Kimi-K2.6' '--' 'say hi'(prefix preserved, sourced from workspace config)
Suggested fix
Don't strip when the prefix is a known opencode provider in the user's workspace opencode.json. Concretely:
- Parse the workspace
opencode.json(already read byreadWorkspaceModel) and extractObject.keys(cfg.provider || {})as a known-custom-provider set. - In the explicit-
opts.modelbranch, if the prefix is in that set, skip the strip and returnopts.modelverbatim. - Optionally: if the prefix matches a built-in opencode provider ID (
openai,anthropic,google, ...) keep current strip behaviour so the existing API-key validation path still applies.
A minimal alternative is to flip the default — pass --model through verbatim and only strip when explicitly opted in. The current behaviour silently breaks any custom provider workflow.
Side-by-side: codex adapter
For consistency, note that the codex adapter does the opposite — it passes --model through verbatim, with no stripping. So agentctl launch codex --model "openai/gpt-5.4" reaches OpenAI's API as model: "openai/gpt-5.4" and is rejected (The requested model 'openai/gpt-5.4' does not exist). Users have to know to pass the bare model name gpt-5.4. This is also footgun-y but at least surfaces a clean upstream error.
Workaround
Per our updated docs:
- opencode: omit
--model, let agentctl resolve from~/.config/opencode/config.json. - codex: pass bare model name (
gpt-5.4, notopenai/gpt-5.4).
Environment
- agentctl:
/Users/ms/personal/agentctl/dist/cli.js(build from~/personal/agentctl) - opencode: 1.2.11
- codex: 0.104.0
- macOS Darwin 25.4.0 arm64
Related memory
2026-04-30: daemon env validation bug —validateApiKeyForModel()only sees the daemon process env, not~/.zshenv. Workaround: start daemon from a login shell.2026-04-30: codex[agents]integer-fields rejection —max_threads/max_depth/job_max_runtime_secondsat top level under[agents]is rejected by Codex 0.104.0.2026-05-04: this issue (model-prefix strip).
Activity