Skip to content

fix(bin): pass the dispatch profile effort to OpenCode workers through their launch config - #5542

Closed
karotkriss wants to merge 4 commits into
kunchenguid:mainfrom
karotkriss:fm/fm-up-1373-opencode-effort
Closed

karotkriss wants to merge 4 commits into
kunchenguid:mainfrom
karotkriss:fm/fm-up-1373-opencode-effort

Conversation

@karotkriss

Copy link
Copy Markdown
Contributor

Intent

Fixes #1373

The dispatch profile's effort axis is recorded in task metadata but never reaches an OpenCode worker: the launch writes only a permission grant into the config it constructs, and no effort setting is passed.
Write the chosen effort into the OpenCode config the launch already constructs, using the config field OpenCode documents for per-model reasoning effort, so the worker runs at the profile's effort; when no effort is chosen the launch stays byte-identical.
This closes upstream issue #1373.

What Changed

  • effort_flag_for_harness now emits an agent.build entry (model + variant) into the OPENCODE_CONFIG_CONTENT JSON the OpenCode launch already writes, so the profile's effort reaches the worker via the config schema's per-model reasoning-effort field instead of being dropped; the entry is gated to providers/efforts known to expose a matching variant (anthropic/*: high, max; openai/*: low, medium, high, xhigh), and with no resolved model, another provider, or an out-of-family effort the launch stays byte-identical to the permission-only form.
  • Updated docs/configuration.md and the OpenCode harness-adapter reference to document how the effort rides the launch config and when the variant is omitted.
  • Reworked the OpenCode dispatch-profile tests: assert the variant is written for anthropic and openai family efforts, and assert the config is unchanged when effort is absent or outside the model family's list.

Risk Assessment

✅ Low: The fix-round change correctly implements the human-chosen provider-family gating with a preserved byte-identical no-effort launch, sound JSON escaping and substitution, and behavioral tests over the emitted launch command; it is well-bounded with no reachable defect found.

Testing

I derived scenarios from the intent and the round-1 provider-family gating decision, then drove each against the real fm-spawn.sh launch builder (which emits the literal command firstmate would run). anthropic/claude-sonnet-4-5 + high emits "agent":{"build":{"model":"anthropic/claude-sonnet-4-5","variant":"high"}}; openai/gpt-5.6-sol + xhigh emits the openai-family variant; no effort produces {"permission":{"*":"allow"}} which is byte-identical to the base commit's template; anthropic + medium (outside anthropic's high|max list) omits the variant and stays permission-only. The full dispatch-profile suite also passed (exit 0). The only aspect not drivable here is whether opencode 1.18.32 actually honors agent.build.variant at runtime and runs the worker at that effort - that needs a live opencode binary plus real model API credentials, so it is reported untested, not as a finding, since the change's own surface is fully validated.

  • Live validation: ✅ go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Anthropic model with a supported effort writes the variant into the launch config ✅ pass live Captured launch for --model anthropic/claude-sonnet-4-5 --effort high carries OPENCODE_CONFIG_CONTENT='{"permission":{"*":"allow"},"agent":{"build":{"model":"anthropic/claude-sonnet-4-5","variant":"hi…
No effort chosen keeps the OpenCode launch byte-identical to before the change ✅ pass live No-effort launch emits OPENCODE_CONFIG_CONTENT='{"permission":{"*":"allow"}}', exactly the base commit 977a81e template string
OpenAI model with a family-supported effort emits the variant ✅ pass live --model openai/gpt-5.6-sol --effort xhigh emits ..."agent":{"build":{"model":"openai/gpt-5.6-sol","variant":"xhigh"}}}
Effort outside the model family's list is omitted, launch stays permission-only ✅ pass live --model anthropic/claude-sonnet-4-5 --effort medium (medium not in anthropic high|max) emits permission-only config with no variant key
OpenCode 1.18.32 actually honors agent.build.variant and runs the worker at the profile effort ⏸️ untested no Requires a live opencode binary (1.18.32) plus real model-provider API credentials to launch a worker and observe the applied reasoning effort. Neither the opencode binary nor provider credentials are…
Evidence: Emitted opencode launch commands (four cases)

Source: Emitted opencode launch commands (four cases)

anthropic+high -> ...OPENCODE_CONFIG_CONTENT='{"permission":{"":"allow"},"agent":{"build":{"model":"anthropic/claude-sonnet-4-5","variant":"high"}}}' opencode --model 'anthropic/claude-sonnet-4-5' --prompt... anthropic+no-effort -> ...OPENCODE_CONFIG_CONTENT='{"permission":{"":"allow"}}' opencode --model 'anthropic/claude-sonnet-4-5'... openai+xhigh -> ..."variant":"xhigh"}}}... anthropic+medium -> ...OPENCODE_CONFIG_CONTENT='{"permission":{"*":"allow"}}'... (variant omitted)

ok - allowlist=absent preserves the operational floor and filters only when opted in
ok - allowlist=missing-config preserves the operational floor and filters only when opted in
ok - allowlist=enabled preserves the operational floor and filters only when opted in
ok - allowlist=empty preserves the operational floor and filters only when opted in
ok - invalid allowlist names refuse before launch or task publication
ok - inaccessible config with present allowlist refuses before launch or task publication
ok - inaccessible config with absent allowlist refuses before launch or task publication
ok - inaccessible ancestor with present allowlist refuses before launch or task publication
ok - inaccessible ancestor with absent allowlist refuses before launch or task publication
ok - secondmate launch inherits the allowlist for subsequent worker launches
ok - local inheritance preserves the allowlist on source errors and mirrors proven absence
ok - remote inheritance preserves the allowlist on source errors and mirrors proven absence
\### anthropic model + high effort (variant emitted)
meta: harness=opencode model=anthropic/claude-sonnet-4-5 effort=high 
launch: export COMPACT_ADVISER_DISABLE=1; env -u CURSOR_AGENT -u CURSOR_INVOKED_AS -u GEMINI_CLI OPENCODE_CONFIG_CONTENT='{"permission":{"*":"allow"},"agent":{"build":{"model":"anthropic/claude-sonnet-4-5","variant":"high"}}}' opencode --model 'anthropic/claude-sonnet-4-5' --prompt "$('~/.no-mistakes/worktrees/80aee654c94f/01M3A0S70SFKH6590J0E7GXGWT/bin/fm-operational-input.sh' encode launch-brief < '/tmp/fm-spawn-dispatch-profile.g2P0FJ/ev-anth-high/home/data/ev-ev-anth-high/launch-brief.md')"

\### anthropic model + no effort (byte-identical permission-only)
meta: harness=opencode model=anthropic/claude-sonnet-4-5 effort=default 
launch: export COMPACT_ADVISER_DISABLE=1; env -u CURSOR_AGENT -u CURSOR_INVOKED_AS -u GEMINI_CLI OPENCODE_CONFIG_CONTENT='{"permission":{"*":"allow"}}' opencode --model 'anthropic/claude-sonnet-4-5' --prompt "$('~/.no-mistakes/worktrees/80aee654c94f/01M3A0S70SFKH6590J0E7GXGWT/bin/fm-operational-input.sh' encode launch-brief < '/tmp/fm-spawn-dispatch-profile.g2P0FJ/ev-anth-none/home/data/ev-ev-anth-none/launch-brief.md')"

\### openai model + xhigh effort (variant emitted)
meta: harness=opencode model=openai/gpt-5.6-sol effort=xhigh 
launch: export COMPACT_ADVISER_DISABLE=1; env -u CURSOR_AGENT -u CURSOR_INVOKED_AS -u GEMINI_CLI OPENCODE_CONFIG_CONTENT='{"permission":{"*":"allow"},"agent":{"build":{"model":"openai/gpt-5.6-sol","variant":"xhigh"}}}' opencode --model 'openai/gpt-5.6-sol' --prompt "$('~/.no-mistakes/worktrees/80aee654c94f/01M3A0S70SFKH6590J0E7GXGWT/bin/fm-operational-input.sh' encode launch-brief < '/tmp/fm-spawn-dispatch-profile.g2P0FJ/ev-openai-xhigh/home/data/ev-ev-openai-xhigh/launch-brief.md')"

\### anthropic model + medium effort (outside family list, omitted)
meta: harness=opencode model=anthropic/claude-sonnet-4-5 effort=medium 
launch: export COMPACT_ADVISER_DISABLE=1; env -u CURSOR_AGENT -u CURSOR_INVOKED_AS -u GEMINI_CLI OPENCODE_CONFIG_CONTENT='{"permission":{"*":"allow"}}' opencode --model 'anthropic/claude-sonnet-4-5' --prompt "$('~/.no-mistakes/worktrees/80aee654c94f/01M3A0S70SFKH6590J0E7GXGWT/bin/fm-operational-input.sh' encode launch-brief < '/tmp/fm-spawn-dispatch-profile.g2P0FJ/ev-anth-med/home/data/ev-ev-anth-med/launch-brief.md')"

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • ⚠️ bin/fm-spawn.sh:2527 - effort_flag_for_harness opencode branch (bin/fm-spawn.sh:2526-2532) writes the requested effort as agent.build.variant for ANY of low|medium|high|xhigh|max, but the branch's own comment (2521) states each model exposes only a subset (Anthropic high|max, OpenAI low..xhigh). A dispatch profile pairing e.g. anthropic/claude-sonnet-4-5 with effort=medium (a plausible real config) writes variant="medium", which that model has no variant for. This diverges from the deliberate record-and-omit precedent in this same function: codex omits max unless model=gpt-5.6-luna (2472-2474) and grok omits xhigh/max (2483-2484) precisely to avoid passing known-bad values. If OpenCode rejects an unknown variant at config/model resolution, this regresses the previously always-valid permission-only launch for those combos; if it silently ignores it, the profile's effort just never applies. I cannot verify OpenCode's behavior from source. Because a durable fix requires per-model variant-list knowledge (a catalog/probe) that extends the change beyond writing the chosen effort, the remedy - not the defect - needs the author's decision; confirm whether an unsupported variant fails the launch or is ignored, and whether to gate emission by the model's variant list as codex/grok do.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Anthropic model with a supported effort writes the variant into the launch config ✅ pass live Captured launch for --model anthropic/claude-sonnet-4-5 --effort high carries OPENCODE_CONFIG_CONTENT='{"permission":{"*":"allow"},"agent":{"build":{"model":"anthropic/claude-sonnet-4-5","variant":"hi…
No effort chosen keeps the OpenCode launch byte-identical to before the change ✅ pass live No-effort launch emits OPENCODE_CONFIG_CONTENT='{"permission":{"*":"allow"}}', exactly the base commit 977a81e template string
OpenAI model with a family-supported effort emits the variant ✅ pass live --model openai/gpt-5.6-sol --effort xhigh emits ..."agent":{"build":{"model":"openai/gpt-5.6-sol","variant":"xhigh"}}}
Effort outside the model family's list is omitted, launch stays permission-only ✅ pass live --model anthropic/claude-sonnet-4-5 --effort medium (medium not in anthropic high|max) emits permission-only config with no variant key
OpenCode 1.18.32 actually honors agent.build.variant and runs the worker at the profile effort ⏸️ untested no Requires a live opencode binary (1.18.32) plus real model-provider API credentials to launch a worker and observe the applied reasoning effort. Neither the opencode binary nor provider credentials are…
  • bash tests/fm-spawn-dispatch-profile.test.sh (full suite, exit 0; the four opencode scenarios all reported ok)
  • Drove fm-spawn.sh directly for four opencode cases via run_ship_spawn and captured the literal tmux send-keys -l launch command for each (anthropic/high, anthropic/no-effort, openai/xhigh, anthropic/medium)
  • Compared the no-effort emitted config against the base commit's opencode template to confirm byte-identical output
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

karotkriss and others added 4 commits September 24, 2026 11:29
…aunch config

The dispatch profile's effort axis was recorded in task metadata but never
reached an OpenCode worker: the launch wrote only a permission grant into
the config it constructs.

OpenCode 1.18.32's config schema carries per-model reasoning effort as
agent.<name>.variant, so the chosen effort is now merged into the same
OPENCODE_CONFIG_CONTENT JSON as the default build agent's variant, keyed to
the resolved model. With no effort chosen the launch stays byte-identical.

Fixes kunchenguid#1373
Keep main's restructured crew-dispatch configuration docs and restore the
OpenCode agent.build.variant effort sentence under model/effort behavior.

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

First look vs main d1abcd6cc601e790c7d9bb24af64a5b2ce8d1f87. Tip was CONFLICTING; otherwise looked auto-merge-ready, so conflicts were resolved on the fork branch.

Closes #1373: yes — body Fixes #1373; tip writes profile effort into OpenCode OPENCODE_CONFIG_CONTENT as agent.build.variant (provider-family gated); main still permission-only + "no verified effort flag" comment.

contract-class: restore — dispatch profile effort axis already existed and was recorded in task meta; OpenCode launch dropped it. No new default effort; no-effort launch stays byte-identical permission-only.

VISION: One captain / interface — aligns (captain-chosen effort applies). Authority explicit — aligns (effort remains captain-owned; omit when unsupported). Scripts — aligns. Restart — n/a. Delegation/spine — aligns (worker contract matches profile). Vendor — aligns (config schema field, not UI scrape). Scope — aligns (launch wiring).

Conflicts: only docs/configuration.md — kept main's restructured crew-dispatch docs and restored the OpenCode agent.build.variant sentence under model/effort. New tip 57187e83983f6db3157916fdadcf7db2c3bc3d01. bin/fm-spawn.sh + tests auto-merged clean.

Attestation: MISMATCH (body 221ba97d7015bac67d036caf60e21aa226c0a6f1 ≠ tip). NM run 36147405701 FAILURE. Please re-run git push no-mistakes so the body attestation binds to the conflict-resolve tip.

Security: none. Firstmate flag: no. Waiting on: author (attestation / NM), not captain.

@karotkriss

Copy link
Copy Markdown
Contributor Author

Superseded by #5799, which carries the same change re-validated on a fresh branch.

@karotkriss karotkriss closed this Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(feature) Configure opencode.jsonc model including reasoningEffort during launch to address profile axes

2 participants