Skip to content

[FEATURE]: Task tool should support model parameter for cost-optimized multi-agent orchestration #26925

Description

@danielpsf-grover

Problem

When using OpenCode as an orchestrator that launches multiple sub-agents via the Task tool, there is no way to specify which model each sub-agent should use. The subagent_type parameter only accepts general or explore — there is no model parameter.

This means every sub-agent runs on the same (expensive) model as the orchestrator, even when the sub-agent's task is simple data gathering that a cheaper model could handle perfectly.

Real-world example (anonymized)

I asked OpenCode (using GitHub Copilot as a provider) to audit Kubernetes resource usage across multiple clusters. The orchestrator launched 5 sub-agents in parallel:

Sub-agent Task Complexity Ideal Model Actual Model
Call Datadog MCP tools, collect metrics LOW — tool calls only cheap (e.g. gpt-4o-mini, sonnet) claude-opus-4.6
Call Grafana MCP tools, collect metrics LOW — tool calls only cheap claude-opus-4.6
Run kubectl commands, parse JSON LOW — shell + parse cheap claude-opus-4.6
Search GitHub files, read YAML LOW — file reads cheap claude-opus-4.6
Cross-validate 3 datasets, write analysis report with 18 action specs HIGH — reasoning + synthesis expensive (opus) claude-opus-4.6

4 out of 5 agents were doing simple tool-calling work that any cheap model handles well. Only the final analysis agent needed heavy reasoning. But all 5 burned premium tokens at the orchestrator's model tier.

Proposed Solution

Add an optional model parameter to the Task tool:

{
  description: "Launch a new agent to handle complex, multistep tasks autonomously.",
  parameters: {
    // existing params...
    subagent_type: { type: "string", enum: ["general", "explore"] },
    model: {
      type: "string",
      description: "Optional model override for the sub-agent (e.g. 'github-copilot/gpt-4o-mini', 'anthropic/claude-sonnet-4'). If omitted, inherits the orchestrator's model."
    }
  }
}

Model resolution priority

  1. params.model (explicit per-invocation override)
  2. Agent config model (from opencode.json)
  3. Parent session model (current behavior)

Why this matters

  1. Cost optimization — Orchestrator patterns are becoming standard (plan → delegate → synthesize). Data-gathering agents don't need frontier models. A 5-agent workflow could cost 80% less by routing 4 agents to cheap models.

  2. Enables "double-tap" validation — Users want to launch Agent A with Model X, then Agent B with Model Y on the same task to cross-validate. Currently impossible without separate agent configs.

  3. The orchestrator knows best — The orchestrator agent understands each sub-task's complexity and should be able to make model routing decisions dynamically, not just at config time.

Prior art / related issues

#26536 proposed exactly this but was closed without substantive review. This issue provides a concrete real-world use case demonstrating the cost impact.

Alternatives considered

Alternative Why insufficient
Create separate agent configs per model in opencode.json Static — orchestrator can't choose model based on task complexity at runtime
Just use cheap model for everything Analysis/synthesis tasks need frontier models for quality
Manual multi-session workflow Defeats purpose of autonomous orchestration

Impact

For users running multi-agent workflows (DevOps audits, codebase migrations, parallel code reviews), this could reduce costs by 50-80% while maintaining quality where it matters.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions