Skip to content

Commit feebaec

Browse files
authored
Add AGENTS.md (#374)
1 parent 4adf4e3 commit feebaec

File tree

8 files changed

+97
-12
lines changed

8 files changed

+97
-12
lines changed

.github/workflows/badge-examples.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- Examples - Tinker
1111
- Examples - Azure
1212
- Examples - Claude Code
13+
- Examples - RAG
1314
types: [completed]
1415

1516
workflow_dispatch:
@@ -37,5 +38,6 @@ jobs:
3738
{ workflow: 'examples-tinker.yml', label: 'examples-tinker.stable', variants: ['stable'] },
3839
{ workflow: 'examples-azure.yml', label: 'examples-azure.stable', variants: ['stable'] },
3940
{ workflow: 'examples-claude-code.yml', label: 'examples-claude-code.stable', variants: ['stable'] },
41+
{ workflow: 'examples-rag.yml', label: 'examples-rag.stable', variants: ['stable'] },
4042
];
4143
await badgeAggregation({ github, context, core, dependencies });

.github/workflows/badge-latest.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
- Examples - Spider
88
- Examples - APO
99
- Examples - Unsloth
10+
- Examples - RAG
11+
- Examples - Claude Code
1012
- GPU Test
1113
types: [completed]
1214

@@ -32,6 +34,8 @@ jobs:
3234
{ workflow: 'examples-spider.yml', label: 'spider.latest', variants: ['latest'] },
3335
{ workflow: 'examples-apo.yml', label: 'apo.latest', variants: ['latest'] },
3436
{ workflow: 'examples-unsloth.yml', label: 'unsloth.latest', variants: ['latest'] },
37+
{ workflow: 'examples-claude-code.yml', label: 'claude-code.latest', variants: ['latest'] },
38+
{ workflow: 'examples-rag.yml', label: 'rag.latest', variants: ['latest'] },
3539
{ workflow: 'tests-full.yml', label: 'tests-full.latest', variants: ['latest'] },
3640
];
3741
await badgeAggregation({ github, context, core, dependencies });

.github/workflows/badge-rag.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Badge - RAG
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- Examples - RAG
7+
types: [completed]
8+
9+
workflow_dispatch:
10+
11+
permissions:
12+
actions: read
13+
contents: read
14+
15+
jobs:
16+
badge:
17+
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }}
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/github-script@v8
22+
with:
23+
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
script: |
25+
const badgeAggregation = require('./scripts/badge_aggregation.js');
26+
const dependencies = [
27+
{ workflow: 'examples-rag.yml', label: 'rag', variants: ['legacy', 'stable'] },
28+
];
29+
await badgeAggregation({ github, context, core, dependencies });

AGENTS.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Repository Guidelines
2+
3+
## Architecture Overview
4+
Agent Lightning runs through a continuous loop: runners and tracers emit spans, `LightningStore` (`agentlightning/store/`) keeps them synchronized, and algorithms in `agentlightning/algorithm/` consume those traces to improve behavior.
5+
6+
## Project Structure & Module Organization
7+
- `agentlightning/`: adapters, execution stack, training loop, tracer, reward logic, and the `agl` CLI.
8+
- `docs/` & `examples/`: narrative and procedural docs (assets in `docs/assets/`, navigation in `mkdocs.yml`) plus runnable workflows whose READMEs point to their companion how-to guides. `docs/how-to` covers task-focused instructions, while `docs/tutorials` explains concepts and subsystems.
9+
- `dashboard/`, `scripts/`, `tests/`: UI bundles, release/dataset/CI automation, and mirrored coverage of the runtime tree. Record download steps rather than committing binaries.
10+
11+
## Build, Test, and Development Commands
12+
- `uv sync --group dev` — provision tooling once per environment.
13+
- `uv run --no-sync pytest -v` — execute the full suite; add a path or `-k expr` to narrow the run.
14+
- `uv run --no-sync pyright` — enforce static typing parity with CI.
15+
- `uv run --no-sync pre-commit run --all-files --show-diff-on-failure` and `uv run --no-sync mkdocs build --strict` — keep formatting tidy and documentation valid.
16+
Always commit the refreshed `uv.lock` when dependencies shift, and mention optional groups (VERL, APO, GPU) in PR notes.
17+
18+
## Coding Style & Naming Conventions
19+
- Target `requires-python >= 3.10`, four-space indentation, 120-character lines (though docstrings may run longer), and formatter-owned diffs (Black + isort, `black` profile). Use `snake_case` for modules, functions, and variables; `PascalCase` for classes and React components; lowercase hyphenation for CLI flags, branch names, and TypeScript filenames.
20+
- Maintain exhaustive type hints (pyright enforces them) and prefer shared dataclasses or Pydantic models from `agentlightning.types`.
21+
- Author Google-style docstrings for new modules or public methods—succinct descriptions, no redundant type info, no redundant `Key features/components` bullet points, and `[][]` syntax for cross-references.
22+
- Writing logs is encouraged, especially for long functions with multiple steps and try-except blocks that catch all exceptions. Use `logging.getLogger(__name__)` to get loggers. Distinguish between DEBUG, INFO, WARNING, and ERROR logs.
23+
24+
## Testing Guidelines
25+
- Mirror runtime directories under `tests/` and match filenames for quick traceability.
26+
- Parametrize pytest cases and apply markers (`openai`, `gpu`, `agentops`, `mongo`, `llmproxy`) so optional suites can be skipped via selectors like `-m "not mongo"` yet still exercised in CI.
27+
- Lean on fixtures, favor real stores/spans/agents over mocks, and drive coverage across the majority of branches.
28+
- If an imported module is missing from the environment, check whether `uv sync` has been run with the right groups. Do not make stubs for external dependencies unless necessary.
29+
30+
## Example Contributions
31+
- Ship each example with a README that includes smoke-test instructions so maintainers can validate quickly. The README must contain an "Included Files" section summarizing every file and its role.
32+
- Keep runnable example modules self-contained with a module-level docstring describing CLI usage. Document important or educational classes/functions with targeted docstrings and inline comments where clarity matters.
33+
- Add a CI workflow per example named `examples-<name>.yml` in `.github/workflows/`. Register it in `badge-<name>.yml`, `badge-examples.yml`, and `badge-latest.yml` when applicable so badges stay accurate.
34+
35+
## Commit & Pull Request Guidelines
36+
- Branch from a fresh `main` using `feature/<slug>`, `fix/<slug>`, `docs/<slug>`, or `chore/<slug>`.
37+
- Write imperative, scoped commits, reference issues with `Fixes #123`, and rerun pre-commit plus the relevant pytest/doc builds before pushing.
38+
- Use PR descriptions to summarize intent, list verification commands, call out dependency or docs-navigation updates, and link new docs/examples via `mkdocs.yml` or `examples/README.md`. Include logs for dashboard changes.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

docs/community/contributing.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Bonus points for examples that:
4646
- Ship CI or self-test coverage so we know they still work as the core evolves. **Otherwise, we would have to mark the example as unmaintained because we won't be able to test the examples manually before each release.**
4747
- Include a [`docs/how-to/`]({{ src("docs/how-to/") }}) guide (or a detailed README if no how-to exists) without duplicating content in multiple places.
4848
- Favor simple, dependency-light code over heavy abstractions.
49+
- Ship a README that documents smoke-test instructions and includes an "Included Files" section summarizing every file and its role; keep the runnable module self-contained with a module-level docstring explaining CLI usage, plus targeted docstrings or inline comments for educational functions/classes.
4950

5051
!!! warning "Please discuss first"
5152

@@ -126,13 +127,13 @@ After `uv sync`, run commands via `uv run ...` (add `--no-sync` once the environ
126127
Formatting and linting are enforced through [pre-commit](https://pre-commit.com/). Install once, then run before each push:
127128

128129
```bash
129-
uv run pre-commit install
130-
uv run pre-commit run --all-files --show-diff-on-failure --color=always
130+
uv run --no-sync pre-commit install
131+
uv run --no-sync pre-commit run --all-files --show-diff-on-failure --color=always
131132
```
132133

133134
Once installed, the hooks run automatically on every `git commit`. Running the pre-commit hooks locally keeps CI green and diffs manageable.
134135

135-
### 3. Branch From a Fresh `main`
136+
### 3. Branch from Fresh `main` and Code
136137

137138
Start all work from the latest upstream state:
138139

@@ -165,28 +166,36 @@ Use lowercase with hyphens, e.g., `feature/async-runner-hooks`.
165166

166167
Remember to register new docs in [`mkdocs.yml`]({{ src("mkdocs.yml") }}), add examples to [examples/README]({{ src("examples/README.md") }}), and update the [Examples Catalog](../how-to/examples-catalog.md).
167168

169+
Before you start coding, bring the shared coding conventions with you:
170+
171+
- Target `requires-python >= 3.10`, four-space indentation, ~120-character lines (docstrings may run longer), and formatter-owned diffs (Black + isort with the `black` profile).
172+
- Use `snake_case` for modules, functions, and variables; `PascalCase` for classes and React components; lowercase hyphenation for CLI flags, branch names, and TypeScript filenames.
173+
- Maintain exhaustive type hints (pyright enforces them), write succinct Google-style docstrings (with `[][]` cross-references).
174+
- Prefer dataclasses or Pydantic models from `agentlightning.types`.
175+
- Log via `logging.getLogger(__name__)` with targeted DEBUG/INFO/WARNING/ERROR calls—especially for long multi-step functions or broad `try/except` blocks.
176+
168177
### 4. Test and Validate
169178

170-
Most contributions require automated checks. Prefix commands with `uv run` so they use the project environment.
179+
Most contributions require automated checks. Once `uv sync` locks dependencies, prefix commands with `uv run --no-sync ...` so they share the same environment as CI.
171180

172181
**Full test suite**
173182

174183
```bash
175-
uv run pytest -v
184+
uv run --no-sync pytest -v
176185
```
177186

178187
**Targeted tests**
179188

180189
```bash
181-
uv run pytest tests/path/to/test_file.py -k test_name
190+
uv run --no-sync pytest tests/path/to/test_file.py -k test_name
182191
```
183192

184193
**Optional/gated tests:** GPU-specific suites or API-dependent tests run automatically when the required hardware or environment variables (such as `OPENAI_API_KEY`) are present.
185194

186195
**Static analysis:**
187196

188197
```bash
189-
uv run pyright
198+
uv run --no-sync pyright
190199
```
191200

192201
If you have touched code under `examples/`, you should run the example-specific smoke tests. Each directory includes a README with example-specific smoke tests—run those too.
@@ -196,16 +205,16 @@ If you have touched code under `examples/`, you should run the example-specific
196205
Keep API references under [docs/reference]({{ src("docs/reference/") }}) up to date. Doc-only changes should still build cleanly:
197206

198207
```bash
199-
uv run mkdocs serve --strict # live reload
200-
uv run mkdocs build --strict # CI-equivalent
208+
uv run --no-sync mkdocs serve --strict # live reload
209+
uv run --no-sync mkdocs build --strict # CI-equivalent
201210
```
202211

203212
`--strict` elevates warnings to errors so you catch issues before CI.
204213

205214
Before opening a PR, double-check the basics:
206215

207216
- Run `uv lock` if you changed dependencies.
208-
- Run `uv run pre-commit run --all-files` (hooks installed via `pre-commit install` run automatically on `git commit`, but rerun them if you amended history).
217+
- Run `uv run --no-sync pre-commit run --all-files --show-diff-on-failure` (hooks installed via `pre-commit install` run automatically on `git commit`, but rerun them if you amended history).
209218
- Execute the relevant commands from the test list above.
210219
- Validate each affected example via its README instructions.
211220

examples/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ This catalog highlights the examples shipped with Agent-lightning.
99
| [calc_x](./calc_x) | VERL-powered math reasoning agent training that uses AutoGen with an MCP calculator tool. | [![calc_x workflow status](https://github.com/microsoft/agent-lightning/actions/workflows/badge-calc-x.yml/badge.svg)](https://github.com/microsoft/agent-lightning/actions/workflows/examples-calc-x.yml) |
1010
| [claude_code](./claude_code) | Claude Code SWE-bench harness that records Agent-lightning traces across Anthropic, vLLM, and OpenAI-compatible backends. | [![claude_code workflow status](https://github.com/microsoft/agent-lightning/actions/workflows/badge-claude-code.yml/badge.svg)](https://github.com/microsoft/agent-lightning/actions/workflows/examples-claude-code.yml) |
1111
| [minimal](./minimal) | Bite-sized programs that demonstrate how individual Agent-lightning building blocks behave in isolation. | [![minimal workflow status](https://github.com/microsoft/agent-lightning/actions/workflows/badge-unit.yml/badge.svg)](https://github.com/microsoft/agent-lightning/actions/workflows/badge-unit.yml) |
12-
| [rag](./rag) | Retrieval-Augmented Generation pipeline targeting the MuSiQue dataset with Wikipedia retrieval. | **Unmaintained** — last verified with Agent-lightning v0.1.1 |
13-
| [search_r1](./search_r1) | Framework-free Search-R1 reinforcement learning training workflow with a retrieval backend. | **Unmaintained** — last verified with Agent-lightning v0.1.2 |
12+
| [rag](./rag) | Retrieval-Augmented Generation pipeline targeting the MuSiQue dataset with Wikipedia retrieval. | [![rag workflow status](https://github.com/microsoft/agent-lightning/actions/workflows/badge-rag.yml/badge.svg)](https://github.com/microsoft/agent-lightning/actions/workflows/examples-rag.yml) |
13+
| [search_r1](./search_r1) | Framework-free Search-R1 reinforcement learning training workflow with a retrieval backend. | **Last verified with Agent-lightning v0.1.2** |
1414
| [spider](./spider) | Text-to-SQL reinforcement learning training on the Spider dataset using LangGraph. | [![spider workflow status](https://github.com/microsoft/agent-lightning/actions/workflows/badge-spider.yml/badge.svg)](https://github.com/microsoft/agent-lightning/actions/workflows/examples-spider.yml) |
1515
| [tinker](./tinker) | Reinforcement learning with Tinker as the backend training service. | [![tinker workflow status](https://github.com/microsoft/agent-lightning/actions/workflows/badge-tinker.yml/badge.svg)](https://github.com/microsoft/agent-lightning/actions/workflows/examples-tinker.yml) |
1616
| [unsloth](./unsloth) | Supervised fine-tuning example powered by Unsloth with 4-bit quantization and LoRA. | [![unsloth workflow status](https://github.com/microsoft/agent-lightning/actions/workflows/badge-unsloth.yml/badge.svg)](https://github.com/microsoft/agent-lightning/actions/workflows/examples-unsloth.yml) |

examples/rag/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# RAG Agent Example
22

3+
[![rag workflow status](https://github.com/microsoft/agent-lightning/actions/workflows/examples-rag.yml/badge.svg)](https://github.com/microsoft/agent-lightning/actions/workflows/examples-rag.yml)
4+
35
This example demonstrates training a Retrieval-Augmented Generation (RAG) agent using Agent-Lightning with retrieval capabilities. The agent answers multi-hop questions from a tiny MuSiQue dataset by retrieving and reasoning over Wikipedia passages.
46

57
## Overview

0 commit comments

Comments
 (0)