A general-purpose LLM-based intelligent agent for software engineering, supporting the execution of complex development tasks with natural language instructions.
NOASSERTIONTypeScript 4.3krefly-airefly Last Updated: 2025-07-10
Trae Agent Project Details
Project Overview
Trae Agent is an open-source intelligent agent developed by ByteDance, based on Large Language Models (LLMs), and designed for general software engineering tasks. The project provides a powerful command-line interface capable of understanding natural language instructions and executing complex software engineering workflows.
GitHub Repository: https://github.com/bytedance/trae-agent
Core Features
🌊 Lakeview
- Provides concise summaries for agent steps
- Helps users quickly understand the agent's execution process
🤖 Multi-LLM Support
- Supports official OpenAI API
- Supports official Anthropic API
- Flexible model selection mechanism
🛠️ Rich Tool Ecosystem
- File editing capabilities
- Bash command execution
- Sequential Thinking
- More extensible tools
🎯 Interactive Mode
- Conversational interface supporting iterative development
- Real-time interaction to enhance the development experience
📊 Trajectory Logging
- Detailed recording of all agent operations
- Supports debugging and analysis
- Automatically generates execution reports
⚙️ Flexible Configuration
- JSON-based configuration system
- Supports environment variable configuration
- Multi-level configuration priority
🚀 Easy Installation
- Simple pip-based installation process
- Recommended to use UV for project setup
Installation Guide
Recommended Installation Method (using UV)
git clone https://github.com/bytedance/trae-agent.git
cd trae-agent
uv sync
Environment Variable Configuration
# OpenAI API Key
export OPENAI_API_KEY="your-openai-api-key"
# Anthropic API Key
export ANTHROPIC_API_KEY="your-anthropic-api-key"
Usage
Basic Task Execution
# Simple task
trae-cli run "Create a hello world Python script"
# Specify provider and model
trae-cli run "Fix the bug in main.py" --provider anthropic --model claude-sonnet-4-20250514
# Specify working directory
trae-cli run "Add unit tests for the utils module" --working-dir /path/to/project
# Save trajectory file for debugging
trae-cli run "Refactor the database module" --trajectory-file debug_session.json
# Force patch generation
trae-cli run "Update the API endpoints" --must-patch
Interactive Mode
# Start an interactive session
trae-cli interactive
# Use custom configuration
trae-cli interactive --provider openai --model gpt-4o --max-steps 30
Interactive Mode Commands
- Enter task description to execute a task
status
- View agent informationhelp
- Display available commandsclear
- Clear screenexit
orquit
- End session
Configuration Management
# Display current configuration
trae-cli show-config
# Use custom configuration file
trae-cli show-config --config-file my_config.json
Configuration File
Trae Agent uses a JSON configuration file (trae_config.json
) for settings:
{
"default_provider": "anthropic",
"max_steps": 20,
"model_providers": {
"openai": {
"api_key": "your_openai_api_key",
"model": "gpt-4o",
"max_tokens": 128000,
"temperature": 0.5,
"top_p": 1
},
"anthropic": {
"api_key": "your_anthropic_api_key",
"model": "claude-sonnet-4-20250514",
"max_tokens": 4096,
"temperature": 0.5,
"top_p": 1,
"top_k": 0
}
}
}
Configuration Priority
- Command-line arguments (highest priority)
- Configuration file values
- Environment variables
- Default values (lowest priority)
Built-in Tools
str_replace_based_edit_tool - File Operation Tool
view
- Display file content or directory listingcreate
- Create a new filestr_replace
- Replace text within a fileinsert
- Insert text at a specified line
bash - Shell Command Execution
- Execute commands and scripts
- Handle persistent state
- Manage long-running processes
- Capture output and errors
sequential_thinking - Structured Problem Solving
- Decompose complex problems
- Iterative thinking and refinement capabilities
- Hypothesis generation and validation
task_done - Task Completion Signal
- Mark task as successfully completed
- Provide final results and summary
Trajectory Logging
Trae Agent automatically records detailed execution trajectories for debugging and analysis:
# Automatically generate trajectory file
trae-cli run "Debug the authentication module"
# Saved to: trajectory_20250612_220546.json
# Custom trajectory file
trae-cli run "Optimize the database queries" --trajectory-file optimization_debug.json
Trajectory File Content
- LLM Interactions: All messages, responses, and tool calls
- Agent Steps: State transitions and decision points
- Tool Usage: Tools invoked and their results
- Metadata: Timestamps, token usage, and execution metrics
Contribution Guide
Contribution Workflow
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Add tests for new features
- Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Submit a Pull Request
Development Guidelines
- Follow PEP 8 style guide
- Add tests for new features
- Update documentation as needed
- Use type hints appropriately
- Ensure all tests pass before committing
System Requirements
- Python 3.12+
- OpenAI API key (for OpenAI models)
- Anthropic API key (for Anthropic models)
Troubleshooting
Import Errors
# Try setting PYTHONPATH
PYTHONPATH=. trae-cli run "your task"
API Key Issues
# Verify if API keys are set
echo $OPENAI_API_KEY
echo $ANTHROPIC_API_KEY
# Check configuration
trae show-config
Permission Errors
# Ensure appropriate permissions for file operations
chmod +x /path/to/your/project