Skip to main content

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
Optional:
  • color - Visual color in UI (blue, green, yellow, red, purple, etc.)
  • tools - Array of tool names the agent can use
  • modelConfig - Model configuration overrides
    • model - 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 files
  • Write - Write/create files
  • Edit - Edit existing files
  • Grep - Search file contents
  • Glob - Find files by pattern
  • Bash - Execute shell commands
  • WebFetch - Fetch web pages
  • WebSearch - Search the web
  • TodoWrite - Manage todo lists

Extension Structure

Place agent files in an agents/ directory:

Configure in Manifest

Update qwen-extension.json:
The 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:
This opens the agent manager where they can:
  • 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:
Each serves a different purpose in the development workflow.

Agent vs Skill

When to use an Agent:
  • User explicitly invokes it
  • Complex, multi-step workflows
  • Needs conversation context
  • Requires human input/decisions
When to use a Skill:
  • AI automatically invokes it
  • Specialized capability
  • Single-purpose function
  • No human interaction needed

Next Steps