Skip to content

fix(workflow): pass the agent model and effort to opencode run (#1193) - #1200

Closed
kittimzhe wants to merge 1 commit into
Tencent:mainfrom
kittimzhe:fix/opencode-agent-model-1193
Closed

kittimzhe wants to merge 1 commit into
Tencent:mainfrom
kittimzhe:fix/opencode-agent-model-1193

Conversation

@kittimzhe

Copy link
Copy Markdown
Contributor

What

A workflow step with agent: on OpenCode launched opencode run --format json <prompt> --agent <name> and nothing else, while pull deploys every OpenCode agent as mode: subagent. The report's request-body forensics (#1193) show:

  • OpenCode 1 rejects a subagent from run --agent — ! agent "reviewer" is a subagent, not a primary agent. Falling back to default agent — so the definition's prompt and model never run.
  • OpenCode 2 applies the definition's prompt but ignores the file's model: and variant:, running on the configured default.

Change (the model half)

  • The driver passes the step agent's mapped --model explicitly — the codex family in the same invocation already did. Per the report's table, both majors honor an explicit --model even in fallback.
  • The mapped effort rides with it: --variant on OpenCode 1, inside the model id (prov#effort) on OpenCode 2, where run has no separate variant flag. The major is probed once per executable (--version) and cached; a failed probe reads as 1, the pinned devDependency's major.
  • local-driver reads the effort off the deployed file's variant field (reverseFromOpencode already collects it into tool_extras.opencode) and passes it through to the adapter.

The mode half — whether pull keeps writing subagent and documents tool_extras.opencode.mode as the escape, or writes a primary-mode copy for workflow-destined agents — is a design call I've left on the issue rather than picking unilaterally.

Verification

Red tests first, both shapes pinned (workflow-local-tool-adapter.test.ts):

  • OpenCode 1: run args contain --model anthropic/claude-sonnet-4-5 and --variant high, no #high
  • OpenCode 2: run args contain --model anthropic/claude-sonnet-4-5#high, no --variant

Real CLI, after npm run build, against the pinned devDependency (OpenCode 1.18.23), agent file exactly as pull deploys it:

$ opencode run --format json --agent reviewer "Reply with just: ok"
! agent "reviewer" is a subagent, not a primary agent. Falling back to default agent

$ opencode run --format json --agent reviewer --model anthropic/claude-sonnet-4-5 --variant high "Reply with just: ok"
(no usage error — the flags parse, the session starts; the run's own error is upstream provider auth in this sandbox)

The second command shows the emitted shape is accepted by OpenCode 1's CLI; whether the model is honored is the report's table (row 2: explicit --model → model sent, even in fallback). I did not re-run their request-body capture.

Suites: 132/132 (adapter + driver + agent-format), e2e 2/2, tsc and lint clean.

Closes the model half of #1193.

…nt#1193)

A workflow step with agent: on OpenCode launched
opencode run --format json <prompt> --agent <name> and nothing else,
while pull deploys every OpenCode agent as mode: subagent. On OpenCode 1
a subagent is not a primary agent, so run falls back to the default
agent - the definition's prompt and model never run. On OpenCode 2 the
definition's prompt applies but its model and variant are ignored.

The model half: the driver now passes the step agent's mapped model
explicitly, the way the codex family in the same invocation already
does. The report's request-body table shows both majors honor an
explicit --model even in fallback. The mapped effort rides with it:
--variant on OpenCode 1, inside the model id (prov#effort) on OpenCode
2, where run has no separate variant flag; the major is probed once per
executable and cached, reading as 1 (the pinned devDependency) when the
probe fails.

The driver reads the effort off the deployed file's variant field
(reverseFromOpencode already collects it into tool_extras.opencode).

The mode half - whether pull should keep writing subagent and document
tool_extras.opencode.mode as the escape, or write a primary-mode copy
for workflow-destined agents - is a design call left on the issue.
@jeff-r2026 jeff-r2026 self-assigned this Oct 18, 2026
@github-actions

Copy link
Copy Markdown

No confident findings in the three-file head-commit diff inspected. The PR description includes a post-build real-CLI verification record; no missing-testing finding is warranted.

Review limitation: The checkout is shallow, and the requested three-dot diff fails with no merge base. I inspected cf03ed3...8c0b26f instead, so I cannot certify that the entire requested PR diff was reviewed.

No PR code was run, built, or installed.

@kittimzhe

Copy link
Copy Markdown
Contributor Author

Closing — superseded by #1192, which landed both halves. I missed the pointer posted 23 minutes after my claim and opened this before re-reading the thread; sorry for the duplicate.

The independent run did converge: the model half here is the same shape #1192 shipped — --model M --variant V on OpenCode 1, --model M#V on OpenCode 2, the major probed once per executable and cached. I'd left the mode half open as a design call, and #1192's answer (keep subagent; on OpenCode 1 a subagent step inlines the instructions without --agent, warning about the file settings that then don't apply) is the cleaner one.

Thanks for the careful-repro note on the issue — glad the forensics held up.

@kittimzhe kittimzhe closed this Oct 18, 2026
@kittimzhe
kittimzhe deleted the fix/opencode-agent-model-1193 branch October 18, 2026 12:49
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.

2 participants