Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,4 @@ cython_debug/
.cursorindexingignore

# Claude
.claude/*.local.json

# Dashboard generated files
agentlightning/dashboard/**/*.css
agentlightning/dashboard/**/*.js
agentlightning/dashboard/**/*.html
agentlightning/dashboard/**/*.svg
.claude/*.local.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to change this I think.

395 changes: 395 additions & 0 deletions docs/how-to/train-adk-agent.md

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion examples/apo/room_selector_apo.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ def main() -> None:
trainer = Trainer(
algorithm=algo,
# Increase the number of runners to run more rollouts in parallel
n_runners=8,
strategy={
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change?

"type": "shm",
"n_runners": 8,
"main_thread": "algorithm",
},
# APO algorithm needs a baseline
# Set it either here or in the algo
initial_resources={
Expand Down
8 changes: 8 additions & 0 deletions examples/google_adk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
vendor/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most of these ignores have been included in global gitignore. Please check,

.venv/
venv/
env/
ENV/
__pycache__/
*.py[cod]
.DS_Store
120 changes: 120 additions & 0 deletions examples/google_adk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# ADK Example

This example demonstrates training a Google ADK (Application Development Kit) agent using Agent-Lightning with reinforcement learning. The agent processes user instructions and generates ADK actions for Google applications. It's compatible with Agent-lightning v0.2 or later.

## Requirements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have decided to create a how-to tutorial, this README can be greatly simplified and only keeps necessarily installation and running guidance.


This example requires a single node with at least one 40GB GPU. Follow the [installation guide](../../docs/tutorials/installation.md) to install Agent-Lightning and VERL-related dependencies.

Additionally, install the ADK dependencies:

```bash
pip install "google-adk>=0.3.0" "fastapi" "uvicorn" "pytest"
```

Or use the local `pyproject.toml` in this directory:

```bash
cd examples/google_adk
uv sync
```

## Dataset

Detailed dataset preparation instructions are available in the [How to Train an ADK Agent](../../docs/how-to/train-adk-agent.md) guide.

## Included Files

| File/Directory | Description |
|----------------|-------------|
| `adk_agent.py` | ADK agent implementation using the v0.2 LitAgent API, wrapping ADK's agent orchestration capabilities |
| `train_adk.py` | Training script with support for CI modes and external store debugging |
| `prepare_dataset.py` | Dataset conversion utility for generating Parquet files from various formats |
| `adk_debug.py` | Sanity check script for testing the agent without training |

## Running Examples

### Training

Train the ADK agent using the training script:

```bash
cd examples/google_adk
python train_adk.py --train-file data/train.parquet --val-file data/test.parquet
```

The script supports several CLI options:

- `--train-file`: Path to training Parquet file (default: `data/train.parquet`)
- `--val-file`: Path to validation Parquet file (default: `data/test.parquet`)
- `--model`: Model name for the rollout LLM (default: from `OPENAI_MODEL` env var or `meta-llama/Meta-Llama-3-8B-Instruct`)
- `--endpoint`: OpenAI-compatible base URL (default: from `OPENAI_API_BASE` env var or `http://localhost:8000/v1`)
- `--ci`: Reduce workload for CI (smaller dataset slice, fewer runners)
- `--ci-fast`: Ultra-fast CI mode (tiny dataset slice, 1 runner)
- `--external-store-address`: Use an external LightningStore address for debugging (e.g., `http://localhost:4747`)
- `--wandb-project`: Weights & Biases project name (default: `agent-lightning-adk`)
- `--wandb-run-name`: Weights & Biases run name (optional)

**Example with CI mode:**

```bash
python train_adk.py --ci-fast --wandb-project my-project --wandb-run-name test-run
```

**Example with external store for debugging:**

```bash
python train_adk.py --external-store-address http://localhost:4747
```

### Debugging

To test the agent without training, use the sanity check script:

```bash
python adk_debug.py
```

You can customize the test with CLI options:

- `--file`: Path to Parquet file (default: `data/test.parquet`)
- `--index`: Row index to test (default: `0`)
- `--model`: Model name (default: from `OPENAI_MODEL` env var)
- `--endpoint`: API endpoint (default: from `OPENAI_API_BASE` env var or `http://localhost:8000/v1`)

**Example:**

```bash
python adk_debug.py --file data/train.parquet --index 0 --endpoint http://localhost:8000/v1 --model meta-llama/Meta-Llama-3-8B-Instruct
```

This runs a single rollout and prints the reward, helping you verify that the agent configuration, ADK orchestration, and dataset are correct before starting a full training run.

## Configuration

The agent expects an OpenAI-compatible API service. Configure your service endpoint and credentials using environment variables:

- `OPENAI_API_BASE`: Base URL for the API service
- `OPENAI_API_KEY`: API key (if required)
- `OPENAI_MODEL`: Default model name to use

If you're using vLLM locally, you typically don't need an API key:

```bash
export OPENAI_API_BASE=http://localhost:8000/v1
export OPENAI_MODEL=meta-llama/Meta-Llama-3-8B-Instruct
```

## Agent Implementation Details

The `LitAdkAgent` class implements the v0.2 LitAgent API:

- **Task Type**: `AdkTask` with `question`, `app_id`, `ground_truth`, and optional `meta` fields
- **LLM Resource**: Extracted from `resources["main_llm"]` (VERL convention)
- **Reward**: Returns a float reward based on action matching the ground truth (customize as needed)
- **Orchestration**: Wraps ADK's agent orchestration capabilities, similar to how `LitSQLAgent` wraps LangGraph workflows
- **Observability**: Leverages ADK's Cloud Trace integration for span visualization, showing how operations (LLM calls, tool executions) are organized within rollouts

ADK provides observability features that automatically capture spans for each operation, organizing them for visualization. This makes it easy to understand agent execution patterns, identify optimization opportunities, and debug issues. The spans can be organized as sequential, parallel, or nested structures, providing rich insights into agent behavior.

For a real integration, replace the placeholder action generation with actual ADK agent orchestration calls in the `rollout` method, enabling Cloud Trace integration for comprehensive observability.
Loading