Skip to content

[FEATURE]: Runtime model override for task tool subagents #17595

Closed as not planned

Description

@Quadina

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem: Subagents always run on the model configured at startup. There's no way for an orchestrating agent to switch models at runtime based on context.

Use cases:

  1. Adaptive review loop — orchestrator runs code review on haiku. If the same errors repeat twice, it escalates to sonnet or opus for a more thorough review (fewer false positives, better understanding of context).
  2. Variable-complexity reports — same report-generating subagent, but the orchestrator picks the model based on report difficulty. Simple report → cheap model. Complex/long report → stronger model. The agent definition stays the same.

Proposed approach: Add a model parameter to the task tool ("provider/model-id" format). Gate it with a new model_override permission (default: deny) so users control which models agents can switch to. Supports wildcards ("anthropic/*": "allow") and specific models.

Why permission-gated: Without it, a prompt injection could escalate to an expensive model, or an agent could pick models randomly. The permission system lets users whitelist exactly what's allowed.

Not a duplicate of #17570: That issue is about static config — users assign models to subagents upfront in config/UI. This is about runtime decisions — the orchestrating agent picks the model dynamically based on what's happening during execution (errors, complexity, retries). They're complementary features.


Note: PR #17577 with an implementation already exists — apologies for the reversed order. Opening this issue retroactively for proper tracking and design discussion.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 15, 2026
  2. github-actions commented on Mar 15, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your request adds meaningfully different scope (e.g., the permission-gating mechanism or the specific runtime-escalation use cases), please clarify how it differs so maintainers can decide whether to merge or keep separate.

  3. assigned and unassigned on Apr 26, 2026
  4. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. added a commit that references this issue on May 9, 2026
    bf6215a
  6. funkybooboo commented on May 9, 2026

    @funkybooboo

    I've opened PR #26535 implementing this feature with a minimal, permission-gated approach:

    • Adds an optional model parameter to the task tool (provider/model format)
    • model_override permission denied by default -- users opt in via config (e.g. "model_override": { "anthropic/*": "allow" })
    • Validates provider/model format with clear error messages
    • Model priority: params.model -> agent.model -> parent session model

    This is similar to #18528 but uses Effect Schema instead of zod and inlines the parsing to avoid importing the heavy Provider module. Compared to #11217 (UI-driven @agent:provider/model) and #11377 (tier abstraction), this takes the simplest direct approach with the security gate from the original issue.

  7. github-actions commented on Jul 9, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  8. Doble-K commented on Aug 7, 2026

    @Doble-K

    I ran into this issue while building an orchestration framework on top of OpenCode and wanted to share what I found after tracing the implementation.

    Initially I assumed this was a bug because I was requesting a Medium model for a delegated Worker task, but the Worker was executing with MiMo.

    After inspecting the framework, I realized the behavior was actually expected:

    • Agent-configured models are propagated correctly.
    • SubtaskPart.model is supported.
    • The HTTP Prompt API supports explicit model selection.
    • The Task tool itself does not expose a runtime model parameter, so there is no supported per-invocation override.

    The real problem in my framework turned out to be that the Director was still delegating to the generic worker alias instead of worker-medium. Since worker was configured with MiMo, the runtime was behaving correctly.

    Changing the delegation to explicit capability-based agents (worker-small, worker-medium, worker-large) solved the problem without any changes to OpenCode.

    So I can confirm that this is not a runtime bug—the current implementation is internally consistent.

    Although I still think a runtime model override could simplify orchestration frameworks by reducing duplicated agent definitions, the current capability-based approach works well once the routing is configured correctly.

    Hopefully this investigation helps anyone who arrives here after assuming the model selection is being ignored, as I initially did.

  9. RajatGarga commented on Aug 22, 2026

    @RajatGarga

    I have hit a stone wall on this. I want to use opencode as my primary harness and hoped that this feature would ship but all I see is dead discussions closed automatically. Some with PRs as well

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

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