Issue for this PR
Closes leoncheng57/dcaleon#90. Upstream tracking issue: anomalyco#6651.
Fork-internal PR: this targets fix/subagent-effective-deny-inheritance, the branch our local patched binary is built from. It is not a contribution to anomalyco/opencode — see the note at the bottom.
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
Adds an optional model parameter to the task tool so one delegation can run on a different model than the subagent's configured default.
Resolution order becomes: explicit model > subagent's configured model > invoking assistant's model. Omitting the parameter takes the same branch as before, so existing behaviour is untouched.
The model is resolved once, before the foreground/background split, so a background BackgroundJob child runs on the same model a foreground one would, and both report it in tool metadata. Metadata still carries the normalized { providerID, modelID } object, so downstream consumers that read task provenance need no change.
Validation is early: provider.getModel is called before the child session is created, so an unknown model fails with ProviderModelNotFoundError and leaves no orphaned child. This is the same call the prompt path makes later, so it changes when the failure happens, not whether.
On a resume via task_id, an explicit model applies to that invocation only and is not persisted as a session default.
How did you verify your code works?
bun test test/tool/task.test.ts test/tool/parameters.test.ts — 91 pass, 0 fail
bun run typecheck (tsgo) — exit 0
- Full
packages/opencode suite — 3329 pass, 1 fail; the failure is chunkTimeout ... SSE body stalls, which reproduces identically on the pristine base
- prettier clean; oxlint 0 added warnings
- Mutation check: reverting the precedence expression fails 6 of the new tests, including the background case
- Built the binary from the merged tip and diffed the live tool schema against the previous binary:
model appears in the task tool's properties and is absent from required; the old binary has no model key at all
Background coverage needed one correction: the completion handler injects a hand-back prompt into the parent, so a naive last-prompt capture asserts the wrong message. The test now asserts on the prompt addressed to the child.
Screenshots / recordings
Not a UI change.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Note on upstream
This is deliberately not proposed to anomalyco/opencode. That repository already has an active implementation of the same feature in anomalyco#34947, which additionally gates the parameter behind a model_override permission defaulting to deny. Earlier raw-parameter attempts (anomalyco#26535, anomalyco#29447) were closed as superseded by it. This fork carries the change only so the locally pinned binary has it.