Qwen-Agent Agent Types: A Complete Guide to AI Agent Classes
Qwen-Agent supports over 20 distinct agent types—including assistants, ReAct reasoners, document QA systems, writing agents, and multi-agent orchestrators—all inheriting from the abstract Agent base class defined in qwen_agent/agent.py.
Qwen-Agent is an open-source LLM application development framework that ships with a rich hierarchy of specialized agent classes. Whether you need simple function calling, retrieval-augmented generation, or complex multi-agent group chats, understanding the different Qwen-Agent agent types helps you select the right tool for your workflow.
Core Agent Architecture
All agents in Qwen-Agent inherit from the abstract base class Agent located in qwen_agent/agent.py. This base class defines the core interface including the run method, _call_llm for LLM invocation, _call_tool for tool execution, and streaming interfaces.
For minimal use cases, BasicAgent provides a concrete subclass without additional capabilities. It serves as the simplest possible agent implementation in the framework.
Function-Calling Agents
Function-calling agents wrap LLM function-calling capabilities with tool execution logic.
FnCallAgent
FnCallAgent in qwen_agent/agents/fncall_agent.py implements the standard function-calling workflow. It parses tool definitions from the LLM, executes the requested tools, and returns results to the model. Most higher-level agents in Qwen-Agent build upon this foundation.
ReActChat
ReActChat in qwen_agent/agents/react_chat.py implements the ReAct reasoning loop, combining Chain-of-Thought reasoning with tool use. This agent type is ideal for complex queries requiring multi-step reasoning and external data retrieval.
from qwen_agent.agents import ReActChat
react = ReActChat()
messages = [{"role": "user", "content": "Find the current temperature in Tokyo"}]
for chunk in react.run(messages):
# chunk is a list of Message objects (streamed)
print(chunk[-1].content, flush=True)
RAG-Enabled Assistants
Retrieval-Augmented Generation assistants combine function calling with document retrieval capabilities.
Assistant
Assistant in qwen_agent/agents/assistant.py is the general-purpose RAG assistant. It extends FnCallAgent to add retrieval capabilities, making it suitable for knowledge-base问答 and document-aware conversations.
from qwen_agent.agents import Assistant
# Create a plain assistant; it loads the default LLM configuration from env vars
assistant = Assistant()
# Single-turn chat (non-streaming for simplicity)
messages = [{"role": "user", "content": "What is the capital of France?"}]
response = list(assistant.run(messages))[0] # first (and only) response
print(response[0].content) # → "Paris"
VirtualMemoryAgent
VirtualMemoryAgent in qwen_agent/agents/virtual_memory_agent.py provides a persistent "virtual memory" store for long-term context across conversation sessions.
DialogueRetrievalAgent
DialogueRetrievalAgent in qwen_agent/agents/dialogue_retrieval_agent.py specializes in retrieving relevant dialogue history before generating responses, optimized for conversational RAG scenarios.
MemoAssistant
MemoAssistant in qwen_agent/agents/memo_assistant.py maintains a short-term "memo" across conversation turns, useful for tracking temporary context or user preferences.
DialogueSimulator
DialogueSimulator in qwen_agent/agents/dialogue_simulator.py simulates multi-turn dialogue for testing or synthetic data generation purposes.
Document Question Answering
Specialized agents for processing long documents and answering questions based on their content.
DocQAAgent
DocQAAgent (aliased as BasicDocQA) in qwen_agent/agents/doc_qa/basic_doc_qa.py is the default long-document QA agent. It internally uses RAG and tool calls to process documents that exceed context window limits.
ParallelDocQA
ParallelDocQA in qwen_agent/agents/doc_qa/parallel_doc_qa.py provides a parallelized version that splits documents across multiple sub-agents for faster processing of very large document sets.
Writing and Content Generation
Agents specialized in creative writing and content generation workflows.
WriteFromScratch
WriteFromScratch in qwen_agent/agents/write_from_scratch.py composes full pieces of text from a blank slate based on user prompts.
from qwen_agent.agents import WriteFromScratch
writer = WriteFromScratch()
prompt = [{"role": "user", "content": "Write a 300-word blog post about renewable energy"}]
article = list(writer.run(prompt))[0][0].content
print(article)
ContinueWriting
ContinueWriting in qwen_agent/agents/writing/continue_writing.py extends existing drafts while preserving style and context.
OutlineWriting
OutlineWriting in qwen_agent/agents/writing/outline_writing.py generates structured outlines for long-form content planning.
ExpandWriting
ExpandWriting in qwen_agent/agents/writing/expand_writing.py expands brief bullet points into detailed paragraphs.
ArticleAgent
ArticleAgent in qwen_agent/agents/article_agent.py combines multiple writing helpers to produce polished, publication-ready articles.
Multi-Agent Orchestration
Agents designed to coordinate multiple sub-agents in complex workflows.
GroupChat
GroupChat in qwen_agent/agents/group_chat.py serves as the core multi-agent hub. It forwards messages to member agents and aggregates their responses, enabling collaborative problem-solving.
from qwen_agent.agents import GroupChat, Assistant, ReActChat
assistant = Assistant()
react = ReActChat()
group = GroupChat(members=[assistant, react], name="DemoGroup")
messages = [{"role": "user", "content": "Explain quantum tunneling in layman's terms"}]
# Run the group chat; each member replies and the hub aggregates
for resp in group.run(messages):
print("Group reply:", resp[0].content)
Router
Router in qwen_agent/agents/router.py combines group chat capabilities with assistant functionality to route messages to appropriate sub-agents based on content analysis.
GroupChatAutoRouter
GroupChatAutoRouter in qwen_agent/agents/group_chat_auto_router.py automatically routes incoming messages to the most appropriate sub-agent within a group chat using content-based heuristics.
GroupChatCreator
GroupChatCreator in qwen_agent/agents/group_chat_creator.py generates GroupChat configurations automatically from high-level specifications, simplifying multi-agent setup.
MultiAgentHub
MultiAgentHub in qwen_agent/multi_agent_hub.py is a mixin class providing utilities for registering, looking up, and invoking sub-agents across the framework.
Specialized and Utility Agents
Domain-specific agents for mathematics, simulation, and testing scenarios.
TIRMathAgent
TIRMathAgent in qwen_agent/agents/tir_agent.py is a mathematics-oriented agent that uses tool-integrated reasoning (TIR) for symbolic computation and mathematical problem-solving.
HumanSimulator
HumanSimulator in qwen_agent/agents/human_simulator.py simulates human participants in group chats, primarily used for testing group-chat logic and synthetic conversation generation.
UserAgent
UserAgent in qwen_agent/agents/user_agent.py is a thin wrapper that allows the human user to act as an agent within multi-agent demonstrations, enabling interactive participation.
Key-Generation Strategies
The framework includes small helper agents for query processing located in qwen_agent/agents/keygen_strategies/:
GenKeywordingen_keyword.pygenerates search keywords from user queriesSplitQuerysplits complex queries into manageable sub-queries
These inherit from the base Agent class and support retrieval workflows.
Summary
- Qwen-Agent provides a hierarchical agent architecture centered on the abstract
Agentclass inqwen_agent/agent.py. - Function-calling agents like
FnCallAgentandReActChathandle tool use and reasoning workflows. - RAG-enabled assistants including
Assistant,VirtualMemoryAgent, andDialogueRetrievalAgentcombine retrieval with generation. - Document QA agents such as
DocQAAgentandParallelDocQAspecialize in long-form document processing. - Writing agents like
WriteFromScratchandArticleAgentsupport content creation pipelines. - Multi-agent orchestration via
GroupChat,Router, andMultiAgentHubenables complex collaborative workflows. - Specialized agents including
TIRMathAgentandHumanSimulatoraddress domain-specific use cases.
Frequently Asked Questions
What is the base class for all Qwen-Agent agent types?
All agent types in Qwen-Agent inherit from the abstract Agent class defined in qwen_agent/agent.py. This base class establishes the core interface including the run method, _call_llm for LLM invocation, _call_tool for tool execution, and streaming interfaces. Even specialized agents like GroupChat and TIRMathAgent ultimately trace back to this foundation.
How do I choose between Assistant and ReActChat agents?
Choose Assistant when you need a general-purpose agent with retrieval-augmented generation capabilities for knowledge-base问答 and document-aware conversations. Select ReActChat when your task requires explicit reasoning chains combined with tool use, such as multi-step problem solving or complex queries requiring intermediate reasoning steps. Both inherit from FnCallAgent but optimize for different interaction patterns.
Can I combine multiple agent types in a single application?
Yes, you can compose multiple agent types using GroupChat or MultiAgentHub. The GroupChat class in qwen_agent/agents/group_chat.py allows you to instantiate different agents like Assistant and ReActChat as members, then coordinate them through a central hub. The MultiAgentHub mixin in qwen_agent/multi_agent_hub.py provides utilities for registering, looking up, and invoking sub-agents programmatically across complex workflows.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →