You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: docs/community/contributing.md
+19-10Lines changed: 19 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,7 @@ Bonus points for examples that:
46
46
- 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.**
47
47
- 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.
48
48
- 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.
49
50
50
51
!!! warning "Please discuss first"
51
52
@@ -126,13 +127,13 @@ After `uv sync`, run commands via `uv run ...` (add `--no-sync` once the environ
126
127
Formatting and linting are enforced through [pre-commit](https://pre-commit.com/). Install once, then run before each push:
127
128
128
129
```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
131
132
```
132
133
133
134
Once installed, the hooks run automatically on every `git commit`. Running the pre-commit hooks locally keeps CI green and diffs manageable.
134
135
135
-
### 3. Branch From a Fresh `main`
136
+
### 3. Branch from Fresh `main` and Code
136
137
137
138
Start all work from the latest upstream state:
138
139
@@ -165,28 +166,36 @@ Use lowercase with hyphens, e.g., `feature/async-runner-hooks`.
165
166
166
167
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).
167
168
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.
- 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
+
168
177
### 4. Test and Validate
169
178
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.
171
180
172
181
**Full test suite**
173
182
174
183
```bash
175
-
uv run pytest -v
184
+
uv run --no-sync pytest -v
176
185
```
177
186
178
187
**Targeted tests**
179
188
180
189
```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
182
191
```
183
192
184
193
**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.
185
194
186
195
**Static analysis:**
187
196
188
197
```bash
189
-
uv run pyright
198
+
uv run --no-sync pyright
190
199
```
191
200
192
201
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
196
205
Keep API references under [docs/reference]({{ src("docs/reference/") }}) up to date. Doc-only changes should still build cleanly:
197
206
198
207
```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
201
210
```
202
211
203
212
`--strict` elevates warnings to errors so you catch issues before CI.
204
213
205
214
Before opening a PR, double-check the basics:
206
215
207
216
- 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).
209
218
- Execute the relevant commands from the test list above.
210
219
- Validate each affected example via its README instructions.
Copy file name to clipboardExpand all lines: examples/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,8 +9,8 @@ This catalog highlights the examples shipped with Agent-lightning.
9
9
|[calc_x](./calc_x)| VERL-powered math reasoning agent training that uses AutoGen with an MCP calculator tool. |[](https://github.com/microsoft/agent-lightning/actions/workflows/examples-calc-x.yml)|
10
10
|[claude_code](./claude_code)| Claude Code SWE-bench harness that records Agent-lightning traces across Anthropic, vLLM, and OpenAI-compatible backends. |[](https://github.com/microsoft/agent-lightning/actions/workflows/examples-claude-code.yml)|
11
11
|[minimal](./minimal)| Bite-sized programs that demonstrate how individual Agent-lightning building blocks behave in isolation. |[](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. |[](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**|
14
14
|[spider](./spider)| Text-to-SQL reinforcement learning training on the Spider dataset using LangGraph. |[](https://github.com/microsoft/agent-lightning/actions/workflows/examples-spider.yml)|
15
15
|[tinker](./tinker)| Reinforcement learning with Tinker as the backend training service. |[](https://github.com/microsoft/agent-lightning/actions/workflows/examples-tinker.yml)|
16
16
|[unsloth](./unsloth)| Supervised fine-tuning example powered by Unsloth with 4-bit quantization and LoRA. |[](https://github.com/microsoft/agent-lightning/actions/workflows/examples-unsloth.yml)|
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.
0 commit comments