Repository navigation
feat(XCOD-82): configurable subagent model selection (part 1) - #27
Merged
Merged
Conversation
Resolution, first match wins: per-call (only if subagent.dynamic.enabled
and on subagent.dynamic.allow; anything else is refused, never replaced) →
per-type agent.<type>.model → global subagent.model → inherit.
Values: "inherit", "small" (small_model, else inherit), "provider/model".
- agent/subagent-model.ts: pure resolver returning the model, variant,
rule and source. checkResidency() runs before the subagent session
starts; a denial names the rule ("agent.qa.model → anthropic/... denied
by residency policy") and is written to the residency audit log.
- Reasoning variant: inherited models keep the main agent's variant;
overridden models use the configured variant or the model default. This
removes the silent variant drop at task.ts:209.
- Resume keeps the original run's model unless the call explicitly picks
another allowed model.
- Task tool: `model` is only in the JSON schema when dynamic selection is
enabled, as an enum of allowed models minus residency-denied ones. It is
added per request in the tool registry.
- Metadata: model, modelRule and modelSource on every task call.
- Config: `subagent` declared in ConfigV1.Info and the v2 schema;
agent.<type>.model keeps its raw spec so "small"/"inherit" survive.
- Docs: agents.mdx "Choosing models for subagents", deployment guide note,
CHANGELOG.
Real runs (test/cli/run/subagent-model.test.ts; the scripted LLM records
the model each request actually used): no config → subagent on the main
model; agent.explore.model "small" → explore called small-model;
subagent.model → global; dynamic allowed → per-call, off-list → tool
error; residency-denied per-type model → refused before start, never
called, audit line written. Removing checkResidency fails the last case.
Not in this part: graduating the background flag, the monitoring surface,
and lifecycle semantics. Those are the rest of XCOD-82.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Part 1 of XCOD-82: configurable subagent model selection. The ticket stays open. Graduating the background flag, the monitoring surface and the lifecycle semantics come in part 2.
Resolution
The first rule that matches wins:
subagent.dynamic.enabledis true and the model is onsubagent.dynamic.allow. Anything else is refused with a tool error the model can see; it is never silently replaced.agent.<type>.model.subagent.model.Each setting accepts three values:
"inherit","small"(usessmall_model, or inherits if that isn't set), or"provider/model".Rules the ticket required
variant, or the model's default. This removes the silent variant drop attask.ts:209.agent.qa.model → anthropic/claude-haiku-4-5 denied by residency policy.dynamic.allowthat the policy denies are never offered to the main agent.modelparameter exists only when dynamic selection is enabled, and then as an enum of the allowed models. It is added per request in the tool registry.task_idkeeps the original run's model unless the call explicitly picks another allowed one.model,modelRuleandmodelSource.subagentis declared in bothConfigV1.Infoand the v2 schema, andagent.<type>.modelkeeps its raw spec. A config test decodes every new key from a real file.Verification:
test/cli/run/subagent-model.test.ts, reallunos runThe scripted LLM records the
modelfield of every request, so each case checks which model was actually called, not just what the resolver returned.test-model(main)agent.explore.model: "small"small-modelagent.explore.modelsubagent.modelsmall-modelsmall-modelnot on subagent.dynamic.allowallow: ["eu"],agent.explore.model: anthropic/…anthropic allowed:falseagent.explore.modelcheckResidencymakes the residency case fail.modelfield. The validator must accept it; the wire schema strips it unless dynamic selection is on.turbo typecheckpasses after./script/generate.ts.🤖 Generated with Claude Code