GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(task): allow selecting a model per task invocation (1.18.23 lineage) by leoncheng57 · Pull Request #4 · leoncheng57/opencode

Conversation

@leoncheng57

@leoncheng57 leoncheng57 commented Aug 26, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Owner

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
leoncheng57 added 2 commits August 26, 2026 12:19
@leoncheng57
feat(task): allow selecting a model per task invocation
31b21f9
Adds an optional `model` parameter ("provider/model") to the native task
tool, so a delegating agent can route one subtask to a different model
without changing the subagent's configuration.

Precedence is explicit per-invocation model > subagent's configured model
> invoking assistant's model. Omitting the parameter is behaviourally
identical to before.

The model is resolved once, before the foreground/background branch, so a
BackgroundJob child runs the same model a foreground one would and the
`{ providerID, modelID }` tool metadata stays correct on every return path.

Validation is early: an explicit model goes through the same
Provider.getModel the prompt path calls later, but before the child
session is created, so an unavailable model fails without leaving an
orphaned child. Omission skips that call entirely and leaves the existing
fallback chain's late validation untouched.

The parent's variant is only inherited when the child actually runs the
parent's model, so a variant cannot leak onto a different model.

Provider.node is already a tool-registry dependency, so acquiring
Provider.Service adds no new wiring; the test layer is updated to match.
@leoncheng57
test(task): cover per-invocation model selection
cb32260
Wire shape: the new parameter is optional, string-typed, and rejects a
non-string; the JSON Schema snapshot records what the calling model sees.

Behaviour, against a config-declared provider so model lookups resolve
deterministically without network access or loading an SDK:

- explicit model beats the invoking assistant's model
- explicit model beats the subagent's configured model
- omission preserves both existing fallbacks, including that the parent's
  variant is still inherited only when no model overrides it
- an explicit model on a resumed task_id applies to that invocation and
  creates no second child, and does not persist onto the child session
- running and result metadata both report the selected pair
- a model id containing extra slashes parses as provider + rest
- a background launch runs the child on the selected model, asserted on
  the prompt actually addressed to the child rather than on the hand-back
  prompt injected into the parent

Validation is pinned to what the code really does rather than to the
aspiration: an unknown or malformed model fails with Provider's own
ProviderModelNotFoundError before any child session exists, before the
child is prompted, and before any running metadata is emitted.
This was referenced Aug 26, 2026
Sub-agents: make delegated work legible and controllable leoncheng57/dcaleon#208
Open
Allow explicit model selection when delegating a sub-agent leoncheng57/dcaleon#90
Closed
@github-actions github-actions Bot added the needs:compliance label Aug 26, 2026
@leoncheng57
leoncheng57 marked this pull request as ready for review August 26, 2026 17:19
@leoncheng57
leoncheng57 merged commit d677b7e into fix/subagent-effective-deny-inheritance Aug 26, 2026
4 of 9 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs:compliance label Aug 26, 2026
@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Aug 26, 2026
feat(task): optional per-invocation model selector for sub-agent tasks #3
Closed
Correct the upstream status of the subagent deny patch leoncheng57/dcaleon#231
Merged
Make OpenCode server restarts recoverable without prolonged BFF downtime leoncheng57/dcaleon#234
Open
Name the fork build with SemVer build metadata leoncheng57/dcaleon#238
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@leoncheng57
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.