Skip to main content

Qwen-Agent

Agent framework for building LLM applications with function calling, RAG, code interpreter, and multi-agent workflows

What is Qwen-Agent?

Qwen-Agent is a comprehensive framework for developing LLM applications based on the instruction following, tool usage, planning, and memory capabilities of Qwen models. It provides both atomic components (LLMs, Tools) and high-level abstractions (Agents, Multi-Agent Systems) to help you build sophisticated AI applications.

Function Calling

Execute tools and APIs with native function calling support

Code Interpreter

Run Python code safely in Docker sandbox environments

RAG Support

Build knowledge-grounded applications with retrieval-augmented generation

Multi-Agent Systems

Coordinate multiple agents for complex workflows

Key Features

Native support for function calling with parallel tool execution. Agents can intelligently select and execute multiple tools simultaneously to accomplish complex tasks.
Execute Python code in isolated Docker containers with full sandboxing. Perfect for data analysis, visualization, and mathematical computations.
Parse and process multiple document formats (PDF, Word, PowerPoint, HTML) with built-in retrieval systems for question-answering over large document collections.
Support for Model Context Protocol (MCP) to connect with external tools and services through standardized interfaces.
Handle super-long documents with 1M+ token contexts using advanced RAG solutions that outperform native long-context models.
BrowserQwen Chrome extension for web page interaction, PDF reading, and content creation based on browsing history.

Quick Example

Here’s a simple example of creating an agent with custom tools:
from qwen_agent.agents import Assistant
from qwen_agent.tools.base import BaseTool, register_tool

# Define a custom tool
@register_tool('my_image_gen')
class MyImageGen(BaseTool):
    description = 'AI painting service that generates images from text descriptions.'
    parameters = [{
        'name': 'prompt',
        'type': 'string',
        'description': 'Detailed description of the desired image content',
        'required': True
    }]

    def call(self, params: str, **kwargs) -> str:
        prompt = json5.loads(params)['prompt']
        # Your image generation logic here
        return json5.dumps({'image_url': f'https://example.com/{prompt}'})

# Configure the LLM
llm_cfg = {
    'model': 'qwen-max-latest',
    'model_type': 'qwen_dashscope',
    'generate_cfg': {'top_p': 0.8}
}

# Create an agent with tools
bot = Assistant(
    llm=llm_cfg,
    system_message='You are a helpful assistant that can generate images.',
    function_list=['my_image_gen', 'code_interpreter']
)

# Chat with the agent
messages = [{'role': 'user', 'content': 'Draw a sunset over mountains'}]
for response in bot.run(messages=messages):
    print(response)

Why Qwen-Agent?

Modular Architecture

Build with composable components: Agents, Tools, LLMs, and Memory systems

Production Ready

Battle-tested as the backend for Qwen Chat with millions of users

Extensible

Easy to add custom tools, agents, and LLM integrations

Multi-Model Support

Works with Qwen3.5, Qwen3, QwQ, and OpenAI-compatible APIs

Rich Tool Ecosystem

Built-in tools for web search, document parsing, image generation, and more

GUI Support

Rapid prototyping with Gradio-based web interfaces

Use Cases

  • Conversational AI: Build chatbots with tool usage and memory
  • Document Analysis: Question-answering over large document collections
  • Code Generation: Generate and execute code for data analysis and visualization
  • Web Automation: Browser-based agents for web scraping and interaction
  • Multi-Agent Collaboration: Coordinate multiple specialized agents for complex workflows
  • Research Assistants: RAG-powered systems for knowledge retrieval and synthesis

Get Started

Installation

Install Qwen-Agent and set up your environment

Quickstart

Build your first agent in 5 minutes

Core Concepts

Understand the building blocks of Qwen-Agent

API Reference

Explore the complete API documentation

Community & Support

GitHub

View source code and contribute

Documentation

Official Qwen-Agent documentation

Discord

Join the community discussion

Blog

Read technical articles and updates

Build docs developers (and LLMs) love