oliver-zehentleitner / maity

runner: opencode placements exit at once: the new opencode TUI refuses --model ('Unrecognized flag: --model in command opencode')

Sign in to report

tsk-daa6e0gfncg0 Done An agent

2026-11-19 23:28Z, after the CLI 0.1.0a16 upgrade: both xAI reviewer placements (maity-review-xai-001 plc-nyqv2a9vk6rg on oliver-pc01-l, maity-review-xai-002 on home-laptop; opencode, interactive) exit right after the start and loop. maity runner logs plc-nyqv2a9vk6rg shows opencode's help and:

ERROR Unrecognized flag: --model in command opencode

The installed opencode's root command now only takes --standalone, --server, --auto, --continue/-c, --session/-s, --prompt (plus a directory), and lists subcommands (run, serve, mini, models, …). cli/src/maity/runner/adapters.py _opencode builds the interactive launch as [binary, clone, "--model", model, "--prompt", prompt] (around line 770-773), so every interactive opencode placement fails on this opencode version. The supervised form (opencode run --dir … --model …) may or may not still accept --model; check.

Done when: the runner sets the model in a way this opencode accepts for both modes (the runner already writes the placement's own opencode.json via OPENCODE_CONFIG: put "model" there, keeping the fail-closed check from #1969 so a missing or unknown model still refuses the start), maity runner check probes the installed opencode for the flags the adapter uses and reports a mismatch before a start, tests for both launch forms, and docs (runner docs, cli/context/runner.md opencode entry) updated in the same PR. Then a CLI release. Workaround until then: an opencode version that still accepts --model on the root command.

Ops confirmed on the host (note nte-22jpstv7c7x5 on tsk-kf2kp09d6qew): OpenCode v2.3.0. The regression comes from #1969: in a15 an interactive placement without a model got no --model and started (on opencode's own default, the bug #1969 fixed); a16 always passes --model. OpenCode 2.3's TUI (no subcommand) has no --model; opencode run and opencode mini accept --model/-m, so supervised placements are unaffected. Fix options: model in the generated opencode.json for interactive, or start the TUI as opencode mini … --model. Workaround until the fix: run opencode placements supervised.

Notes

  1. Mr. Robot · Nov 20, 2026, 19:25 UTC

    Live check on oliver-pc01-l with OpenCode 2.3.0, 2026-11-20 ~19:25Z. Done in a throwaway directory with its own tmux; no prompt sent, the TUI was stopped after reading its screen.

    1. Does the interactive TUI take the model from a top-level `"model"` in the file named by `OPENCODE_CONFIG`, without `--model`? Only with `--standalone`.

    • OPENCODE_DISABLE_PROJECT_CONFIG=1 OPENCODE_CONFIG=<file with "model":"xai/grok-4.6"> opencode <dir> shows "Build · Tidepool Alpha Free OpenCode", i.e. opencode's own hosted model. The config's model is ignored.
    • The same with opencode --standalone <dir> shows "Build · Grok 4.6 xAI", so the config's model is used.
    • Why: without --standalone, 2.3's TUI connects to the shared background service (opencode serve --service, one per user, here running since 2026-11-18). That service has its own configuration, so the session's OPENCODE_CONFIG and OPENCODE_DISABLE_PROJECT_CONFIG don't reach it. This matters beyond the model: every opencode placement of that user would share one service, and the runner's per-placement config and the project-config switch would not apply. The runner should start the TUI with `--standalone`, or check that 2.3 honours its env otherwise.

    2. Does `opencode run` accept `--dir` and `--continue`? --continue (-c) yes. --dir no: opencode run --dir . gives ERROR Unrecognized flag: --dir in command opencode run. 2.3's run has no directory flag (usage: opencode run [flags] [<message...>]). The runner's supervised launch [opencode, "run", "--dir", <clone>, …] (adapters.py _opencode) therefore fails on 2.3 too; start it with the clone as working directory instead. run also has --model/-m and --session.

    So on 2.3 both modes need a change: interactive needs --standalone plus the model in the config (2.3's TUI has no --model), and supervised needs no --dir.

  2. Mr. Robot · Nov 20, 2026, 20:37 UTC

    Live check of #2048 (head ed56c7c1) on oliver-pc01-l, OpenCode 2.3.0, 2026-11-20 ~20:40Z. Run in a throwaway clone (a shallow clone of keep-the-why in ~/ops-workspace/tmp/oc2048) with the same arguments and env the PR's _opencode builds: OPENCODE_DISABLE_PROJECT_CONFIG=1, and OPENCODE_CONFIG pointing at a file with a top-level "model": "xai/grok-4.6". No prod involved.

    (1) Interactive opencode --standalone <clone>, with no --model: ✓. The TUI shows "Build · Grok 4.6 xAI", so the configured model is used, not the hosted one. Its status line shows the clone's path and branch (~/ops-workspace/tmp/oc2048/clone:main), so it runs in the clone. I left out --prompt so as not to start an agent run in the throwaway, which means the prompt path itself was not exercised.

    (2) Supervised, with the clone as working directory and no --dir: ✓. opencode run --model xai/grok-4.6 "<prompt>" exited 0 with the header > build · grok-4.6 and the expected answer. Then opencode run --model xai/grok-4.6 --continue "<what did you answer last time?>" exited 0 and answered with the first run's word, so --continue picked up that directory's last session.

    So both launch shapes of #2048 work on 2.3.0 as built. Two small prompts went to xAI for (2).

  3. Mr. Robot · Nov 21, 2026, 13:28 UTC

    ops 3yc2, the interactive --prompt path of #2048 at head ed56c7c1 (lotse go seq 188388), oliver-pc01-l, OpenCode 2.3.0, 2026-11-21 ~13:30Z. It supplements nte-e6v9en0xk539.

    Rig: the PR's own adapters.launch() built the interactive launch for a TEST placement (mode interactive, model xai/grok-4.6, in models and default_model) on a throwaway clone. That gave opencode --standalone <clone> --prompt <prompt>, with OPENCODE_DISABLE_PROJECT_CONFIG=1 and OPENCODE_CONFIG = the placement's opencode.json with top-level "model": "xai/grok-4.6". The runner's start prompt was swapped for a harmless one ("reply with exactly the word PONG … do not run any tools"). It ran with a clean env in a tmux server of its own (own socket), with no hub and no join.

    Result: passes.

    • The TUI started, took the prompt as its first message and answered `PONG` (Build · Grok 4.6 · 2.8s). The footer reads "Build · Grok 4.6 xAI", so it used the config's model, not the hosted default.
    • The status line shows the throwaway clone's path and branch, so it ran in the clone.
    • It stayed up: still running at 10 s, 25 s and 45 s, with no exit or loop as in the a16 bug.
    • No tools ran. The session's title became "Harmless PONG test".

    So both of #2048's launch shapes, interactive including the first prompt and supervised, work on OpenCode 2.3.0 as built.

    Cleanup: the tmux server was stopped and the throwaway clone, agent dir and socket removed. Cost: one small prompt to xAI. OpenCode keeps its own session history in its data dir, as for any session; I didn't touch that.

  4. Maity Test Team · Nov 21, 2026, 15:07 UTC

    Tester note (maity-test-team), #2048 at main af07490c: PASS (the probe and unit level; ops already covered the live launch in nte-mmnz3mk1247c).

    I probed capabilities.opencode_missing_flags against fake opencode binaries, Python 3.13:

    • 2.3-like help (-m, --model string, --prompt=TEXT, …) → {'interactive': (), 'supervised': ()}.
    • Look-alikes only (--standalone-mode, --prompts, --model-name, --continue-x) → every flag reported missing. The word-boundary regex holds.
    • Help printed only on stderr → found (stdout and stderr are both read).
    • Exit 1 with the flags in the output, or exit 0 with no output → None (a warning, not ok).
    • Missing binary → None. A hanging binary → None after 10.0 s (VERSION_TIMEOUT); no hang.
    • An unknown mode is skipped ({}).
    • pytest tests/test_runner.py tests/test_ssh.py -k opencode: 14 passed. test_adapters: 178 passed (in the #2050 run, same main).

    Observation, not a bug: the probe counts a flag that appears anywhere in the help text, e.g. in another flag's description. That is acceptable for a diagnostic.