Skip to main content

LLM-based agent for general purpose tasks

Project description

Pywen

Python 3.9+ Python 3.12- License: MIT Alpha

ไธญๆ–‡็‰ˆ | English

Pywen Logo

Pywen is a Python CLI tool based on Qwen3-Coder, designed specifically for intelligent software engineering tasks. It provides a conversational interface that can understand natural language instructions and execute complex development workflows through an advanced agent system.

๐Ÿงฌ Recent Updates

  • 2025.08.26 Updated the /agent module by adding the Claude Code agent, with execution logic aligned to Claude Code, and introducing dedicated tools such as the task tool and todowrite tool. You can switch to the Claude Code agent using /agent claude.
  • 2025.08.08: Updated the /agent switch agent module, added DeepResearch agent, with execution logic aligned with Google's open-source DeepResearch LangGraph version. You can use /agent research to switch GeminiResearchDemo agent.Before you use it, please make sure you have the serper api key.
  • 2025.08.06: Released the first version of Pywen, with execution logic aligned with Gemini CLI/Qwen Code

๐ŸŽฏ Project Background

Pywen is built on the Qwen3-Coder large language model, aiming to provide developers with an efficient and intelligent code assistant. The project is primarily adapted from Qwen-Code, with deep optimizations for Python developers and the Qwen3-Coder model.

Why Choose Qwen3-Coder?

  • ๐Ÿš€ Code Specialization: Qwen3-Coder excels in code generation, understanding, and debugging
  • โšก Efficient Inference: Optimized model architecture providing fast responses
  • ๐Ÿ”ง Engineering Practicality: Specifically trained for real-world software development scenarios

Project Status: The project is still under active development. We welcome your help in improving Pywen.

Differences from Other Code Agent CLIs

Pywen is a Python-based CLI tool with excellent Python ecosystem compatibility and developer-friendliness. It provides a transparent, modular architecture that allows researchers and developers to easily modify, extend, and analyze, making it an ideal platform for researching AI Agent architectures, conducting ablation studies, and developing new Agent capabilities. This research-friendly design enables academia and the open-source community to more easily contribute to foundational Agent frameworks and build innovative applications, facilitating continuous breakthroughs in the rapidly evolving AI Agent field.

โœจ Features

  • ๐Ÿค– Qwen3-Coder-Plus Powered: Based on Alibaba Cloud's latest code-specialized large model
  • ๐Ÿ“ฆ Modular: Built on modular architecture, extensible and customizable (future support for multi-agent frameworks)
  • ๐Ÿ› ๏ธ Rich Tool Ecosystem: File editing, bash execution, sequential thinking, and more
  • ๐Ÿ“Š Trajectory Recording: Detailed logging of all Agent operations for debugging and analysis
  • โš™๏ธ Smart Configuration: Automatic guided configuration on first run, supports environment variables
  • ๐Ÿ“ˆ Session Statistics: Real-time tracking of API calls, tool usage, and token consumption

๐Ÿš€ Quick Start

Installation

pip install pywen
Build from source with uv (recommended)
git clone https://github.com/PAMPAS-Lab/Pywen.git
cd Pywen
uv venv
uv sync --all-extras

# linux/macos
source .venv/bin/activate

# windows
.venv\Scripts\activate

First Use

Simply run the pywen command to start:

pywen

If it's your first run and there's no configuration file, Pywen will automatically start the configuration wizard:

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—   โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•—    โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ•—   โ–ˆโ–ˆโ•‘
โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ•šโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘    โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•‘
โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ•‘ โ–ˆโ•— โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•”โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘
โ–ˆโ–ˆโ•”โ•โ•โ•โ•   โ•šโ–ˆโ–ˆโ•”โ•  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•  โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘
โ–ˆโ–ˆโ•‘        โ–ˆโ–ˆโ•‘   โ•šโ–ˆโ–ˆโ–ˆโ•”โ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘ โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ•‘
โ•šโ•โ•        โ•šโ•โ•    โ•šโ•โ•โ•โ•šโ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•โ•โ•šโ•โ•  โ•šโ•โ•โ•โ•

Configuration file not found, starting setup wizard...

API Key: [Enter your Qwen API key]
Base URL: https://dashscope.aliyuncs.com/compatible-mode/v1
Model: qwen3-coder-plus
...

โœ… Configuration saved to pywen_config.json

After configuration is complete, you can start using Pywen!

Basic Usage

Once you enter the Pywen command-line interface, you can:

# File operations
> Create a Python script to calculate Fibonacci sequence
> Refactor functions in main.py to make them more efficient

# Code analysis and debugging
> Fix bugs in this project and add unit tests
> Analyze performance bottlenecks in my code

# Project management
> Create a new Flask web application with proper structure
> Add comprehensive documentation to this codebase

๐Ÿ“– User Guide

Command Line Interface

Available Commands

# System commands
/about       show version info
/auth        change the auth method
/clear       clear the screen and conversation history
/help        for help on pywen code
/memory      Commands for interacting with memory.show
  Show       the current memory contents.add
  Add        content to the memory.refresh
  Refresh    the memory from the source.
/stats       check session stats. Usage:/stats         
/tools       list available Pywen tools 
/bug         submit a bug report
/quit        exit the cli
!            shell command                                  

# Special commands
!<command>    - Execute shell command

# Keyboard shortcuts
Ctrl+Y        - Toggle YOLO mode (auto-approve all operations - use with caution!)

# Direct input of task descriptions to execute agent

YOLO Mode

Use with caution:

  • Press Ctrl+Y to toggle YOLO mode
  • Default behavior: All tool calls require user confirmation for safety
  • In YOLO mode, all tool calls are automatically approved without user confirmation
  • This speeds up execution but removes safety checks
  • Mode status is displayed in the interface
  • You can also type 'a' (always) when prompted for tool confirmation to enable YOLO mode

Configuration Management

Pywen uses the pywen_config.json file for configuration:

{
  "default_provider": "qwen",
  "max_steps": 20,
  "enable_lakeview": false,
  "model_providers": {
    "qwen": {
      "api_key": "your-qwen-api-key",
      "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
      "model": "qwen3-coder-plus",
      "max_tokens": 4096,
      "temperature": 0.5
    }
  }
}

Configuration Priority:

  1. Command line arguments (highest)
  2. Configuration file values
  3. Environment variables
  4. Default values (lowest)

Environment Variables

You can set API keys through environment variables:

# Qwen (required)
export QWEN_API_KEY="your-qwen-api-key"

# Tool API Keys (optional but recommended)
export SERPER_API_KEY="your-serper-api-key"  # For web search
export JINA_API_KEY="your-jina-api-key"      # For content reading

# Other supported providers
export OPENAI_API_KEY="your-openai-api-key"
export ANTHROPIC_API_KEY="your-anthropic-api-key"

Getting API Keys

Serper API (Web Search):

  1. Visit serper.dev
  2. Sign up for a free account
  3. Get your API key from the dashboard

Jina API (Content Reading):

  1. Visit jina.ai
  2. Sign up for a free account
  3. Get your API key from the dashboard

๐Ÿ› ๏ธ Available Tools

Pywen provides a comprehensive toolkit for software development:

  • File Operations: Create, edit, read, and manage files
  • Bash Execution: Run shell commands and scripts
  • Sequential Thinking: Structured problem-solving approach
  • Task Completion: Mark tasks as complete with summaries
  • JSON Operations: Parse and manipulate JSON data

For detailed information about all available tools and their capabilities, see docs/tools.md.

๐Ÿ”Œ MCP (Model Context Protocol) Integration

Pywen also supports MCP (Model Context Protocol) to connect external tools and services such as playwright.

Enabling MCP

  1. Open your configuration file:
    ~/.pywen/pywen_config.json
    
  2. Locate the mcp section and enable it:
    "mcp": {
        "enabled": true,
            "isolated": true,
            "servers": [
            {
                "name": "playwright",
                "command": "npx",
                "args": [
                    "@playwright/mcp@latest"
                ],
                "enabled": true,
                "include": [
                    "browser_*"
                ],
                "save_images_dir": "./outputs/playwright",
                "isolated": true 
            }
            ]
    }
    

Node.js

Ensure that you have Node.js installed. You can verify it with the following command:

node -v

If you donโ€™t have it installed, please follow the Node.js installation guide.

Browser Dependency

If your device does not have a browser installed, install browser for Playwright with:

npx playwright install --with-deps

After enabling MCP and installing the required browser, Pywen will be able to call the playwright MCP server for tasks like browser automation, screenshot capture, and web interaction.

๐Ÿ“Š Trajectory Recording

Pywen automatically records detailed execution trajectories for debugging and analysis:

# Trajectory files are automatically saved to trajectories/ directory
trajectories/trajectory_xxxxxx.json

Trajectory files contain:

  • LLM Interactions: All messages, responses, and tool calls
  • Agent Steps: State transitions and decision points
  • Tool Usage: Which tools were called and their results
  • Metadata: Timestamps, token usage, and execution metrics

๐Ÿ“ˆ Session Statistics

Monitor your usage with real-time statistics:

> /stats

Tracks:

  • API calls and token consumption
  • Tool usage patterns
  • Session duration
  • Model performance metrics

๐Ÿค Contributing

We welcome contributions to Pywen! Here's how to get started:

  1. Fork the repository
  2. Set up the development environment:
    git clone https://github.com/your-username/Pywen.git
    cd Pywen
    uv venv
    uv sync --all-extras
    
    # linux/macos
    source .venv/bin/activate
    
    # windows
    .venv\Scripts\activate
    
  3. Create a feature branch
  4. Make your changes and add tests
  5. Submit a pull request

Development Guidelines

  • Follow PEP 8 style guidelines
  • Add tests for new features
  • Update documentation as needed
  • Use type hints appropriately
  • Ensure all tests pass before submitting

๐Ÿ“‹ Requirements

  • Python 3.9+,<3.13
  • Qwen API key (recommended) or other supported LLM provider API keys
  • Internet connection for API access

๐Ÿ”ง Troubleshooting

Common Issues

Configuration Issues:

# Re-run configuration wizard
rm pywen_config.json
pywen

API Key Issues:

# Verify your API key is set
echo $QWEN_API_KEY

# Check configuration in Pywen
> /config

๐Ÿ™ Acknowledgments

We thank:

  • Google for the Gemini CLI project, which provided agent execution logic and rich tool ecosystem libraries for this project
  • Alibaba Cloud Qwen Team for providing the powerful Qwen3-Coder model and Qwen-Code reference implementation
  • ByteDance for the trae-agent project, which provided valuable foundational architecture for this project
  • Yuyz0112 for the claude-code-reverse project, and shareAI-lab for the Kode project, both of which provided inspiration for the Claude code agent development in this project

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Pywen - Making the power of Qwen3-Coder accessible for intelligent software development! ๐Ÿš€

PAMPAS-Lab - Dedicated to breakthroughs in large model agent frameworks, bridging AI research and applications! ๐Ÿš€


๐ŸŒŸStar History

Star History Chart

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywen-1.2.2.1.tar.gz (360.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pywen-1.2.2.1-py3-none-any.whl (206.5 kB view details)

Uploaded Python 3

File details

Details for the file pywen-1.2.2.1.tar.gz.

File metadata

  • Download URL: pywen-1.2.2.1.tar.gz
  • Upload date:
  • Size: 360.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for pywen-1.2.2.1.tar.gz
Algorithm Hash digest
SHA256 a394207405634b0a76fef2b91e4fa314416562a562f1d7f406267cb78fa4893d
MD5 074ca98636fbc7313da7f2154b71019c
BLAKE2b-256 795b84754832aa3aa7554999715bd09e483b66ec5b47ab70cb4e3db5340f304d

See more details on using hashes here.

File details

Details for the file pywen-1.2.2.1-py3-none-any.whl.

File metadata

  • Download URL: pywen-1.2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 206.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for pywen-1.2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b54d3fa59010928068bacedea0aaf0af6aa350a94138d837e38c5d3051b4ce3
MD5 148fca807221fe9a84e339ea88d30e1e
BLAKE2b-256 30646e40df91be86f0593fe2bdc290a8bcb17c59ca493f8f874abe209f8b2aa5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page