feat(new_task): add optional variant parameter for per-subtask reasoning#9172
Open
Githubguy132010 wants to merge 18 commits intoKilo-Org:mainfrom
Open
feat(new_task): add optional variant parameter for per-subtask reasoning#9172Githubguy132010 wants to merge 18 commits intoKilo-Org:mainfrom
Githubguy132010 wants to merge 18 commits intoKilo-Org:mainfrom
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Forward the optional `variant` field from a SubtaskPart into both the persisted tool-call `state.input` record and the `taskArgs` object passed to `taskTool.execute`, so the variant is available downstream in the subtask session. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a new live test "subtask variant is threaded into tool-part state.input" that creates a subtask with variant="high", drives the loop until the tool-part is observable, and asserts state.input.variant === "high". Also extends the addSubtask helper with an optional `variant` parameter and adds a variantProviderCfg helper with high/low variants on test-model. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
280f25a to
3714367
Compare
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (6 files)
Reviewed by gpt-5.4-20260305 · 2,766,052 tokens |
- Remove duplicate `const msg`/`const model` block that was left behind when the early-validation block was added (TS2451 redeclaration error) - Remove duplicate variant validation block (same code existed in both early and late positions in TaskTool.execute) - Rewrite variant tests to use existing `stubOps` + `promptOps` pattern instead of monkey-patching SessionPrompt namespace (which fails because SessionPrompt is imported as a type-only import and its properties are read-only consts) - Add `// kilocode_change` annotation to the modified import line in task.test.ts to satisfy the annotation CI check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Context
Closes #9145.
Currently the
new_tasktool has no way to override a subagent's reasoning level / variant for a specific subtask. The only workaround is to pre-define a second subagent with a differentagent.variant— coarse, and doesn't scale.This PR adds one optional
variantparameter tonew_taskso a primary agent can pick the reasoning effort per call (low,medium,high,xhigh,maxon Claude Opus 4.7;none,minimal,low,medium,high,xhighon OpenAI reasoning models; whatever the configured model exposes otherwise).Implementation
Additive-optional across four files:
packages/opencode/src/tool/task.ts— addedvariant: z.string().optional()to the tool schema and a validation block inTaskTool.executethat looks up the target model viaProvider.getModel(...)and fails the Effect with a helpful error listing available variants if the passed value isn't recognised.ModelNotFoundErroris caught viaEffect.tryPromiseand surfaced as a clean tool-level error. Themsg+modelresolution + validation block runs beforeSession.create, so an invalid variant never creates an orphan child session. The validatedparams.variantis forwarded toSessionPrompt.prompt, where the pre-existingPromptInput.variant → createUserMessageprecedence handles the rest.packages/opencode/src/session/message-v2.ts— addedvariant: z.string().optional()toSubtaskPartso programmatic subtask callers (message-level SubtaskParts, not just the LLM tool call) can also specify a variant. Strictly additive — existing persisted sessions deserialize unchanged.packages/opencode/src/session/prompt.ts— inhandleSubtask, threadedtask.variantinto both the persisted tool-partstate.inputand thetaskArgsobject passed totaskTool.execute. Both paths converge at a single validation site inTaskTool.execute..changeset/new-task-variant.md— minor bump for@kilocode/cli.All new blocks under
packages/opencode/carry// kilocode_changemarkers.End-to-end flow: primary agent calls
new_task({ variant: "high" })→TaskTool.executeresolves the subagent's target model →Provider.getModelreturns the model with itsvariantsmap → validation fails fast if the variant isn't a key →SessionPrompt.prompt({ variant })→createUserMessagewritesvariantonto the child's user message →llm.tsmergesmodel.variants[variant]into provider options for the API call.When
variantis omitted, behavior is identical to before — noProvider.getModelround-trip, no variant injected anywhere.How to Test
Start a primary-agent session on a reasoning-capable model (e.g. Claude Opus 4.7), then:
Happy path (expected: subtask runs at the specified reasoning level)
Have the main agent invoke:
Inspect the child session's first user message —
model.variantshould be"max". If provider debug logging is on, the merged provider options should include the adaptive-reasoning config fromProviderTransform.variants.Negative path (expected: tool-level error, no child session created)
Call with
variant: "turbo". The tool result should be an error containing"turbo","Available variants:", and the real variant names for the target model. Running against a non-reasoning model with any variant should error with"does not support variants".Regression (expected: unchanged)
Omit
variantentirely. Behavior should be identical to today — the subagent runs at its configuredagent.variantif any, else default reasoning.Automated coverage
packages/opencode/test/tool/task.test.ts— 6 new tests: valid forward, invalid variant rejected with list, no-variants-on-model branch, omitted-variant regression guard,task_idresume + variant.packages/opencode/test/session/prompt-effect.test.ts— 1 new end-to-end test drivingprompt.loopon aSubtaskPartwith variant set, asserting it reaches the persisted tool-part input.All 11 tests in
task.test.tsand all non-skipped tests inprompt-effect.test.tspass on this branch. Typecheck is clean.Get in Touch
n/a