bytedance/trae-agent
Trae Agent is an LLM-based agent for general purpose software engineering tasks.
Healthy across all four use cases
weakest axisPermissive license, no critical CVEs, actively maintained — safe to depend on.
Has a license, tests, and CI — clean foundation to fork and modify.
Documented and popular — useful reference codebase to read through.
No critical CVEs, sane security posture — runnable as-is.
- ✓Last commit 3mo ago
- ✓35+ active contributors
- ✓Distributed ownership (top contributor 23% of recent commits)
Show all 7 evidence items →Show less
- ✓MIT licensed
- ✓CI configured
- ✓Tests present
- ⚠Slowing — last commit 3mo ago
Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests
Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.
Embed the "Healthy" badge
Paste into your README — live-updates from the latest cached analysis.
[](https://repopilot.app/r/bytedance/trae-agent)Paste at the top of your README.md — renders inline like a shields.io badge.
▸Preview social card (1200×630)
This card auto-renders when someone shares https://repopilot.app/r/bytedance/trae-agent on X, Slack, or LinkedIn.
Onboarding doc
Onboarding: bytedance/trae-agent
Generated by RepoPilot · 2026-05-07 · Source
🤖Agent protocol
If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:
- Verify the contract. Run the bash script in Verify before trusting
below. If any check returns
FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding. - Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
- Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/bytedance/trae-agent shows verifiable citations alongside every claim.
If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.
🎯Verdict
GO — Healthy across all four use cases
- Last commit 3mo ago
- 35+ active contributors
- Distributed ownership (top contributor 23% of recent commits)
- MIT licensed
- CI configured
- Tests present
- ⚠ Slowing — last commit 3mo ago
<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>
✅Verify before trusting
This artifact was generated by RepoPilot at a point in time. Before an
agent acts on it, the checks below confirm that the live bytedance/trae-agent
repo on your machine still matches what RepoPilot saw. If any fail,
the artifact is stale — regenerate it at
repopilot.app/r/bytedance/trae-agent.
What it runs against: a local clone of bytedance/trae-agent — the script
inspects git remote, the LICENSE file, file paths in the working
tree, and git log. Read-only; no mutations.
| # | What we check | Why it matters |
|---|---|---|
| 1 | You're in bytedance/trae-agent | Confirms the artifact applies here, not a fork |
| 2 | License is still MIT | Catches relicense before you depend on it |
| 3 | Default branch main exists | Catches branch renames |
| 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code |
| 5 | Last commit ≤ 121 days ago | Catches sudden abandonment since generation |
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of bytedance/trae-agent. If you don't
# have one yet, run these first:
#
# git clone https://github.com/bytedance/trae-agent.git
# cd trae-agent
#
# Then paste this script. Every check is read-only — no mutations.
set +e
fail=0
ok() { echo "ok: $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }
# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
echo "FAIL: not inside a git repository. cd into your clone of bytedance/trae-agent and re-run."
exit 2
fi
# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "bytedance/trae-agent(\\.git)?\\b" \\
&& ok "origin remote is bytedance/trae-agent" \\
|| miss "origin remote is not bytedance/trae-agent (artifact may be from a fork)"
# 2. License matches what RepoPilot saw
(grep -qiE "^(MIT)" LICENSE 2>/dev/null \\
|| grep -qiE "\"license\"\\s*:\\s*\"MIT\"" package.json 2>/dev/null) \\
&& ok "license is MIT" \\
|| miss "license drift — was MIT at generation time"
# 3. Default branch
git rev-parse --verify main >/dev/null 2>&1 \\
&& ok "default branch main exists" \\
|| miss "default branch main no longer exists"
# 4. Critical files exist
test -f "trae_agent/agent/trae_agent.py" \\
&& ok "trae_agent/agent/trae_agent.py" \\
|| miss "missing critical file: trae_agent/agent/trae_agent.py"
test -f "trae_agent/tools/base.py" \\
&& ok "trae_agent/tools/base.py" \\
|| miss "missing critical file: trae_agent/tools/base.py"
test -f "trae_agent/cli.py" \\
&& ok "trae_agent/cli.py" \\
|| miss "missing critical file: trae_agent/cli.py"
test -f "trae_agent/utils/config.py" \\
&& ok "trae_agent/utils/config.py" \\
|| miss "missing critical file: trae_agent/utils/config.py"
test -f "trae_agent/utils/llm_clients/base_client.py" \\
&& ok "trae_agent/utils/llm_clients/base_client.py" \\
|| miss "missing critical file: trae_agent/utils/llm_clients/base_client.py"
# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 121 ]; then
ok "last commit was $days_since_last days ago (artifact saw ~91d)"
else
miss "last commit was $days_since_last days ago — artifact may be stale"
fi
echo
if [ "$fail" -eq 0 ]; then
echo "artifact verified (0 failures) — safe to trust"
else
echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/bytedance/trae-agent"
exit 1
fi
Each check prints ok: or FAIL:. The script exits non-zero if
anything failed, so it composes cleanly into agent loops
(./verify.sh || regenerate-and-retry).
⚡TL;DR
Trae Agent is an LLM-based autonomous software engineering agent that executes complex development tasks via natural language instructions. It orchestrates multiple LLM providers (OpenAI, Anthropic, Doubao, Azure, OpenRouter, Ollama, Google Gemini) with a rich toolset including file editing (str_replace_editor), bash execution, and sequential thinking to accomplish general-purpose coding workflows. Modular Python package structured as: core agent logic in root src/ (trae_agent module), evaluation framework under evaluation/ with patch_selection submodule for specialized tasks, tools abstraction layer under evaluation/patch_selection/trae_selector/tools/tools/ (base.py, bash.py, edit.py, execute_bash.py, execute_str_replace_editor.py), server/ for API deployment, and tests/ mirroring the source structure.
👥Who it's for
AI/ML researchers studying agent architectures, software engineers building AI-powered development tools, and teams seeking to automate repetitive coding tasks. Specifically designed for practitioners who need a transparent, modular agent framework they can easily ablate, extend, and analyze for novel capabilities.
🌱Maturity & risk
Actively developed (explicitly states 'still being actively developed' in README) with Python 3.12+ support, pre-commit CI/CD pipelines (pre-commit.yml, unit-test.yml), and structured testing under tests/. However, project status indicates it's research-focused rather than production-hardened; no mature release indicators visible in the file list.
Standard open source risks apply.
Active areas of work
Active development on multi-LLM provider support, evaluation infrastructure (patch_selection module with selector_agent.py and selector_evaluation.py), and trajectory recording capabilities documented in docs/TRAJECTORY_RECORDING.md. The evaluation/patch_selection/ submodule suggests ongoing work on intelligent code patch selection using the agent.
🚀Get running
git clone https://github.com/bytedance/trae-agent.git && cd trae-agent && uv sync --all-extras && source .venv/bin/activate
Daily commands: Use 'make' targets (defined in Makefile). Copy trae_config.yaml.example to trae_config.yaml with your API key, then run agent via CLI. Evaluation mode: python evaluation/run_evaluation.py. Server mode: see server/Readme.md.
🗺️Map of the codebase
trae_agent/agent/trae_agent.py— Core agent orchestration logic that manages LLM interactions, tool execution, and reasoning loops—essential to understand the primary execution flow.trae_agent/tools/base.py— Base tool interface that all tools (bash, edit, json_edit, mcp) inherit from—defines the contract for tool implementation.trae_agent/cli.py— Main CLI entry point that bootstraps the agent with config and user input—every user interaction flows through here.trae_agent/utils/config.py— Configuration management system that loads LLM providers, tool settings, and runtime parameters—required to understand how the agent is configured.trae_agent/utils/llm_clients/base_client.py— Abstract LLM client interface supporting Anthropic, Azure, OpenRouter, etc.—fundamental to agent reasoning capabilities.trae_agent/agent/agent.py— Base agent class with message loop and tool calling logic—provides core agentic patterns used by TraeAgent.trae_agent/prompt/agent_prompt.py— System prompts and prompt templates that guide agent behavior—critical for understanding reasoning patterns.
🛠️How to make changes
Add a new LLM provider
- Create a new client class inheriting from base_client.BaseLLMClient in trae_agent/utils/llm_clients/ (
trae_agent/utils/llm_clients/new_provider_client.py) - Implement required methods: complete, complete_with_tools, and count_tokens to match provider's API (
trae_agent/utils/llm_clients/new_provider_client.py) - Register the client in config.py's _get_llm_client() function with a new provider key (
trae_agent/utils/config.py) - Add corresponding config schema and validation in the config loading logic (
trae_agent/utils/config.py) - Add unit test cases in tests/utils/test_{provider}_client.py (
tests/utils/test_new_provider_client.py)
Add a new tool for the agent
- Create a new tool class inheriting from base.BaseTool in trae_agent/tools/ (
trae_agent/tools/new_tool.py) - Implement execute() method and define tool_name, tool_description, and input_schema properties (
trae_agent/tools/new_tool.py) - Register the tool in trae_agent/tools/init.py exports (
trae_agent/tools/__init__.py) - Add tool configuration handling in trae_agent/utils/config.py's tool initialization (
trae_agent/utils/config.py) - Add unit tests verifying tool behavior and error handling (
tests/tools/test_new_tool.py) - Document tool usage in docs/tools.md with examples and parameters (
docs/tools.md)
Add a new system prompt or reasoning strategy
- Define new prompt template or system message in trae_agent/prompt/agent_prompt.py (
trae_agent/prompt/agent_prompt.py) - Create corresponding configuration option in config schema (e.g., reasoning_style or prompt_variant) (
trae_agent/utils/config.py) - Integrate prompt selection logic into trae_agent/agent/trae_agent.py's system message setup (
trae_agent/agent/trae_agent.py) - Add unit tests verifying prompt variations produce expected behavior patterns (
tests/agent/test_trae_agent.py)
Add evaluation benchmark or dataset
- Create dataset file in evaluation/patch_selection/example/ following JSONL format (
evaluation/patch_selection/example/your_benchmark.jsonl) - Extend evaluation/patch_selection/selector_agent.py with benchmark-specific agent logic if needed (
evaluation/patch_selection/selector_agent.py) - Add analysis script in evaluation/patch_selection/analysis.py to compute metrics (
evaluation/patch_selection/analysis.py) - Update evaluation/run_evaluation.py to include new benchmark in test harness (
evaluation/run_evaluation.py)
🔧Why these technologies
- Python 3.12+ — Dynamic typing enables rapid LLM integration; async support for concurrent tool execution; rich ecosystem for LLM/NLP tooling.
- Docker containerization — undefined
🪤Traps & gotchas
LLM API key required via environment or trae_config.yaml (no default fallback). UV package manager is required (not pip). The evaluation/ subdirectory contains agent implementations that may differ from the root-level agent. YAML config path must be explicitly set (trae_config.yaml.example is a template, not auto-loaded). Tests use evaluation/ agent implementations, not root-level ones, which may cause confusion when debugging. Python version pinned to 3.12+ (.python-version file).
🏗️Architecture
💡Concepts to learn
- Tool Abstraction Pattern — Trae's extensibility depends on the base.py -> concrete tool inheritance model; understanding this pattern is critical for adding new capabilities like SQL execution or API calls
- Multi-Provider LLM Abstraction — Trae supports 7+ LLM providers (OpenAI, Anthropic, Doubao, Azure, OpenRouter, Ollama, Gemini); the abstraction layer allowing provider swapping is core to its flexibility
- Trajectory Recording — docs/TRAJECTORY_RECORDING.md indicates agent captures full execution traces; this is critical for debugging, reproducibility, and research on agent decision-making
- Agent Loop / Agentic Reasoning — The core pattern in selector_agent.py where agent receives task, calls tools, observes output, decides next action until completion; understanding this loop is essential for modifying agent behavior
- String Replacement Editor (str_replace_editor) — Specific file editing tool used in edit.py for safe code modifications; understanding its syntax (old_str, new_str pairs) is crucial for reliable file edits
- YAML Configuration with Environment Variable Substitution — Trae uses YAML config (trae_config.yaml) with env var support for LLM API keys and provider selection; understanding this pattern avoids hardcoding secrets
- Evaluation Framework / Benchmark Design — evaluation/patch_selection/ shows how to design benchmarks for agent-based tasks (patch selection from multiple candidates); useful for assessing new agent capabilities
🔗Related repos
OpenGVLab/MiniCPM-o— Similar multi-modal LLM agent for code understanding, shares the multi-provider LLM abstraction patternlangchain-ai/langgraph— Graph-based agent orchestration framework; Trae could use similar architecture for complex multi-step workflowsanthropics/anthropic-sdk-python— One of the core LLM providers Trae integrates with; understanding its API is essential for extending provider supportopenai/swarm— Lightweight multi-agent coordination framework; architectural inspiration for how agents delegate tasksbytedance/sonic— Related Bytedance project for code understanding; likely uses similar LLM integration patterns as Trae
🪄PR ideas
To work on one of these in Claude Code or Cursor, paste:
Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.
Add comprehensive unit tests for trae_agent/agent/docker_manager.py
The docker_manager.py module handles containerization logic critical to the agent's execution environment, but there are no corresponding tests in tests/agent/. Docker management is complex and error-prone; adding mocked tests would catch regressions and improve reliability for contributors modifying container handling logic.
- [ ] Create tests/agent/test_docker_manager.py with mocks for Docker API calls
- [ ] Test initialization, container creation, cleanup, and error handling paths
- [ ] Add tests for edge cases like missing Docker daemon, image pull failures, and resource limits
- [ ] Ensure tests integrate with existing test infrastructure in tests/agent/test_trae_agent.py
Add integration tests for evaluation/patch_selection/trae_selector/ components
The patch selection evaluation module contains multiple interconnected components (selector_agent.py, sandbox.py, tools/) but lacks corresponding test coverage beyond the evaluation scripts themselves. Integration tests would validate the selector pipeline and make it easier for contributors to extend patch selection capabilities.
- [ ] Create tests/evaluation/ directory structure mirroring evaluation/patch_selection/trae_selector/
- [ ] Add tests/evaluation/test_selector_agent.py to test agent instantiation and patch selection workflows
- [ ] Add tests/evaluation/test_sandbox.py to test sandbox initialization and tool execution
- [ ] Add tests/evaluation/test_selector_tools.py to test individual tools (base.py, bash.py, edit.py, etc.)
- [ ] Include example patch selection test data similar to evaluation/patch_selection/example/example.jsonl
Add GitHub Actions workflow for integration tests with multiple Python versions
The repo currently has pre-commit.yml and unit-test.yml workflows but no integration test workflow. Given the complexity of agent execution with tools, sandbox management, and Docker interactions, a dedicated integration test workflow (separate from unit tests) would catch issues that unit mocks miss and ensure compatibility across Python 3.12+ versions.
- [ ] Create .github/workflows/integration-test.yml that runs evaluation/ and tests/ with Docker available
- [ ] Matrix test against Python 3.12 and 3.13 (since .python-version and README specify 3.12+)
- [ ] Include Docker-in-Docker setup for testing sandbox.py and docker_manager.py
- [ ] Set up job to run integration tests from evaluation/run_evaluation.py on smaller example datasets
- [ ] Add conditional skip logic for Docker-dependent tests if Docker is unavailable
🌿Good first issues
- Add tool usage documentation: evaluation/patch_selection/trae_selector/tools/tools/ has execute_bash.py and execute_str_replace_editor.py with no docstrings. Document the contract between tool.py classes and selector_agent.py that invokes them.
- Expand test coverage for edit.py tool: tests/tools/ exists but test_bash_tool.py is present while edit.py (file modification core) lacks dedicated unit tests showing str_replace_editor behavior with edge cases (overlapping ranges, encoding issues).
- Create examples/ directory with runnable Jupyter notebooks: docs/TRAJECTORY_RECORDING.md and docs/tools.md exist but no end-to-end example showing how to instantiate agent, configure LLM provider, and run a real task (e.g., 'refactor this Python function').
⭐Top contributors
Click to expand
Top contributors
- @chao-peng — 23 commits
- @JasonHonKL — 14 commits
- @trae-agent — 7 commits
- @luke396 — 4 commits
- @L-Qun — 4 commits
📝Recent commits
Click to expand
Recent commits
e839e55— fix(openai): persist tool outputs in message history (#369) (wcyjames)d9b60cd— fix(#281): resolve Rich MarkupError when error messages contain squar… (#341) (sirix-v)2cb6578— doc: modify bug report template note for private token uploading (#321) (WillemJiang)8472571— Feat/fix some bugs for docker mode and update README (#318) (kinesiatricssxilm14)cc33769— Add Docker mode (#306) (kinesiatricssxilm14)a8d7f69— hotfix:_BashSession.stop()may might hang on Windows (#297) (zanghu)70d83a6— fix: Azure GPT5 doesn't support max_tokens instead of max_completion_… (#286) (yaohaowei0914)3e02d66— add base_url usage to the README.md (#294) (MrKylinGithub)92efea5— Feat: Integrate swebench, swebench-live, and multi-swebench evaluation workflows (#295) (Eshe0922)d135080— Fix empty content error in tool call result handling for Anthropic API (#231) (rakodalovic)
🔒Security observations
- High · Potential Command Injection in Bash Tool —
trae_agent/tools/bash_tool.py. The bash_tool.py file likely executes shell commands based on user input. Without proper sanitization and validation, this could allow command injection attacks where an attacker could execute arbitrary system commands through crafted input to the agent. Fix: Implement strict input validation and use subprocess with shell=False. Use shlex.quote() for any arguments that must be passed to shell. Consider using allowlists for permitted commands and implement rate limiting on command execution. - High · Potential Code Execution via File Operations —
trae_agent/tools/edit_tool.py, trae_agent/tools/json_edit_tool.py. The edit_tool.py and json_edit_tool.py allow arbitrary file read/write operations. Combined with the agent's ability to execute code, this could allow an attacker to modify critical files, inject malicious code, or exfiltrate sensitive data. No apparent path traversal protections are visible in the file structure. Fix: Implement strict path validation using os.path.abspath() and verify paths are within allowed directories. Use a sandbox directory whitelist. Implement file permission checks and audit all file operations. Consider using a virtual filesystem layer. - High · Docker Execution Without Security Constraints —
trae_agent/agent/docker_manager.py, trae_agent/tools/docker_tool_executor.py. The docker_manager.py and docker_tool_executor.py modules execute arbitrary code in Docker containers. Without proper resource limits, network isolation, and capability restrictions, this could be exploited for container escape, resource exhaustion, or lateral movement attacks. Fix: Configure Docker containers with: --read-only root filesystem, --cap-drop=ALL, memory limits, CPU limits, --network=none or isolated network, and disable privileged mode. Implement seccomp profiles and AppArmor/SELinux policies. Use user namespaces with non-root user execution. - Medium · Insufficient Input Validation on LLM Agent —
trae_agent/agent/trae_agent.py, trae_agent/agent/agent.py. The agent accepts natural language instructions which are processed by an LLM and converted to tool calls. The conversion process may be vulnerable to prompt injection attacks where an attacker could craft instructions to bypass safety constraints and execute unintended operations. Fix: Implement input sanitization and length limits on user instructions. Add a secondary validation layer that verifies tool calls against a schema before execution. Implement rate limiting and monitoring for suspicious patterns. Use prompt engineering techniques to make the model more robust to injection attempts. - Medium · MCP Tool Integration Security —
trae_agent/tools/mcp_tool.py, tests/tools/test_mcp_tool.py. The MCP (Model Context Protocol) tool implementation loads and executes external tools/plugins. Without proper sandboxing and verification, this could allow execution of malicious code if an attacker can control the MCP tool source. Fix: Verify the integrity and authenticity of MCP tools before loading. Use cryptographic signatures to verify tool sources. Implement strict capability restrictions for MCP tools. Isolate MCP tool execution in sandboxed environments. Maintain an allowlist of trusted tool sources. - Medium · Credentials in Configuration Files —
tests/utils/test_google_client.py, tests/utils/test_openrouter_client_utils.py, tests/utils/test_ollama_client_utils.py, trae_agent/utils/. The codebase includes utilities for Google client and multiple LLM client configurations (OpenRouter, Ollama). API keys and credentials may be passed through environment variables or configuration files without proper encryption or access controls. Fix: Never hardcode credentials. Use environment variables with a .env.example template (without actual values). Implement credential rotation mechanisms. Use secure secret management systems (e.g., HashiCorp Vault, AWS Secrets Manager). Encrypt credentials at rest and in transit. Implement audit logging for credential access. - Medium · Insufficient Logging and Monitoring —
trae_agent/agent/, trae_agent/tools/. Agent operations including tool execution, file modifications, and command execution should be comprehensively logged for security auditing. The codebase structure suggests limited logging/monitoring capabilities for tracking security-relevant events. Fix:
LLM-derived; treat as a starting point, not a security audit.
👉Where to read next
- Open issues — current backlog
- Recent PRs — what's actively shipping
- Source on GitHub
Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.