{"id":4389,"library":"qwen-agent","title":"Qwen-Agent Library","description":"Qwen-Agent is a Python library designed to enhance Large Language Models (LLMs) with advanced capabilities such as Agent Workflows, Retrieval-Augmented Generation (RAG), Function Calling, and Code Interpreters. It's actively developed, with version 0.0.34 released recently, maintaining a rapid release cadence with frequent minor updates.","status":"active","version":"0.0.34","language":"en","source_language":"en","source_url":"https://github.com/QwenLM/Qwen-Agent","tags":["LLM","agent","Qwen","RAG","function calling","code interpreter","multi-modal"],"install":[{"cmd":"pip install qwen-agent","lang":"bash","label":"Basic Install"},{"cmd":"pip install qwen-agent[gui]","lang":"bash","label":"Install with GUI support"}],"dependencies":[{"reason":"Required for using Qwen models via the DashScope API.","package":"dashscope","optional":false},{"reason":"Required for using OpenAI models.","package":"openai","optional":false},{"reason":"Optional dependency for GUI features, installed with `qwen-agent[gui]`.","package":"gradio","optional":true}],"imports":[{"symbol":"AssistantAgent","correct":"from qwen_agent.agents import AssistantAgent"},{"symbol":"CodeInterpreter","correct":"from qwen_agent.tools.tool_code_interpreter import CodeInterpreter"},{"note":"RAG tool path might vary slightly based on specific RAG components needed, but this is common.","symbol":"RAG","correct":"from qwen_agent.tools.tool_rag import RAG"}],"quickstart":{"code":"import os\nfrom qwen_agent.agents import AssistantAgent\nfrom qwen_agent.tools.tool_code_interpreter import CodeInterpreter\n\n# Configure your LLM access\n# Ensure DASHSCOPE_API_KEY or OPENAI_API_KEY is set in your environment variables.\nllm_config = {\n    'model': 'qwen-turbo',\n    'model_server': 'dashscope', # or 'openai', 'ollama', etc.\n    'api_key': os.environ.get('DASHSCOPE_API_KEY', os.environ.get('OPENAI_API_KEY', ''))\n}\n\nif not llm_config['api_key']:\n    raise ValueError(\"Please set DASHSCOPE_API_KEY or OPENAI_API_KEY environment variable.\")\n\n# Initialize the agent with tools\nagent = AssistantAgent(\n    llm=llm_config,\n    tools=[CodeInterpreter()]\n)\n\n# Run the agent with a prompt\nresponse = agent.run(\"Please write a python code snippet to calculate the sum of 123 and 456.\")\nprint(response)\n","lang":"python","description":"This quickstart demonstrates how to initialize an `AssistantAgent` with a Code Interpreter tool and use it to execute a simple task. It requires an API key for DashScope (for Qwen models) or OpenAI, which should be set as an environment variable."},"warnings":[{"fix":"Ensure `DASHSCOPE_API_KEY` or `OPENAI_API_KEY` is set in your environment or explicitly passed in the `llm_config` dictionary. Double-check `model_server` matches your `model` and API key.","message":"API Key Configuration: Users often forget to set the correct environment variables (e.g., `DASHSCOPE_API_KEY` or `OPENAI_API_KEY`) or pass them incorrectly to the LLM configuration, leading to authentication errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If using MCP-dependent features, refer to the official documentation for specific installation and configuration instructions, as it may not be part of the base `qwen-agent` install.","message":"Multi-Modal Compute Platform (MCP) is an optional dependency. Features relying on MCP (e.g., certain multi-modal capabilities) may not work without a specific setup or additional installation steps.","severity":"gotcha","affected_versions":">=0.0.17"},{"fix":"For complex or lengthy tasks, consider adjusting these limits by setting the `QWEN_AGENT_MAX_LLM_CALL_PER_RUN` and `QWEN_AGENT_DEFAULT_MAX_INPUT_TOKENS` environment variables before running the agent.","message":"Default LLM call and token limits can lead to unexpected truncations or early termination of agent runs. Defaults are `QWEN_AGENT_MAX_LLM_CALL_PER_RUN=20` and `QWEN_AGENT_DEFAULT_MAX_INPUT_TOKENS=58k`.","severity":"gotcha","affected_versions":">=0.0.20"},{"fix":"Install `qwen-agent[gui]` to ensure the correct `gradio` version is used. If problems persist, check the library's `pyproject.toml` or `setup.py` for the exact `gradio` version pinned and adjust your environment accordingly.","message":"The `gradio` dependency for GUI features has seen version modifications. If you encounter issues with the GUI, it might be due to `gradio` version incompatibility.","severity":"gotcha","affected_versions":">=0.0.18"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}