agent-lightning
Microsoft Research's agent training framework. Optimizes AI agents with Reinforcement Learning, Automatic Prompt Optimization, and Supervised Fine-tuning. Zero code change required. Works with LangChain, AutoGen, CrewAI, OpenAI Agent SDK.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/olmmlo-cmd/agent-lightningAgent Lightning ⚡
Microsoft Research's agent training framework. Turn your AI agents into optimizable beasts with (almost) zero code changes.
Core Features
- 🔌 Universal Compatibility: Works with LangChain, OpenAI Agent SDK, AutoGen, CrewAI, Microsoft Agent Framework, or plain Python OpenAI
- 🎯 Selective Optimization: Optimize one or more agents in a multi-agent system
- 🧠 Multiple Algorithms: Reinforcement Learning (RL), Automatic Prompt Optimization (APO), Supervised Fine-tuning (SFT)
- ⚡ Zero Code Change: Add
agl.emit_xxx()helpers or use tracer — your agent keeps running as usual
Installation
pip 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
Quick Start
1. Instrument Your Agent
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)
2. Create Training Config
# 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"
3. Run Training
agent-lightning train --config config.yaml
Algorithms
| 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 |
Usage Commands
agent-lightning train
Train your agent with configured algorithm.
agent-lightning eval
Evaluate agent on benchmark tasks.
agent-lightning export
Export trained model/prompts for deployment.
agent-lightning serve
Launch serving endpoint for trained agent.
Example: SQL Agent Training
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
)
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-olmmlo-cmd-agent-lightning": {
"enabled": true,
"auto_update": true
}
}
}Tags
Related Skills
peft-fine-tuning
Parameter-efficient fine-tuning for LLMs using LoRA, QLoRA, and 25+ methods. Use when fine-tuning large models (7B-70B) with limited GPU memory, when you need to train <1% of parameters with minimal accuracy loss, or for multi-adapter serving. HuggingFace's official library integrated with transformers ecosystem.
office-to-md
Convert Office documents (Word, Excel, PowerPoint, PDF) to Markdown using Microsoft's markitdown
memory-maintenance
Intelligent memory management for OpenClaw agents. Reviews daily notes, suggests MEMORY.md updates, maintains directory health, and auto-cleans old files. Recommended for agents with growing memory footprints.