Skip to content

Commit 160a82b

Browse files
authored
Update README (#22)
1 parent 7102e9a commit 160a82b

File tree

6 files changed

+73
-50
lines changed

6 files changed

+73
-50
lines changed

README.md

Lines changed: 68 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,56 @@
1-
# Agent Lightning
1+
![Agent-lightning-banner](assets/readme-banner.png)
22

3-
Welcome to Agent Lightning! Agent Lightning is a flexible and extensible training framework that enables seamless model training for any existing agent framework.
3+
# Agent Lightning
44

5-
This guide will walk you through setting up and running the project.
5+
Agent Lightning is a flexible framework that enables you to optimize any AI agent.
66

7-
## Installation
7+
## ⚡ Core Features
88

9-
First, let's get your environment set up. We'll be using `/path/to/agentlightning` to refer to the directory containing this README file.
10-
11-
### 1. Set Up Your Environment
9+
- Turn your agent into an optimizable beast with **ZERO CODE CHANGE** (almost)! 💤
10+
- Build with **ANY** agent framework (LangChain, OpenAI Agent SDK, AutoGen, CrewAI, ...); or even WITHOUT agent framework (Python OpenAI). You name it! 🤖
11+
- **Selectively** optimize one or more agents in a multi-agent system. 🎯
12+
- Embraces Reinforcement Learning, Automatic Prompt Optimization and more **algorithms**. 🤗
1213

13-
We strongly recommend creating a new virtual environment to avoid conflicts with other packages. You can use either `conda` or `venv`. **Python 3.10 or later** is recommended.
14+
![Agent-Lightning-code-diff](assets/readme-diff.png)
1415

15-
### 2. Install Core Dependencies
16+
## ⚡ Resources
1617

17-
Next, let's install the essential packages: `uv`, `PyTorch`, `FlashAttention`, and `vLLM`.
18+
- 7/26/2025 [We discovered an approach to train any AI agent with RL, with (almost) zero code changes.](https://www.reddit.com/r/LocalLLaMA/comments/1m9m670/we_discovered_an_approach_to_train_any_ai_agent/) Reddit.
19+
- 6/6/2025 [Agent Lightning - Microsoft Research](https://www.microsoft.com/en-us/research/project/agent-lightning/) Project page.
1820

19-
* **Install `uv`** (This is required for some MCP agents; otherwise some agents might hang):
21+
## ⚡ Installation
2022

21-
```bash
22-
curl -LsSf https://astral.sh/uv/install.sh | sh
23-
```
23+
First, let's get your environment set up. We'll be using `/path/to/agentlightning` to refer to the directory containing this README file.
2424

25-
* **Install `PyTorch`, `FlashAttention`, and `vLLM`**:
26-
The following versions and installation order have been tested and are confirmed to work.
25+
### 1. Set Up Your Environment
2726

28-
```bash
29-
pip install torch==2.7.0 torchvision==0.22.0 torchaudio==2.7.0 --index-url https://download.pytorch.org/whl/cu128
30-
pip install flash-attn --no-build-isolation
31-
pip install vllm==0.9.2
32-
```
27+
We strongly recommend creating a new virtual environment to avoid conflicts with other packages. You can use either `conda` or `venv`. **Python 3.10 or later** is recommended.
3328

34-
### 3. Install VERL
29+
### 2. Install Core Training Dependencies (Optional)
3530

36-
Agent Lightning requires VERL for RL training. Please install the latest version from main branch.
31+
If you are running RL with Agent-Lightning, the next step is to install the essential packages: `PyTorch`, `FlashAttention`, `vLLM` and `VERL`. The following versions and installation order have been tested and are confirmed to work.
3732

3833
```bash
39-
git clone https://github.com/volcengine/verl /path/to/your/verl
40-
cd /path/to/your/verl
41-
pip install -e .
34+
pip install torch==2.7.0 torchvision==0.22.0 torchaudio==2.7.0 --index-url https://download.pytorch.org/whl/cu128
35+
pip install flash-attn --no-build-isolation
36+
pip install vllm==0.9.2
37+
pip install verl==0.5.0
4238
```
4339

44-
### 4. Install Agent Lightning
40+
See `scripts/setup_stable_gpu.sh` for a full installation script.
41+
42+
### 3. Install Agent Lightning
4543

4644
Now, you're ready to install Agent Lightning itself.
4745

4846
```bash
49-
cd /path/to/agentlightning
50-
pip install -e .
47+
pip install agentlightning
5148
```
5249

53-
### 5. Install Optional Frameworks
50+
### 4. Install Agent Frameworks (Optional)
5451

5552
If you plan to use other agent frameworks, you can install them with the following commands. If you don't need these, feel free to skip this step.
53+
We recommend doing this as the final step to avoid dependency versions being overwritten by mistake.
5654

5755
```bash
5856
# AutoGen (Recommended to install first)
@@ -64,6 +62,9 @@ pip install "litellm[proxy]"
6462
# MCP
6563
pip install mcp
6664

65+
# UV
66+
pip install uv
67+
6768
# OpenAI Agents
6869
pip install openai-agents
6970

@@ -76,19 +77,40 @@ pip install sqlparse nltk
7677

7778
Don't worry if dependency conflicts arise during this step. Follow the installation order above and the conflicts generally do not matter.
7879

79-
## Architecture
80+
## ⚡ Examples
81+
82+
For more detailed examples, please see the `examples` folder:
83+
84+
1. [calc_x](examples/calc_x): An agent built with AutoGen with calculator tool use, trained on Calc-X dataset with Reinforcement Learning.
85+
2. [spider](examples/spider): A write-check-rewrite looped agent with LangGraph with SQL execution; selectively optimize write and rewrite on Spider dataset with Reinforcement Learning.
86+
3. [apo](examples/apo): An example to customize an optimization algorithm: Automatic Prompt Optimization.
87+
88+
## ⚡ Important Caveats
89+
90+
1. **AgentOps Integration**: Agent Lightning uses [AgentOps](https://github.com/AgentOps-AI/agentops) for agent tracking by default. If you're already using AgentOps in your own code, you'll need to disable our managed AgentOps client by modifying the `tracer` parameter of trainer.
91+
2. **Debugging Traces**: If you encounter issues with tracing, you can visualize the trace tree using `tracer.last_trace().visualize("tree_graph")`. Please note that this API is experimental and may change in future releases.
92+
3. **Launching the Server and Agents**: Currently, the training server and agent clients must be launched in separate processes. You can open two terminal windows or run one of them in the background. The launching order generally doesn't matter.
93+
4. **Environment Variables**: The environment variables and working directory at the time of `ray init` are important. If you run into "file not found" errors, try restarting Ray from your current working directory.
94+
5. **Handling Timeouts**: The training server may hang if samples fail or time out on the agent side. To prevent this, we recommend setting limits on the prompt and response lengths, as this is the most common cause of failures.
95+
6. **VERL Failures**: Save checkpoints frequently, as VERL with vLLM may sometimes experience out-of-memory issues. If you encounter a VERL failure, you can resume training from the last checkpoint.
96+
97+
## ⚡ Architecture
8098

8199
Currently, Agent Lightning is built around a **training server** and one or multiple **agents**.
82100

83-
* The **server** manages the training data, prepares samples for the agents, and provides the LLM endpoint.
84-
* **Agents** retrieve samples from the server, process them (which may involve interacting with the LLM), and send the results back. These results, or "trajectories," are lists of prompts and responses from the LLM.
85-
* The **server** then collects these trajectories and computes the loss to optimize the language models.
101+
* The **server** manages the training data, prepares samples for the agents, and provides the LLM endpoint.
102+
* **Agents** retrieve samples from the server, process them (which may involve interacting with the LLM), and send the results back. These results, or "trajectories," are lists of prompts and responses from the LLM.
103+
* The **server** then collects these trajectories and computes the losses to optimize the language models.
104+
105+
![Agent-Lightning-architecture](assets/readme-architecture.png)
86106

87-
## Development Instructions
107+
## Development Instructions
88108

89109
Install with development dependencies:
90110

91111
```
112+
git clone https://github.com/microsoft/agent-lightning
113+
cd agent-lightning
92114
pip install -e .[dev]
93115
```
94116

@@ -99,20 +121,22 @@ pre-commit install
99121
pre-commit run --all-files --show-diff-on-failure --color=always
100122
```
101123

102-
## Examples
124+
## ⚡ Contributing
103125

104-
For more detailed examples, please see the `examples` folder.
126+
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
105127

106-
## Important Caveats
128+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
107129

108-
1. **AgentOps Integration**: Agent Lightning uses [AgentOps](https://github.com/AgentOps-AI/agentops) for agent tracking by default. If you're already using AgentOps in your own code, you'll need to disable our managed AgentOps client by modifying the `tracer` parameter of trainer.
130+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
109131

110-
2. **Debugging Traces**: If you encounter issues with tracing, you can visualize the trace tree using `tracer.last_trace().visualize("tree_graph")`. Please note that this API is experimental and may change in future releases.
132+
## ⚡ Trademarks
111133

112-
3. **Launching the Server and Agents**: Currently, the training server and agent clients must be launched in separate processes. You can open two terminal windows or run one of them in the background. The order in which you launch them generally doesn't matter.
134+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.
113135

114-
4. **Environment Variables**: The environment variables and working directory at the time of `ray init` are important. If you run into "file not found" errors, try restarting Ray from your current working directory.
136+
## ⚡ Responsible AI
115137

116-
5. **Handling Timeouts**: The training server may hang if samples fail or time out on the agent side. To prevent this, we recommend setting limits on the prompt and response lengths, as this is the most common cause of failures.
138+
This project has been evaluated and certified to comply with the Microsoft Responsible AI Standard. The team will continue to monitor and maintain the repository, addressing any severe issues, including potential harms, if they arise.
117139

118-
6. **VERL Failures**: Save checkpoints frequently, as VERL with vLLM may sometimes experience out-of-memory issues. If you encounter a VERL failure, you can resume training from the last checkpoint.
140+
## ⚡ License
141+
142+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

assets/readme-architecture.png

598 KB
Loading

assets/readme-banner.png

166 KB
Loading

assets/readme-diff.png

1.06 MB
Loading

examples/calc_x/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ This example requires a single node with one GPU of at least 40GB memory.
66
2. Start ray: `bash ../../scripts/restart_ray.sh`. To use Wandb, you need to set the WANDB_API_KEY environment variable before starting ray.
77
3. Run the agent: `python calc_agent.py`. It automatically launches 4 agent workers by default.
88
4. In another terminal, launch the training server: `bash train.sh`.
9+
10+
## Common Issues
11+
12+
1. The agent client will hang indefinitely if the environment is not properly configured. Check if uv and mcp are properly installed. Use `tests/test_mcp_calculator.py` to verify the installation.

scripts/setup_stable_gpu.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ pip install --no-cache-dir torch==2.7.0 torchvision==0.22.0 torchaudio==2.7.0 --
77
pip install --no-cache-dir transformers==4.53.3
88
pip install --no-cache-dir flash-attn==2.8.1 --no-build-isolation
99
pip install --no-cache-dir vllm==0.9.2
10-
11-
git clone https://github.com/volcengine/verl
12-
cd verl
13-
git checkout 1df03f3abf96f59cb90c684f93a71ee0bbb57f49
14-
pip install --no-cache-dir -e .
15-
cd ..
10+
pip install --no-cache-dir verl==0.5.0
1611

1712
pip install --no-cache-dir -e .[dev,agent]

0 commit comments

Comments
 (0)