Microsoft Agent-Lightning Setup and Usage Guide
This guide describes how to use
microsoft/agent-lightning to automatically optimize GIIP agent prompts.
🚀 Overview
Agent-Lightning is a framework for tuning agent prompts using reinforcement learning (RL). By leveraging task history as a dataset, it identifies the optimal instructions that lead to higher performance.
[!IMPORTANT] Windows User Notice:
relies on Unix-only libraries. You must run it in WSL2 or a Linux environment.agent-lightning
🛠️ Installation (WSL2 / Linux)
-
Prepare Python Environment:
# Python 3.10+ recommended python3 -m venv venv source venv/bin/activate -
Install Library:
pip install agentlightning -
Set API Keys: Set environment variables so the training loop can call your LLM.
export AZURE_OPENAI_API_KEY="your-key" export AZURE_OPENAI_ENDPOINT="your-endpoint"
📈 Usage Workflow
Step 1: Generate Training Data
Run the following command in your Windows terminal to convert project task logs into a dataset.
python giipdb/scripts/prompt_optimization/generate_dataset.py
Upon success,
giipdb/scripts/prompt_optimization/giip_training_data.jsonl will be created.
Step 2: Start Reinforcement Learning (WSL2)
Use the generated dataset to tune your agent instructions.
# Execute in WSL terminal python giipdb/scripts/prompt_optimization/train_giip_role.py
Step 3: Apply Optimized Results
Once training is complete, update the respective markdown files in the
.agent/roles/ folder with the resulting Optimal Prompt.
📊 Benefits
- Improved Success Rates: Learn from past failures to prevent similar errors.
- Automated Prompt Engineering: Objectively optimize performance using data instead of manual tuning.
- Self-Improving System: Continuously elevate agent intelligence throughout the project lifecycle.