Bug: --model in agentArgsOverride for opencode does not work
Problem
When using agentArgsOverride to pass --model to the opencode agent, gnhf fails immediately on every iteration with a 400 error from the opencode serve API. The TUI shows "waiting (backoff)..." with 0 in / 0 out tokens.
There are two separate issues:
-
opencode serve does not accept --model — gnhf passes all extraArgs directly to opencode serve, but --model / -m is only a valid flag on the main opencode command (TUI/run modes), not on serve. Depending on the opencode version, this either causes the server to print help and exit, or silently ignores the flag.
-
The opencode HTTP API expects model as an object, not a string — The POST /session/:id/prompt_async endpoint expects the model field as { "providerID": "...", "modelID": "..." }, not a bare string like "fireworks-ai/accounts/fireworks/models/qwen3p6-plus". Passing a string returns HTTP 400 with: "Invalid input: expected object, received string".
Steps to reproduce
- Configure
~/.gnhf/config.yml:
agent: opencode
agentArgsOverride:
opencode:
- --model
- fireworks-ai/accounts/fireworks/models/qwen3p6-plus
- Run
gnhf "any prompt" in a git repo
- Observe "waiting (backoff)..." with 0 tokens processed
Expected behavior
gnhf should extract --model from the extra args, parse the provider/model string into { providerID, modelID }, and pass it in the prompt_async request body rather than on the opencode serve CLI.
Proposed fix
In OpenCodeAgent:
- Extract
--model/-m from extraArgs before spawning the server
- Split the
provider/model string on the first / into { providerID, modelID }
- Pass the model object in the
prompt_async request body (which the opencode API supports)
- Continue passing all other extra args to
opencode serve as before
I've got this working locally with the fix applied — gnhf successfully runs opencode with a fireworks-ai model, and all existing tests pass.
Environment
- gnhf: 0.1.24
- opencode: 1.14.21
- macOS: 15.7.1 (24G231)
- Node.js: v24.12.0
Bug:
--modelinagentArgsOverridefor opencode does not workProblem
When using
agentArgsOverrideto pass--modelto the opencode agent, gnhf fails immediately on every iteration with a 400 error from the opencode serve API. The TUI shows "waiting (backoff)..." with 0 in / 0 out tokens.There are two separate issues:
opencode servedoes not accept--model— gnhf passes allextraArgsdirectly toopencode serve, but--model/-mis only a valid flag on the mainopencodecommand (TUI/run modes), not onserve. Depending on the opencode version, this either causes the server to print help and exit, or silently ignores the flag.The opencode HTTP API expects
modelas an object, not a string — ThePOST /session/:id/prompt_asyncendpoint expects themodelfield as{ "providerID": "...", "modelID": "..." }, not a bare string like"fireworks-ai/accounts/fireworks/models/qwen3p6-plus". Passing a string returns HTTP 400 with:"Invalid input: expected object, received string".Steps to reproduce
~/.gnhf/config.yml:gnhf "any prompt"in a git repoExpected behavior
gnhf should extract
--modelfrom the extra args, parse theprovider/modelstring into{ providerID, modelID }, and pass it in theprompt_asyncrequest body rather than on theopencode serveCLI.Proposed fix
In
OpenCodeAgent:--model/-mfromextraArgsbefore spawning the serverprovider/modelstring on the first/into{ providerID, modelID }prompt_asyncrequest body (which the opencode API supports)opencode serveas beforeI've got this working locally with the fix applied — gnhf successfully runs opencode with a fireworks-ai model, and all existing tests pass.
Environment