GeezerVison is showing github.com — feat(opencode): add optional model param to Task tool and show provider in message headers by shoootyou · Pull Request #31694 · anomalyco/opencode
Conversation
shoootyou
commented
Jun 10, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
Closes #17595
Related #9584
Related #24812
Type of change
What does this PR do?
Two related changes:
1. Optional model param on the Task tool
Adds an optional model string (provider/model format) to the Task tool input. When provided, the spawned subagent runs on that model instead of its configured or inherited one. The param is validated before the child session is created so invalid values fail fast without orphaning a session. Error messages distinguish malformed format from unavailable models, and surface getModel's fuzzy suggestions as a Did you mean: clause.
Note: PR #29447 implements the same Task model param with an additional model_override permission gate (default deny). This PR intentionally omits that gate and leaves the policy decision to maintainers. The implementations are otherwise complementary — this one adds full test coverage (36 passing tests), differentiated error messages, and prototype-key security hardening.
2. provider/model in message headers
Shows provider/model (e.g. anthropic/Claude Sonnet 4) instead of just the model name in assistant and user message headers — across packages/ui (app + desktop) and the TUI (session view + transcript export). providerID was already persisted on AssistantMessage; this is a presentational change only.
How did you verify your code works?
bun test test/tool/task.test.ts in packages/opencode — 36/36 pass (model override, inheritance, error cases, prototype-key rejection, no orphan sessions)
bun test src/components/message-part-model.test.ts in packages/ui — 6/6 pass
bun test test/util/provider-model-label.test.ts test/util/model.test.ts test/util/transcript.test.ts in packages/tui — 29/29 pass
bun typecheck clean in packages/opencode, packages/ui, packages/tui
- Tested in a running
opencode serve instance: model override routes subagents correctly, provider/model label visible in the web UI
Screenshots / recordings
UI change (provider label in message headers) — screenshot available on request.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Allow a Task subagent call to specify the model it runs on via an
optional "providerID/modelID" string param. The model is parsed with
Provider.parseModel and validated with Provider.getModel; an explicit
model overrides both the agent's configured model and parent
inheritance, forcing variant to undefined. Omitting the param preserves
the existing inherit-from-agent/parent behavior.
Co-authored-by: yui-soul <[email protected]>
Display the provider alongside the model as "provider/model" in both
assistant footer and user header of the shared message component (used
by app web and desktop). Extracts a pure formatModelLabel helper with
per-field catalog fallback to raw providerID/modelID and a no-model
guard that never renders a stray slash.
Co-authored-by: yui-soul <[email protected]>
Add Model.providerModel formatter returning "provider/model" with raw
providerID/modelID fallback on catalog miss, leaving Model.name intact.
Switch the session transcript header and the session view model label to
the new formatter. Existing transcript tests updated to the new format.
Co-authored-by: yui-soul <[email protected]>
Address audit findings on the Task tool model override:
- treat the param as present when defined (model: "" now errors instead
of silently inheriting the parent model)
- reject empty and prototype-polluting segments (__proto__, constructor,
prototype) before any provider lookup, and catch defects so a crafted
value never leaks a raw TypeError
- validate the model before creating the child subagent session, so an
invalid model fails fast without spawning an orphan session
Adds tests for empty-string, prototype keys, multi-slash modelID, and
override-beats-agent-own-model.
Co-authored-by: yui-soul <[email protected]>
When the provider resolves but the model is unknown, render the provider
display name with the raw model id (provider/model), matching the shared
UI helper instead of falling back to raw IDs for both. Full miss still
yields raw providerID/modelID. Adds direct Model.name tests for the
retained helper.
Co-authored-by: yui-soul <[email protected]>
Add tests for the partial-miss branch (provider known, model unknown) and
both branches of the no-model guard, and replace the brittle double-cast
fixture with a fully-typed one.
Co-authored-by: yui-soul <[email protected]>
Replace the fixed denylist with a prototype-membership check
(segment in {}) so inherited Object.prototype member names such as
toString and valueOf cannot pass as a modelID against a valid provider
and spawn an orphan subagent session. Adds regression tests and
strengthens the empty-string assertion.
Co-authored-by: yui-soul <[email protected]>
Note that the invoking agent can override the subagent model per call via
the Task tool's optional model parameter (provider/model form), and that
an invalid value fails with an Invalid task model error.
Co-authored-by: yui-soul <[email protected]>
Split the single generic Task model error into format vs availability:
- malformed format (no slash, empty segment, prototype-chain key) keeps a
"provider/model format" explanation
- a well-formed but unknown provider reports "provider ... is not
configured"
- a known provider with an unknown model reports "model ... is not
available for provider ..."
Availability errors surface getModel suggestions (Did you mean: ...),
discriminated by the typed ModelNotFoundError tag and Provider.list()
membership rather than message text.
Co-authored-by: yui-soul <[email protected]>
Add cases for the empty/omitted suggestions branch (no dangling
Did you mean), pin the comma-join separator and order, cover the
single-suggestion no-comma path, guard the suggestion-presence loops
against vacuum, and assert the empty-string format echo.
Co-authored-by: yui-soul <[email protected]>
Distinguish the malformed-format Invalid task model error from the
well-formed-but-unavailable Model unavailable error (with suggestions).
Co-authored-by: yui-soul <[email protected]>
|
Hey! Your PR title feat(opencode,ui,tui): dynamic model param for Task tool + provider display in messages doesn't follow conventional commit format.
Please update it to start with one of:
feat: or feat(scope): new feature
fix: or fix(scope): bug fix
docs: or docs(scope): documentation changes
chore: or chore(scope): maintenance tasks
refactor: or refactor(scope): code refactoring
test: or test(scope): adding or updating tests
Where scope is the package name (e.g., app, desktop, opencode).
See CONTRIBUTING.md for details.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The following comment was made by an LLM, it may be inaccurate:
Based on my search, I found one potentially related PR:
Potential Duplicate/Related PR
PR #29447: feat(opencode): add task model override
#29447
This PR appears to address the same feature—adding a model override capability to the Task tool. Since PR #31694 (the current PR) implements dynamic model parameters for Task tools with both feature and provider display improvements, PR #29447 may be an earlier or alternative approach to the same problem.
You should verify whether #29447 was closed/superseded or if there's overlapping work between the two PRs.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
shoootyou
changed the title
feat(opencode,ui,tui): dynamic model param for Task tool + provider display in messages
feat(opencode): add optional model param to Task tool and show provider in message headers
Jun 10, 2026
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Jun 29, 2026
|
Closing this PR — the change has already been merged into our fork (shoootyou/opencode) and will be maintained there. Thanks for the framework!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|