agent-lightning

agent-lightning is a skill for Claude Code, Codex from coco-research/coco. It costs 48 tokens per session (1,848 once invoked), scanned B, original, Apache-2.0.

A guide to training and improving AI agents with Microsoft's Agent Lightning framework. It covers reinforcement learning, which improves an agent through rewards, along with tracing, shared training storage, reward functions, and listed optimization methods.

In plain words
What is it for?
Use it when setting up agent training, recording agent runs, defining rewards, configuring LightningStore, or applying reinforcement learning and APO prompt optimization.
Why use it?
It helps measure how an agent behaves and use feedback to improve its prompts or actions systematically.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when setting up agent training, recording agent runs, defining rewards, configuring LightningStore, or applying reinforcement learning and APO prompt optimization.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/coco-research/coco/agent-lightning
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add coco-research/coco --skill agent-lightning
Clone the repo
git clone --depth 1 https://github.com/coco-research/coco

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for agent-lightning

README.md
[![agentmods](https://agentmods.dev/badge/skills/coco-research/coco/agent-lightning/github.svg)](https://agentmods.dev/skills/coco-research/coco/agent-lightning)
Your own site
<a href="https://agentmods.dev/skills/coco-research/coco/agent-lightning"><img src="https://agentmods.dev/badge/skills/coco-research/coco/agent-lightning/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for agent-lightning

Your own site · 80×15
<a href="https://agentmods.dev/skills/coco-research/coco/agent-lightning"><img src="https://agentmods.dev/badge/skills/coco-research/coco/agent-lightning.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,848 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00048 $0.01848
Opus 5.5 $0.00019 $0.00739
Sonnet 5.5 $0.00010 $0.00370
Haiku 4.5 $0.00005 $0.00185

Measured 3mo ago against content hash 8e29e4f578b9, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

agent-lightning scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Sends data to an external URLmediumData exfiltration

A POST to an outside endpoint may be telemetry or may be exfiltration; either way the mod talks to somewhere, and you should know where.

const response = await fetch('http://localhost:8080/rollouts', { method: 'POST',
skills/agent-lightning/SKILL.md · 352 lines

How it starts

The opening of the file, as written. The whole thing — 352 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent Lightning

Microsoft's framework for training AI agents with reinforcement learning, automatic prompt optimization, and supervised fine-tuning.

Quick Start

Installation

pip install agentlightning

For nightly builds:

pip install --upgrade --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ --pre agentlightning

Minimal Integration (Zero Code Change)

Add agl.emit_xxx() helpers to your existing agent:

import agentlightning as agl

# Your existing agent code
def my_agent(task):
    agl.emit_input(task)  # Track input
    
    response = llm.generate(task)
    agl.emit_output(response)  # Track output
    
    reward = evaluate(response)
    agl.emit_reward(reward)  # Track reward
    
    return response

Core Concepts

Architecture Flow

Agent (your code) → agl.emit_xxx() → Spans → LightningStore → Algorithm → Updated Resources

Key Components

Component Purpose
LightningStore Central hub for traces, tasks, and resources
Tracer Collects spans from agent execution
Algorithm Consumes traces, produces improvements
Trainer Orchestrates training loop

Instrumentation

Emit Functions

import agentlightning as agl

# Basic emissions
agl.emit_input(prompt)           # Track input to agent
agl.emit_output(response)        # Track agent output
agl.emit_reward(score)           # Track reward signal
agl.emit_tool_call(name, args)   # Track tool usage
agl.emit_tool_result(result)     # Track tool results

Tracer Context

from agentlightning import Tracer

tracer = Tracer(store=store)

with tracer.trace_context(task_id="task-123"):
    # All emissions within this context are grouped
    result = agent.run(task)
    
# Retrieve trace after execution
trace = tracer.get_last_trace()

OpenTelemetry Integration

Agent Lightning integrates with OpenTelemetry:

from agentlightning.utils.otel import get_tracer

tracer = get_tracer()  # Returns OTel tracer for "agentlightning"

Read the full file on GitHub · 352 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 352 lines · 48 tokens per session scan B 8e29e4f578b9

Subscribe to this mod's changes

agent-lightning is a skill published in the GitHub repository coco-research/coco (323 stars, last pushed yesterday), licensed Apache-2.0. It adds 48 tokens to every session and 1,848 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it B with 1 finding (sends data to an external url). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

agent-lightning compared with skills from other repositories

agent-lightning next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
agent-lightningcoco-research/cocoSkill323yesterdayApache-2.0B48Claude Code, Codex
pageindexmarcusquinn/aidevopsSkill476todayMITA15Claude Code
infrastructure-llmdocxology/templateSkill25todayApache-2.0A66Claude Code, Codex
infrastructure-search-moniddocxology/templateSkill25todayApache-2.0A124Claude Code, Codex
template-autoresearch-projectdocxology/templateSkill25todayApache-2.0A30Claude Code, Codex
bioinformatics-scientistwonsukchoi/domain-expertsSkill30todayMITA168Claude Code, Codex
ai-researcherK-Dense-AI/scientific-agentsSkill2651mo agoMITA111Claude Code