feat: simplify subagent model configuration with model selector

Refactor subagent model configuration from nested modelConfig object to a simple model string field for better UX and clarity.

Changes:
- Replace modelConfig object with model string in SubagentConfig interface
- Add model-selection.ts utility for parsing and validating model selectors
- Support 'inherit' keyword and bare model IDs (e.g., 'glm-5', 'claude-sonnet-4-6')
- Maintain backward compatibility by parsing legacy modelConfig frontmatter
- Update validation to reject cross-provider authType-prefixed selectors
- Update SDK types (TypeScript and Java) to reflect new schema
- Add comprehensive tests for model selection and validation
- Update documentation with model selection examples

Breaking changes:
- modelConfig.frontmatter field deprecated in favor of model field
- Cross-provider model selectors (e.g., 'openai:gpt-4') not supported for subagents

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
tanzhenxin 2026-03-27 11:49:45 +08:00
parent 3776825c2d
commit 5d58b2f112
17 changed files with 372 additions and 207 deletions

View file

@ -98,6 +98,7 @@ Subagents are configured using Markdown files with YAML frontmatter. This format
---
name: agent-name
description: Brief description of when and how to use this agent
model: inherit # Optional: inherit or model-id
tools:
- tool1
- tool2
@ -106,9 +107,17 @@ tools:
System prompt content goes here.
Multiple paragraphs are supported.
You can use ${variable} templating for dynamic content.
```
#### Model Selection
Use the optional `model` frontmatter field to control which model a subagent uses:
- `inherit`: Use the same model as the main conversation
- Omit the field: Same as `inherit`
- `glm-5`: Use that model ID with the main conversation's auth type
- `sonnet`, `opus`, `haiku`: Alias-style values are also accepted as model strings
#### Example Usage
```
@ -117,12 +126,7 @@ name: project-documenter
description: Creates project documentation and README files
---
You are a documentation specialist for the ${project_name} project.
Your task: ${task_description}
Working directory: ${current_directory}
Generated on: ${timestamp}
You are a documentation specialist.
Focus on creating clear, comprehensive documentation that helps both
new contributors and end users understand the project.
@ -213,7 +217,7 @@ tools:
- web_search
---
You are a technical documentation specialist for ${project_name}.
You are a technical documentation specialist.
Your role is to create clear, comprehensive documentation that serves both
developers and end users. Focus on: