agent-lightningMicrosoft Research's agent training framework. Optimizes AI agents with Reinforcement Learning, Automatic Prompt Optimization, and Supervised Fine-tuning. Ze...
Install via ClawdBot CLI:
clawdbot install olmmlo-cmd/agent-lightningMicrosoft Research's agent training framework. Turn your AI agents into optimizable beasts with (almost) zero code changes.
agl.emit_xxx() helpers or use tracer — your agent keeps running as usualpip install agentlightning
For latest nightly build:
pip install --upgrade --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ --pre agentlightning
Option A: Add emit helpers (recommended)
import agentlightning as agl
# In your agent's tool calls
response = agl.emit_tool_call(
model=model,
messages=messages,
tools=tools,
context={"task": "search"}
)
Option B: Use tracer (zero code change)
from agentlightning import tracer
# Wrap your agent with tracer
with tracer.trace("my-agent", input_data):
result = your_agent.run(user_query)
# config.yaml
agent:
name: "my-agent"
type: "openai" # openai, langchain, autogen, crewai
training:
algorithm: "grpo" # grpo, apo, sft, rloo
episodes: 100
batch_size: 16
environment:
eval_tasks:
- "math"
- "coding"
- "reasoning"
agent-lightning train --config config.yaml
| Algorithm | Use Case | Description |
|-----------|----------|-------------|
| GRPO | General RL | Group Relative Policy Optimization — stable, works well for most agents |
| APO | Prompt Tuning | Automatic Prompt Optimization — improves system prompts |
| SFT | Supervised Fine-tuning | Supervised Fine-tuning with preference data |
| RLOO | Long-horizon | RLOO for tasks with sparse rewards |
agent-lightning trainTrain your agent with configured algorithm.
agent-lightning evalEvaluate agent on benchmark tasks.
agent-lightning exportExport trained model/prompts for deployment.
agent-lightning serveLaunch serving endpoint for trained agent.
See full example: Train SQL Agent with RL
from agentlightning import Agent, RLConfig, GRPOTrainer
# 1. Define your agent
sql_agent = Agent(
name="sql-agent",
system_prompt="You are a SQL expert...",
tools=[execute_sql, query_schema]
)
# 2. Configure RL training
config = RLConfig(
algorithm="grpo",
episodes=500,
learning_rate=1e-4
)
# 3. Train
trainer = GRPOTrainer(config=config)
trainer.train(sql_agent, eval_tasks=["sql-generation"])
# Required for training
export OPENAI_API_KEY="sk-..."
# Optional: for remote storage
export AGL_STORAGE="s3://my-bucket/agent-lightning/"
from agentlightning import LightningStore, GRPOTrainer
# LightningStore keeps tasks, resources, and traces in sync
store = LightningStore()
# Read traces, learn, and update prompts
trainer = GRPOTrainer(store=store)
trainer.train(agent=my_agent)
# Launch dashboard
agent-lightning dashboard --port 8080
# View logs
tail -f ~/.agent-lightning/logs/training.log
If you use Agent Lightning in research:
@misc{luo2025agentlightningtrainai,
title={Agent Lightning: Train ANY AI Agents with Reinforcement Learning},
author={Xufang Luo and Yuge Zhang and Zhiyuan He and Zilong Wang and Siyun Zhao and Dongsheng Li and Luna K. Qiu and Yuqing Yang},
year={2025},
eprint={2508.03680},
archivePrefix={arXiv},
primaryClass={cs.AI}
}
Generated Mar 1, 2026
A company uses an AI agent for customer support to handle common inquiries and troubleshoot issues. Agent Lightning can train the agent via Reinforcement Learning to improve response accuracy and customer satisfaction scores, reducing escalations to human agents.
A financial firm employs an AI agent to analyze market data and generate investment reports. Using Agent Lightning's Supervised Fine-tuning, the agent can learn from expert feedback to enhance its analytical precision and compliance with regulatory guidelines.
A healthcare provider uses an AI agent to assist in preliminary diagnostics by analyzing patient symptoms and medical history. Agent Lightning's Automatic Prompt Optimization can refine the agent's prompts to increase diagnostic accuracy and safety, supporting clinicians in decision-making.
An e-commerce platform integrates an AI agent to personalize product recommendations based on user behavior. With Agent Lightning's Reinforcement Learning, the agent can optimize its recommendations to boost conversion rates and customer engagement over time.
An educational tech company deploys an AI tutoring agent to help students with homework and learning exercises. Agent Lightning's training algorithms can fine-tune the agent using student interaction data to improve explanatory clarity and adapt to different learning styles.
Offer Agent Lightning as a cloud-based service where businesses pay a monthly or annual fee to access training tools, dashboards, and support. This model provides recurring revenue and scales with customer usage across various industries.
Provide specialized consulting services to help enterprises integrate and optimize Agent Lightning for their specific AI agents. This includes custom training configurations, algorithm tuning, and ongoing maintenance, generating high-value project-based income.
Sell enterprise licenses for on-premises deployment of Agent Lightning, catering to organizations with strict data privacy or compliance requirements. This model includes upfront licensing costs and optional support packages for long-term revenue.
💬 Integration Tip
Start by instrumenting agents with minimal code changes using the tracer option, then gradually implement training configurations based on specific performance goals.
Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Clau...
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
Search and analyze your own session logs (older/parent conversations) using jq.
Typed knowledge graph for structured agent memory and composable skills. Use when creating/querying entities (Person, Project, Task, Event, Document), linking related objects, enforcing constraints, planning multi-step actions as graph transformations, or when skills need to share state. Trigger on "remember", "what do I know about", "link X to Y", "show dependencies", entity CRUD, or cross-skill data access.
Ultimate AI agent memory system for Cursor, Claude, ChatGPT & Copilot. WAL protocol + vector search + git-notes + cloud backup. Never lose context again. Vibe-coding ready.
Headless browser automation CLI optimized for AI agents with accessibility tree snapshots and ref-based element selection