# aluro7in/qwen-agent architecture

> Architecture diagram of the GitHub repository aluro7in/qwen-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aluro7in/qwen-agent
- Repository: https://github.com/aluro7in/qwen-agent

## Overview

Qwen-Agent is an LLM application framework whose main workflow turns a user request into an agent response, optionally planning or routing work through model calls and tools. Its documented capabilities include retrieval-augmented document QA, memory, multi-agent coordination, code execution, and GUI/server applications. The graph also shows the browser-assistant surface and model/tool integration layers. Several modules are unsampled; links to those features are included only where the README or sampled runtime code supports them, and uncertain wiring is omitted.

Main entry points: [`qwen_agent/agent.py`](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/agent.py) (Agent Base), [`qwen_agent/tools/retrieval.py`](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/tools/retrieval.py) (Retrieval Tool), [`qwen_agent/agents/assistant.py`](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/agents/assistant.py) (Assistant), [`qwen_agent/gui/web_ui.py`](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/gui/web_ui.py) (Gradio UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agents["Agent Runtime"]
  node_agent["Agent Base<br/>[agent.py]"]
  node_assistant["Assistant<br/>[assistant.py]"]
  node_router["Agent Router<br/>[router.py]"]
  node_multiagent["Agent Hub<br/>[multi_agent_hub.py]"]
  node_memory["Memory<br/>[memory.py]"]
end

subgraph group_models["Models and Tools"]
  node_llm["Chat Model API<br/>[base.py]"]
  node_providers["Model Providers"]
  node_toolbase["Tool Registry<br/>[base.py]"]
  node_tools["Agent Tools"]
  node_mcp["MCP Client<br/>[mcp_manager.py]"]
end

subgraph group_rag["Document Retrieval"]
  node_retrieval["Retrieval Tool<br/>[retrieval.py]"]
  node_parser["Document Parser<br/>[doc_parser.py]"]
  node_search["RAG Search"]
end

subgraph group_interfaces["User Interfaces"]
  node_gui["Gradio UI<br/>[web_ui.py]"]
  node_browser["Browser Assistant<br/>[popup.js]"]
  node_extension["Browser Background<br/>[background.js]"]
end

subgraph group_server["Server and State"]
  node_serverassistant["Assistant Server"]
  node_dbserver["Database Server<br/>[database_server.py]"]
  node_state[("Workspace State<br/>[memory.py]")]
end

node_user(("User"))
node_modelservice(("Model Service"))
node_mcpservice(("MCP Servers"))
node_documents["Input Documents"]
node_web(("Web Client"))

node_user -->|"submits request"| node_gui
node_gui -->|"invokes"| node_assistant
node_user -->|"submits request"| node_browser
node_browser -->|"dispatches"| node_extension
node_assistant -->|"uses runtime"| node_agent
node_agent -->|"requests generation"| node_llm
node_llm -->|"dispatches"| node_providers
node_providers -.->|"sends prompts"| node_modelservice
node_agent -->|"resolves tools"| node_toolbase
node_toolbase -->|"dispatches calls"| node_tools
node_assistant -.->|"uses for RAG"| node_retrieval
node_retrieval -->|"parses files"| node_parser
node_retrieval -->|"searches records"| node_search
node_documents -->|"supplies files"| node_retrieval
node_router -->|"coordinates agents"| node_multiagent
node_agent -.->|"uses memory"| node_memory
node_gui -.->|"requests service"| node_serverassistant
node_browser -.->|"sends browser tasks"| node_dbserver
node_dbserver -->|"reads and writes"| node_state
node_web -->|"sends requests"| node_serverassistant
node_mcp -.->|"connects to"| node_mcpservice
node_tools -.->|"uses integration"| node_mcp

click node_agent "https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/agent.py"
click node_assistant "https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/agents/assistant.py"
click node_router "https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/agents/router.py"
click node_multiagent "https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/multi_agent_hub.py"
click node_memory "https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/memory/memory.py"
click node_llm "https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/llm/base.py"
click node_providers "https://github.com/aluro7in/qwen-agent/tree/main/qwen_agent/llm"
click node_toolbase "https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/tools/base.py"
click node_tools "https://github.com/aluro7in/qwen-agent/tree/main/qwen_agent/tools"
click node_mcp "https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/tools/mcp_manager.py"
click node_retrieval "https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/tools/retrieval.py"
click node_parser "https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/tools/doc_parser.py"
click node_search "https://github.com/aluro7in/qwen-agent/tree/main/qwen_agent/tools/search_tools"
click node_gui "https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/gui/web_ui.py"
click node_browser "https://github.com/aluro7in/qwen-agent/blob/main/browser_qwen/src/popup.js"
click node_extension "https://github.com/aluro7in/qwen-agent/blob/main/browser_qwen/background.js"
click node_serverassistant "https://github.com/aluro7in/qwen-agent/blob/main/qwen_server/assistant_server.py"
click node_dbserver "https://github.com/aluro7in/qwen-agent/blob/main/qwen_server/database_server.py"
click node_state "https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/memory/memory.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_agent,node_assistant,node_router,node_multiagent,node_memory,node_user,node_web toneBlue
class node_llm,node_providers,node_toolbase,node_tools,node_mcp toneAmber
class node_retrieval,node_parser,node_search,node_mcpservice toneMint
class node_gui,node_browser,node_extension toneRose
class node_serverassistant,node_dbserver,node_state,node_modelservice,node_documents toneIndigo
```

## Components

### Agent Runtime

- [Agent Base](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/agent.py): `qwen_agent/agent.py`
- [Assistant](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/agents/assistant.py): `qwen_agent/agents/assistant.py`
- [Agent Router](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/agents/router.py): `qwen_agent/agents/router.py`
- [Agent Hub](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/multi_agent_hub.py): `qwen_agent/multi_agent_hub.py`
- [Memory](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/memory/memory.py): `qwen_agent/memory/memory.py`

### Models and Tools

- [Chat Model API](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/llm/base.py): `qwen_agent/llm/base.py`
- [Model Providers](https://github.com/aluro7in/qwen-agent/tree/main/qwen_agent/llm): `qwen_agent/llm`
- [Tool Registry](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/tools/base.py): `qwen_agent/tools/base.py`
- [Agent Tools](https://github.com/aluro7in/qwen-agent/tree/main/qwen_agent/tools): `qwen_agent/tools`
- [MCP Client](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/tools/mcp_manager.py): `qwen_agent/tools/mcp_manager.py`

### Document Retrieval

- [Retrieval Tool](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/tools/retrieval.py): `qwen_agent/tools/retrieval.py`
- [Document Parser](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/tools/doc_parser.py): `qwen_agent/tools/doc_parser.py`
- [RAG Search](https://github.com/aluro7in/qwen-agent/tree/main/qwen_agent/tools/search_tools): `qwen_agent/tools/search_tools`

### User Interfaces

- [Gradio UI](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/gui/web_ui.py): `qwen_agent/gui/web_ui.py`
- [Browser Assistant](https://github.com/aluro7in/qwen-agent/blob/main/browser_qwen/src/popup.js): `browser_qwen/src/popup.js`
- [Browser Background](https://github.com/aluro7in/qwen-agent/blob/main/browser_qwen/background.js): `browser_qwen/background.js`

### Server and State

- [Assistant Server](https://github.com/aluro7in/qwen-agent/blob/main/qwen_server/assistant_server.py): `qwen_server/assistant_server.py`
- [Database Server](https://github.com/aluro7in/qwen-agent/blob/main/qwen_server/database_server.py): `qwen_server/database_server.py`
- [Workspace State](https://github.com/aluro7in/qwen-agent/blob/main/qwen_agent/memory/memory.py): `qwen_agent/memory/memory.py`

### Other components

- **User**
- **Model Service**
- **MCP Servers**
- **Input Documents**
- **Web Client**

## Connections

- User → Gradio UI: submits request
- Gradio UI → Assistant: invokes
- User → Browser Assistant: submits request
- Browser Assistant → Browser Background: dispatches
- Assistant → Agent Base: uses runtime
- Agent Base → Chat Model API: requests generation
- Chat Model API → Model Providers: dispatches
- Model Providers → Model Service: sends prompts
- Agent Base → Tool Registry: resolves tools
- Tool Registry → Agent Tools: dispatches calls
- Assistant → Retrieval Tool: uses for RAG
- Retrieval Tool → Document Parser: parses files
- Retrieval Tool → RAG Search: searches records
- Input Documents → Retrieval Tool: supplies files
- Agent Router → Agent Hub: coordinates agents
- Agent Base → Memory: uses memory
- Gradio UI → Assistant Server: requests service
- Browser Assistant → Database Server: sends browser tasks
- Database Server → Workspace State: reads and writes
- Web Client → Assistant Server: sends requests
- MCP Client → MCP Servers: connects to
- Agent Tools → MCP Client: uses integration
