Skip to content

[bug] A workflow step on OpenCode does not run as its agent #1193

Open

Description

@SaulMoro

Description

A local workflow step with agent: on OpenCode launches opencode run --format json <prompt> --agent <name>. Neither OpenCode major runs the definition that teamai pull deploys for that agent:

  • OpenCode 1 replaces it with the default agent. Pull writes every OpenCode agent with mode: subagent, unless tool_extras.opencode.mode sets another mode. opencode run --agent does not run a subagent. It prints ! agent "reviewer" is a subagent, not a primary agent. Falling back to default agent. The step then runs without the definition's prompt, model, or variant.
  • OpenCode 2 applies the prompt but not the file's model: or variant:. The step runs on the configured default model at its default effort.

The step still counts as run by the definition. The driver reports the file's model as the step's model when the tool reports none. On #1184, the record would also say agent.definition.applied: main, with the file's model as agent.model.requested.

Reproduction

The project's opencode.json sets "model": "anthropic/claude-haiku-4-5" as the default. It also points provider.anthropic.options.baseURL at a local server, which logs each request body. The agent file is the one pull deploys for an agent with model: strong, where strong maps OpenCode to { model: anthropic/claude-sonnet-4-5, effort: high }. A marker is appended to its prompt.

---
description: Reviews a change and answers with a JSON verdict.
mode: subagent
model: anthropic/claude-sonnet-4-5
variant: high
---
You review changes. Never edit files. PROBE-MARKER

Each run is opencode run --format json <flags> hi, and OpenCode 2 also gets --standalone. The table shows the request that carries the message. Each run also sends a title request on a small model.

OpenCode Flags Model sent Thinking Agent prompt sent
1.18.23 --agent reviewer claude-haiku-4-5 none no
1.18.23 --agent reviewer --model anthropic/claude-sonnet-4-5 claude-sonnet-4-5 none no
1.18.23, the same file with mode: all --agent reviewer claude-sonnet-4-5 enabled, 16000 yes
1.18.23, the same file with mode: all --agent reviewer --model anthropic/claude-sonnet-4-5 claude-sonnet-4-5 enabled, 16000 yes
2.0.30, mode: subagent or mode: all --agent reviewer claude-haiku-4-5 none yes
2.0.30, mode: subagent or mode: all --agent reviewer --model anthropic/claude-sonnet-4-5 claude-sonnet-4-5 none yes
1.18.23, no agent --model anthropic/claude-sonnet-4-5 --variant high claude-sonnet-4-5 enabled, 16000 n/a
2.0.30, no agent --model anthropic/claude-sonnet-4-5#high claude-sonnet-4-5 enabled, 16000 n/a

The last two rows are controls. They show that each version sends the high variant when it applies it.

Environment

  • OS: macOS 27.0
  • Node.js: v24.21.0
  • teamai: 0.22.0, main at fe3b906
  • Provider: git
  • AI tool(s): OpenCode 1.18.23 (the pinned devDependency) and OpenCode 2.0.30

Notes

  • I don't know why OpenCode 2 ignores the file's model: and variant:. Its run --help takes a variant only inside --model provider/model#variant.
  • Not measured: whether an interactive OpenCode session, which starts these agents as subagents, applies their model and variant.
  • A possible fix is to launch OpenCode with the definition's model and variant on argv, as the Codex launch already passes the definition's model: --model m --variant v on 1 and --model m#v on 2. OpenCode 1 also needs the definition to run at all. That could mean a primary-capable mode for the agents a workflow runs, or the instructions in the prompt, as Codex gets them.
  • feat(workflow): let a prompt step choose its model (#1177) #1192 (for [feat] Let a workflow choose the model of its prompt steps #1177) fails a step whose model is its agent's own model with no effort, while the agent file sets variant and a mode other than subagent. That is the one case where OpenCode 1 brings the agent's variant back. A fix here should revisit that check. OpenCode 2 never brings the variant back.

Activity

  1. SaulMoro commented on Oct 16, 2026

    @SaulMoro
    CollaboratorAuthor

    #1184 no longer records what this issue describes. On OpenCode, a pass records only the definition's name, with no applied and no model taken from the file. The step's flat model is the model the tool reported, or none, so the file's model is no longer used as a fallback. A real run on OpenCode 1.18.23 shows the entry before and after.

    The fix for this issue goes into #1192, which will close it. Once OpenCode runs the definition, the record can say how again. That is prompt when the instructions are prepended, and main when --agent applies. The requested model and effort come from what the launch passes on argv. Whichever of #1184 and #1192 merges second wires that in.

  2. kittimzhe commented on Oct 17, 2026

    @kittimzhe
    Contributor

    Taking this — with the mechanism verified on both ends before proposing a shape.

    Reproduced the OpenCode 1 half against the pinned devDependency (1.18.23), with the agent file exactly as pull deploys it (mode: subagent, mapped model, marker in the prompt):

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

    Both ends are in the repo, and they disagree about what a workflow step means:

    • renderForOpencode writes mode: 'subagent' for every OpenCode agent (resources/agent-format.ts:439), documented as deliberate ("teamai only syncs subagents"), overridable via tool_extras.opencode.mode.
    • The workflow driver runs ['run', '--format', 'json', prompt, '--agent', name] and nothing else (workflow/local-tool-adapter.ts:79) — the codex family in the same function passes --model when the step's agent maps one, the OpenCode family never does, so even the explicit---model escape the report's table proves honored never happens.

    Proposed split:

    1. Model half (mechanical, I'll implement): the OpenCode family passes the step agent's mapped --model. Per the table, OpenCode 1 honors the flag (even in fallback), OpenCode 2 honors prov#variant — so the variant rides inside the model flag for 2 and as --variant for 1. The driver needs to know which shape to emit; I'd probe once per run unless there's a preferred existing version gate.
    2. Mode half (design call): mode: subagent is pull's documented decision, and the fallback means the definition's prompt never runs on OpenCode 1 either. Flipping the write to all changes the interactive agent picker for everyone, so I don't want to pick unilaterally: keep subagent + document tool_extras.opencode.mode: all as the workflow escape (mechanism already exists), or write a primary-mode copy for workflow-destined agents?

    I'll start with the model half — red test first against the pinned devDependency — and the mode half follows whichever you call.

  3. SaulMoro commented on Oct 17, 2026

    @SaulMoro
    CollaboratorAuthor

    Thanks for picking this up, and for the careful repro. This is already fixed in #1192, which closes this issue. It is open with CI green and waiting for review, so please don't spend time on a separate fix.

    What #1192 does, against both halves of your split:

    • Model half. The OpenCode launch passes the definition's model and variant, or the step's model when the step sets one. That is --model M --variant V on OpenCode 1 and --model M#V on OpenCode 2. The version comes from the existing opencodeMajorVersion, asked of the executable the step actually launches and cached per path.
    • Mode half. Pull keeps deploying mode: subagent. On OpenCode 1, a subagent step gets the agent's instructions in the prompt with no --agent, as Codex does, and a warning names the file settings that then don't apply, such as permission. tool_extras.opencode.mode: all still runs through --agent. OpenCode 2 runs every agent through --agent.
    • A hang you may hit while testing. Both OpenCode majors wait for a piped stdin to close before they start. The adapter now starts every tool with stdin ignored.

    The PR body has the request bodies from real OpenCode 1.18.23 and 2.0.30 runs. A review of #1192 would be very welcome, especially on the mode-half choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions