Skip to content

opencode: --model in agentArgsOverride fails (not passed via HTTP API) #83

@pythoninthegrass

Description

@pythoninthegrass

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:

  1. 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.

  2. 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

  1. Configure ~/.gnhf/config.yml:
    agent: opencode
    agentArgsOverride:
      opencode:
        - --model
        - fireworks-ai/accounts/fireworks/models/qwen3p6-plus
  2. Run gnhf "any prompt" in a git repo
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions