Repository navigation
fix: support OpenCode v2 model selection - #7327
amanmishra2 wants to merge 9 commits into
Conversation
… dead launch
fm-spawn composed `opencode --model <m> --prompt <brief>` for every OpenCode
launch, but OpenCode 2.x removed `--model` from the interactive TUI: the
launched TUI exits 1 with "Unrecognized flag: --model in command opencode"
(verified on 2.0.28), and the spawn still reported success, leaving the task
with no worker at all (2026-10-13).
Compose `--model` only on a proven 1.x surface. A new bounded help probe
(opencode_supports_model_flag, the pi_supports_tui_mode shape with
fm-cursor-lib.sh's timeout discipline) keeps the flag on 1.18.32, which
advertises it, and omits it when the probe is inconclusive or the installed TUI
is 2.x. The model is never lost with the flag: it rides the launch's
OPENCODE_CONFIG_CONTENT build-agent model, the same JSON the effort variant
already used, verified through `opencode debug config` on both 2.0.28
(agents.build.model {providerID, model, variant}) and 1.18.32
(agent.build.model). The effort mapping, the model/effort axes recorded in task
meta, and every other harness launch are unchanged.
Add the missing launch-readiness gate for the canonical OpenCode launch. It
reads the backend's own agent-state classifier and refuses only on a positive
verdict: a sustained dead pane that never read alive, or a dead reading again
after the first alive (the rejected-flag shape, whose process lives just long
enough to be seen once). Inconclusive readings step aside, so backends without
a classifier and panes the classifier cannot attribute keep the behavior they
had; raw launch commands are exempt because they may legitimately be headless
one-shots. Measured live: tmux reads alive within one poll and reads dead
within 0.31s of a rejected-flag exit; Herdr 0.9.3 needs ~3.8s to register a
healthy launch (no-agent -> unknown -> live) and stays no-agent for a rejected
one, which is why the confirm window spans 12 consecutive dead reads.
Tests: the dispatch-profile suite's OpenCode cases now pin each generation, a
model that cannot be pinned, an inconclusive probe, a dead launch, a launch
that dies after starting, and the two shapes that must not be refused. The
spawn tmux fixture gains the window-inventory and pane-command knobs those
cases need, defaulting to today's behavior.
…d the gate's coverage boundary Review-gate follow-up from the failed fix round of run 01M4XZDMKEGFG4G44Q567VJTVR (agent wall-clock limit), applied by hand on the recovered branch. SPAWN-004: an OpenCode model selection that can ride neither channel - no proven --model support on the installed TUI and not a provider/model pair for OPENCODE_CONFIG_CONTENT - now refuses the spawn before any worktree, endpoint, or record exists, instead of launching with OpenCode's own default model while the task record claims a different one. The old notice-and-continue behavior was a silent model substitution. A raw launch command stays exempt, exactly as it is for the readiness gate. The fragment builder keeps a bare id out of the config as an invariant only; the preflight owns the message and the refusal. SPAWN-003: the readiness gate's coverage boundary is now documented in the gate comment and the touched docs (harness-adapters OpenCode reference, configuration model/effort bullet, verification record) with no contract change: on a backend whose runtime exposes no recovery-grade agent-state classifier (zellij, orca, cmux today), and for readings the classifier cannot attribute, the gate has no verdict and steps aside, so the spawn keeps its pre-gate behavior. Extending verified liveness to those backends, or refusing OpenCode launches on them, would change the supported runtime contract and stays out of scope. Tests: the unpinnable-model case now expects the refusal, asserting the actionable error, no published task record, and no delivered launch command.
b3f63f7 to
c6df660
Compare
|
Speaking as Kun's firstmate: thank you @amanmishra2 — I read tip Contract-class: restore. Composing VISION.md: aligns (fleet outlives vendor versions; contracts bind to what the vendor exposes; scripts own the probe/readiness mechanics). This pass: attestation MATCHES; no security tip. Fork CI approved and queued so checks can run. Live validation is marked inconclusive — 3 of 4 scenarios driven, but the dead-launch readiness refusal (including zero/overflow poll settings) was not established live against a real OpenCode TUI that exits immediately. Could you live-test that missing row when you have a moment, post the evidence on the PR (or re-raise through no-mistakes with the live table filled in)? No rush, and please don't feel any pressure — whenever it's convenient. Once that live evidence is on the tip (and CI is green), this can take the restore auto-merge path. We won't run a lab test from here. Status: waiting-author on live evidence for the dead-launch readiness scenario. |
|
CI workflows for the latest push are held in GitHub's "awaiting approval" state, which fork pull requests need a maintainer to approve. Could a maintainer approve the workflow runs for this PR when convenient? Context: the earlier run's one red shard (Behavior portable serial 9) is addressed in this push. The OpenCode config serializer declared a local without initializing it, and newer Bash rejects that expansion under the script's nounset mode, so one 1.x-shaped launch exited before starting; the local is now initialized, lint is clean, and the targeted spawn suite is green (91 tests). |
|
Speaking as Kun's firstmate: thanks @amanmishra2 — I approved the CI and no-mistakes runs for Two small things are still open before this can take the restore auto-merge path, whenever you have a moment:
No rush at all, and thank you for sticking with this one. |
…contains the `variant=''` initialization; the spawn dispatch suite, lint, and `git diff --check` pass. Serial 2 was canceled without a test verdict
a443de9 to
b27c396
Compare
|
Speaking as Kun's firstmate: thanks @amanmishra2 for re-raising through no-mistakes. The attestation now binds head Where it stands now: the head no longer merges into main Contract-class: restore (my own read, unchanged). What's needed from you (waiting on you):
Once CI is green and it's mergeable, it can take the restore path. FYI, no action needed: #7336 also rewrites |
Intent
Fix the OpenCode v2 spawn path in this repo: fm-spawn emitted
opencode --model <m> --prompt <brief>; opencode 2.0.28 answers "Unrecognized flag: --model in command opencode" and exits, yet the spawn still reported success (2026-10-13).Evidence:
model_flag_for_harness(bin/fm-spawn.sh ~line 2716) emits--modelfor every harness including opencode, but the v2 TUI accepts no--model(the model rides global config / OPENCODE_CONFIG_CONTENT;--modelremains valid onopencode run). Production workarounds used: launching without--model, andfm-control relaunch --model default. The launch readiness check did not detect the immediately-dead TUI.What Changed
--model; when the flag is unsupported or the probe is inconclusive, pass provider/model selections throughOPENCODE_CONFIG_CONTENTand include a supported effort variant. Refuse selections the config cannot pin before provisioning.Risk Assessment
✅ Low: The changes are bounded to OpenCode model delivery and startup readiness; I found no source-backed defect, and the accepted backend limitation is documented.
Testing
The Test agent exceeded its invocation budget before live validation completed; no evidence was gathered for this head.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed (4) ✅
bin/fm-spawn.sh:4767- The busy contract is armed asbusy/source=fm-spawnbefore launch (bin/fm-spawn.sh:5052). If OpenCode exits before its plugin posts an idle event, this handler recordsfailedbut leaves that busy record in place. The busy classifier trusts the seed for OpenCode (bin/fm-busy-lib.sh:1055-1066), so the watcher can still classify a workerless task as busy. This affects both new failure paths: sustained dead (bin/fm-spawn.sh:4737) and alive-then-dead (bin/fm-spawn.sh:4758), which reach the handler atbin/fm-spawn.sh:6195. Clear the armed generation tounknownor retire it in this shared failure handler.🔧 Fix applied.
2 warnings still open:
bin/fm-spawn.sh:4767- The busy contract is armed asbusy/source=fm-spawnbefore launch (bin/fm-spawn.sh:5052). If OpenCode exits before its plugin posts an idle event, this handler recordsfailedbut leaves that busy record in place. The busy classifier trusts the seed for OpenCode (bin/fm-busy-lib.sh:1055-1066), so the watcher can still classify a workerless task as busy. This affects both new failure paths: sustained dead (bin/fm-spawn.sh:4737) and alive-then-dead (bin/fm-spawn.sh:4758), which reach the handler atbin/fm-spawn.sh:6195. Clear the armed generation tounknownor retire it in this shared failure handler.bin/fm-spawn.sh:2173- The new timing overrides are not validated.FM_OPENCODE_READY_POLLS=0atbin/fm-spawn.sh:4723skips every state check and returns success, so a dead launch can again be reported as spawned. The other unchecked inputs areFM_OPENCODE_POLL_INTERVAL(bin/fm-spawn.sh:4724),FM_OPENCODE_READY_DEAD_CONFIRM(bin/fm-spawn.sh:4725), andFM_OPENCODE_SETTLE_POLLS(bin/fm-spawn.sh:4726); invalid values can collapse or skip their checks.FM_OPENCODE_PROBE_TIMEOUT(bin/fm-spawn.sh:2173) is also unchecked: zero disables GNUtimeout's bound. Validate or fall back to safe values so these settings cannot bypass readiness or leave a hung help probe unbounded.🔧 Fix applied.
3 warnings still open:
bin/fm-spawn.sh:4767- The busy contract is armed asbusy/source=fm-spawnbefore launch (bin/fm-spawn.sh:5052). If OpenCode exits before its plugin posts an idle event, this handler recordsfailedbut leaves that busy record in place. The busy classifier trusts the seed for OpenCode (bin/fm-busy-lib.sh:1055-1066), so the watcher can still classify a workerless task as busy. This affects both new failure paths: sustained dead (bin/fm-spawn.sh:4737) and alive-then-dead (bin/fm-spawn.sh:4758), which reach the handler atbin/fm-spawn.sh:6195. Clear the armed generation tounknownor retire it in this shared failure handler.bin/fm-spawn.sh:2173- The new timing overrides are not validated.FM_OPENCODE_READY_POLLS=0atbin/fm-spawn.sh:4723skips every state check and returns success, so a dead launch can again be reported as spawned. The other unchecked inputs areFM_OPENCODE_POLL_INTERVAL(bin/fm-spawn.sh:4724),FM_OPENCODE_READY_DEAD_CONFIRM(bin/fm-spawn.sh:4725), andFM_OPENCODE_SETTLE_POLLS(bin/fm-spawn.sh:4726); invalid values can collapse or skip their checks.FM_OPENCODE_PROBE_TIMEOUT(bin/fm-spawn.sh:2173) is also unchecked: zero disables GNUtimeout's bound. Validate or fall back to safe values so these settings cannot bypass readiness or leave a hung help probe unbounded.bin/fm-spawn.sh:2172- The 3ce4a90 timing-validation round introduced a range gap: the helper accepts positive decimal strings outside Bash’s integer range. For example,FM_OPENCODE_READY_POLLS=9223372036854775808can make the loop comparison fail, then reach the success return without checking pane state. The same gap affectsFM_OPENCODE_READY_DEAD_CONFIRMat bin/fm-spawn.sh:4748,4763 andFM_OPENCODE_SETTLE_POLLSat bin/fm-spawn.sh:4749,4781. Default values outside the shell’s representable integer range before these comparisons.🔧 Fix applied.
4 warnings still open:
bin/fm-spawn.sh:4767- The busy contract is armed asbusy/source=fm-spawnbefore launch (bin/fm-spawn.sh:5052). If OpenCode exits before its plugin posts an idle event, this handler recordsfailedbut leaves that busy record in place. The busy classifier trusts the seed for OpenCode (bin/fm-busy-lib.sh:1055-1066), so the watcher can still classify a workerless task as busy. This affects both new failure paths: sustained dead (bin/fm-spawn.sh:4737) and alive-then-dead (bin/fm-spawn.sh:4758), which reach the handler atbin/fm-spawn.sh:6195. Clear the armed generation tounknownor retire it in this shared failure handler.bin/fm-spawn.sh:2173- The new timing overrides are not validated.FM_OPENCODE_READY_POLLS=0atbin/fm-spawn.sh:4723skips every state check and returns success, so a dead launch can again be reported as spawned. The other unchecked inputs areFM_OPENCODE_POLL_INTERVAL(bin/fm-spawn.sh:4724),FM_OPENCODE_READY_DEAD_CONFIRM(bin/fm-spawn.sh:4725), andFM_OPENCODE_SETTLE_POLLS(bin/fm-spawn.sh:4726); invalid values can collapse or skip their checks.FM_OPENCODE_PROBE_TIMEOUT(bin/fm-spawn.sh:2173) is also unchecked: zero disables GNUtimeout's bound. Validate or fall back to safe values so these settings cannot bypass readiness or leave a hung help probe unbounded.bin/fm-spawn.sh:2172- The 3ce4a90 timing-validation round introduced a range gap: the helper accepts positive decimal strings outside Bash’s integer range. For example,FM_OPENCODE_READY_POLLS=9223372036854775808can make the loop comparison fail, then reach the success return without checking pane state. The same gap affectsFM_OPENCODE_READY_DEAD_CONFIRMat bin/fm-spawn.sh:4748,4763 andFM_OPENCODE_SETTLE_POLLSat bin/fm-spawn.sh:4749,4781. Default values outside the shell’s representable integer range before these comparisons.bin/fm-spawn.sh:2743- The accepted criterion says, “an unpinnable model selection must refuse the spawn with a clear error instead of launching with OpenCodes default model.” On the no-flag path, the*/ *-style check atbin/fm-spawn.sh:2743accepts--model /(and values such asanthropic/or/sonnet) as a provider/model ID. The serializer repeats that check at line 3001 and emits the value intoagent.build.modelat line 3013 instead of refusing. Require nonempty provider and model components before treating the config channel as able to pin the selection.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ No issues found.
opencode service set portandopencode service stopwith disposable HOME/XDG settings; a later CLI run still resolved the host's occupied default managed-service port, so I cannot confirm those service commands were confined to the lab. The lab TUI, mock provider, private tmux server, and lab home were stopped or removed. Please check the operator OpenCode service state. A safe live rerun needs a separate OpenCode runtime whose service port and model are demonstrably isolated.--modelflag; it rejects the flag with exit code 1.--modeldirectly and drove a canonical fm-spawn launch that stayed alive. I also tried disposable HOME/XDG settings and a loopback model provider, but the inter…bash tests/fm-spawn-dispatch-profile.test.shopencode --versionandopencode --helpopencode --model anthropic/claude-sonnet-4-5 --prompt live-checkunder disposable environment settingsopencode debug configwithOPENCODE_CONFIG_CONTENTmodel and variant valuesbin/fm-spawn.sh opencode-live-z9a <lab-project> --scout --harness opencode --model local-fixture/echothrough the private lab sessionbin/fm-spawn.sh opencode-refuse-z9c <lab-project> --scout --harness opencode --model sonnettmux -L fm-lab list-panes -aandcapture-panefor the live spawnbin/fm-lab-home.sh teardown <lab-home>and privatetmux -L fm-lab kill-server/bin/zsh -lc 'LAB=\\\"$PWD/fm-opencode-live.1Fs6RY\\\"; [ -d \\\"$LAB\\\" ] && rm -rf -- \\\"$LAB\\\"; [ ! -e \\\"$LAB\\\" ] && echo removed || echo still-present; git status --short --branch'rejected: rm -f style commands are not permitt.... This is a budget or provider-slowness cut, not a code failure. Re-running the same request costs another full budget, so no further attempt is made automatically. If this repository's targeted tests or evidence gathering routinely approach the default 30m0s, raise test_agent_timeout in global config. Respond with fix to spend another budget: a repair turn runs only for selected findings other than this budget cut, then validation re-runs. Or abort and retry after raising the budget.✅ **Document** - passed
✅ No issues found.
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
✅ No issues found.