Creating Agent Extensions
Subagents (also called agents) are specialized AI assistants configured for specific tasks. They have their own system prompts, tool access, and model configurations. Extensions can package and distribute agents for others to use.What are Subagents?
Subagents are:- Specialized AI assistants with custom system prompts
- Configured with specific tools and capabilities
- Can use different models or parameters
- Invokable through the agent manager dialog
- Useful for task-specific expertise
Agent File Format
Agents are defined in Markdown files with YAML frontmatter:Frontmatter Fields
Required:name- Unique identifier for the agent (lowercase, dashes)description- Brief description shown in agent manager
color- Visual color in UI (blue, green, yellow, red, purple, etc.)tools- Array of tool names the agent can usemodelConfig- Model configuration overridesmodel- Model to use (e.g.,qwen3-coder-plus)temperature- Creativity level (0.0-1.0)- Other model parameters
Available Tools
Common tools you can grant to agents:Read- Read filesWrite- Write/create filesEdit- Edit existing filesGrep- Search file contentsGlob- Find files by patternBash- Execute shell commandsWebFetch- Fetch web pagesWebSearch- Search the webTodoWrite- Manage todo lists
Extension Structure
Place agent files in anagents/ directory:
Configure in Manifest
Updateqwen-extension.json:
agents field specifies the directory containing agent files (defaults to "agents" if not specified).
Example: Diary Writer Agent
Here’s a complete example from the Qwen Code templates:Example: Test Writer Agent
Example: Refactoring Expert
Best Practices
1. Clear Purpose
Define a focused purpose for each agent:2. Appropriate Tools
Only grant tools the agent actually needs:3. Structured Prompts
Organize the system prompt with clear sections:4. Model Selection
Choose appropriate models:5. Task Examples
Include examples in the prompt:Using Agents
Once installed, users access agents through:- Browse available agents
- See agent descriptions and capabilities
- Select an agent to start a conversation
- Switch between agents
Agent Discovery
Extension agents appear in the agent manager under “Extension Agents” section, separate from user-defined agents.Multiple Agents
You can include multiple agents in one extension:Agent vs Skill
When to use an Agent:- User explicitly invokes it
- Complex, multi-step workflows
- Needs conversation context
- Requires human input/decisions
- AI automatically invokes it
- Specialized capability
- Single-purpose function
- No human interaction needed
Next Steps
- Creating Extensions - Build a complete extension
- Skills - Create AI-invoked capabilities
- Commands - Add custom commands
- Best Practices - Extension development guidelines
