Showing preview only (9,050K chars total). Download the full file or copy to clipboard to get everything.
Repository: microsoft/agent-lightning
Branch: main
Commit: c746af2f76be
Files: 546
Total size: 8.5 MB
Directory structure:
gitextract_mrw4kizu/
├── .dockerignore
├── .github/
│ └── workflows/
│ ├── backport.yml
│ ├── badge-apo.yml
│ ├── badge-azure.yml
│ ├── badge-calc-x.yml
│ ├── badge-chartqa.yml
│ ├── badge-claude-code.yml
│ ├── badge-compat.yml
│ ├── badge-examples.yml
│ ├── badge-latest.yml
│ ├── badge-rag.yml
│ ├── badge-spider.yml
│ ├── badge-tinker.yml
│ ├── badge-unit.yml
│ ├── badge-unsloth.yml
│ ├── benchmark.yml
│ ├── dashboard.yml
│ ├── docs.yml
│ ├── examples-apo.yml
│ ├── examples-azure.yml
│ ├── examples-calc-x.yml
│ ├── examples-chartqa.yml
│ ├── examples-claude-code.yml
│ ├── examples-compat.yml
│ ├── examples-rag.yml
│ ├── examples-spider.yml
│ ├── examples-tinker.yml
│ ├── examples-unsloth.yml
│ ├── issue-comment.yml
│ ├── playground.yml
│ ├── pypi-nightly.yml
│ ├── pypi-release.yml
│ ├── tests-full.yml
│ └── tests.yml
├── .gitignore
├── .pre-commit-config.yaml
├── .python-version
├── AGENTS.md
├── LICENSE
├── RAI_README.md
├── README.md
├── SECURITY.md
├── agentlightning/
│ ├── __init__.py
│ ├── adapter/
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── messages.py
│ │ └── triplet.py
│ ├── algorithm/
│ │ ├── __init__.py
│ │ ├── apo/
│ │ │ ├── __init__.py
│ │ │ ├── apo.py
│ │ │ └── prompts/
│ │ │ ├── apply_edit_variant01.poml
│ │ │ ├── apply_edit_variant02.poml
│ │ │ ├── text_gradient_variant01.poml
│ │ │ ├── text_gradient_variant02.poml
│ │ │ └── text_gradient_variant03.poml
│ │ ├── base.py
│ │ ├── decorator.py
│ │ ├── fast.py
│ │ ├── utils.py
│ │ └── verl/
│ │ ├── __init__.py
│ │ └── interface.py
│ ├── cli/
│ │ ├── __init__.py
│ │ ├── prometheus.py
│ │ ├── store.py
│ │ └── vllm.py
│ ├── client.py
│ ├── config.py
│ ├── emitter/
│ │ ├── __init__.py
│ │ ├── annotation.py
│ │ ├── exception.py
│ │ ├── message.py
│ │ ├── object.py
│ │ └── reward.py
│ ├── env_var.py
│ ├── execution/
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── client_server.py
│ │ ├── events.py
│ │ ├── inter_process.py
│ │ └── shared_memory.py
│ ├── instrumentation/
│ │ ├── __init__.py
│ │ ├── agentops.py
│ │ ├── agentops_langchain.py
│ │ ├── litellm.py
│ │ ├── vllm.py
│ │ └── weave.py
│ ├── litagent/
│ │ ├── __init__.py
│ │ ├── decorator.py
│ │ └── litagent.py
│ ├── llm_proxy.py
│ ├── logging.py
│ ├── reward.py
│ ├── runner/
│ │ ├── __init__.py
│ │ ├── agent.py
│ │ ├── base.py
│ │ └── legacy.py
│ ├── semconv.py
│ ├── server.py
│ ├── store/
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── client_server.py
│ │ ├── collection/
│ │ │ ├── __init__.py
│ │ │ ├── base.py
│ │ │ ├── memory.py
│ │ │ └── mongo.py
│ │ ├── collection_based.py
│ │ ├── memory.py
│ │ ├── mongo.py
│ │ ├── sqlite.py
│ │ ├── threading.py
│ │ └── utils.py
│ ├── tracer/
│ │ ├── __init__.py
│ │ ├── agentops.py
│ │ ├── base.py
│ │ ├── dummy.py
│ │ ├── otel.py
│ │ └── weave.py
│ ├── trainer/
│ │ ├── __init__.py
│ │ ├── init_utils.py
│ │ ├── legacy.py
│ │ ├── registry.py
│ │ └── trainer.py
│ ├── types/
│ │ ├── __init__.py
│ │ ├── core.py
│ │ ├── resources.py
│ │ └── tracer.py
│ ├── utils/
│ │ ├── __init__.py
│ │ ├── id.py
│ │ ├── metrics.py
│ │ ├── otel.py
│ │ ├── otlp.py
│ │ ├── server_launcher.py
│ │ └── system_snapshot.py
│ └── verl/
│ ├── __init__.py
│ ├── __main__.py
│ ├── async_server.py
│ ├── config.yaml
│ ├── daemon.py
│ ├── dataset.py
│ ├── entrypoint.py
│ └── trainer.py
├── contrib/
│ ├── .gitignore
│ ├── CODEOWNERS
│ ├── README.md
│ ├── agentlightning/
│ │ └── contrib/
│ │ ├── __init__.py
│ │ ├── adapter/
│ │ │ ├── __init__.py
│ │ │ ├── agentos.py
│ │ │ └── triplet_group.py
│ │ ├── agent/
│ │ │ └── env_agent.py
│ │ ├── algorithm/
│ │ │ └── env_verl/
│ │ │ ├── daemon.py
│ │ │ └── trainer.py
│ │ ├── reward/
│ │ │ ├── __init__.py
│ │ │ └── agentos.py
│ │ └── runner/
│ │ ├── __init__.py
│ │ └── agentos.py
│ └── recipes/
│ ├── agentos/
│ │ ├── README.md
│ │ └── demo_governed_training.py
│ ├── envs/
│ │ ├── README.md
│ │ ├── add_instruction.py
│ │ ├── config_env/
│ │ │ ├── alfworld.yaml
│ │ │ └── scienceworld.yaml
│ │ ├── config_verl/
│ │ │ ├── alfworld/
│ │ │ │ └── grpo.yaml
│ │ │ └── scienceworld/
│ │ │ └── grpo.yaml
│ │ ├── install_agl.sh
│ │ ├── prompt_builder.py
│ │ └── train_env_agent.py
│ ├── search_r1/
│ │ ├── README.md
│ │ ├── data_process.sh
│ │ ├── qa_em.py
│ │ ├── retrieval_launch.sh
│ │ ├── retrieval_server.py
│ │ ├── search_r1_agent.py
│ │ └── train_search_r1_agent.py
│ └── webshop/
│ ├── .gitignore
│ ├── Dockerfile
│ ├── Makefile
│ ├── README.md
│ ├── agl/
│ │ ├── __init__.py
│ │ ├── config.py
│ │ ├── generate_tasks.py
│ │ ├── requirements.txt
│ │ ├── run_training.py
│ │ ├── sample_tasks.json
│ │ ├── tasks.py
│ │ └── webshop_tasks.json
│ ├── aml/
│ │ ├── compute.yml
│ │ ├── jobs/
│ │ │ └── webshop-qwen.yml
│ │ └── run_webshop_aml.sh
│ ├── package.json
│ ├── scripts/
│ │ ├── headless-runner.ts
│ │ └── run_stack.sh
│ ├── server/
│ │ ├── .dockerignore
│ │ ├── requirements.txt
│ │ └── webshop_server.py
│ ├── src/
│ │ ├── agent/
│ │ │ ├── prompts.ts
│ │ │ └── webshop-agent.ts
│ │ ├── data/
│ │ │ └── sample-tasks.ts
│ │ ├── environment/
│ │ │ ├── index.ts
│ │ │ ├── types.ts
│ │ │ └── webshop-server.ts
│ │ └── utils/
│ │ └── agentlightning/
│ │ ├── index.ts
│ │ ├── otel.ts
│ │ ├── proxy-llm.ts
│ │ ├── store-client.ts
│ │ └── types.ts
│ ├── tests/
│ │ ├── __init__.py
│ │ ├── conftest.py
│ │ ├── test_span_adapter.py
│ │ └── test_store_integration.py
│ ├── tsconfig.json
│ └── tsup.config.ts
├── dashboard/
│ ├── .gitignore
│ ├── .prettierrc.mjs
│ ├── .storybook/
│ │ ├── constants.ts
│ │ ├── main.ts
│ │ ├── modes.ts
│ │ ├── preview.tsx
│ │ └── vitest.setup.ts
│ ├── .stylelintignore
│ ├── .stylelintrc.json
│ ├── README.md
│ ├── eslint.config.js
│ ├── package.json
│ ├── postcss.config.cjs
│ ├── public/
│ │ ├── index.html
│ │ └── main.tsx
│ ├── src/
│ │ ├── App.tsx
│ │ ├── Router.tsx
│ │ ├── components/
│ │ │ ├── AppAlertBanner.story.tsx
│ │ │ ├── AppAlertBanner.tsx
│ │ │ ├── AppDrawer.component.tsx
│ │ │ ├── AppDrawer.story.tsx
│ │ │ ├── ResourcesTable.component.tsx
│ │ │ ├── ResourcesTable.story.tsx
│ │ │ ├── ResourcesTree.component.tsx
│ │ │ ├── ResourcesTree.story.tsx
│ │ │ ├── RolloutTable.component.tsx
│ │ │ ├── RolloutTable.story.tsx
│ │ │ ├── TracesTable.component.tsx
│ │ │ ├── TracesTable.story.tsx
│ │ │ ├── WorkersTable.component.tsx
│ │ │ └── WorkersTable.story.tsx
│ │ ├── cssVariableResolver.ts
│ │ ├── features/
│ │ │ ├── config/
│ │ │ │ ├── index.ts
│ │ │ │ ├── selectors.ts
│ │ │ │ └── slice.ts
│ │ │ ├── resources/
│ │ │ │ ├── index.ts
│ │ │ │ ├── resources.test.ts
│ │ │ │ ├── selectors.ts
│ │ │ │ └── slice.ts
│ │ │ ├── rollouts/
│ │ │ │ ├── api.ts
│ │ │ │ ├── index.ts
│ │ │ │ ├── rollouts.test.ts
│ │ │ │ ├── selectors.ts
│ │ │ │ └── slice.ts
│ │ │ ├── traces/
│ │ │ │ ├── index.ts
│ │ │ │ ├── selectors.ts
│ │ │ │ ├── slice.ts
│ │ │ │ └── traces.test.ts
│ │ │ ├── ui/
│ │ │ │ ├── alert/
│ │ │ │ │ ├── index.ts
│ │ │ │ │ ├── selectors.ts
│ │ │ │ │ └── slice.ts
│ │ │ │ └── drawer/
│ │ │ │ ├── index.ts
│ │ │ │ ├── selectors.ts
│ │ │ │ └── slice.ts
│ │ │ └── workers/
│ │ │ ├── index.ts
│ │ │ ├── selectors.ts
│ │ │ ├── slice.ts
│ │ │ └── workers.test.ts
│ │ ├── layouts/
│ │ │ ├── AppLayout.story.tsx
│ │ │ ├── AppLayout.tsx
│ │ │ └── helper.ts
│ │ ├── main.tsx
│ │ ├── pages/
│ │ │ ├── Resources.page.story.tsx
│ │ │ ├── Resources.page.tsx
│ │ │ ├── Rollouts.page.story.tsx
│ │ │ ├── Rollouts.page.tsx
│ │ │ ├── Settings.page.story.tsx
│ │ │ ├── Settings.page.tsx
│ │ │ ├── Traces.page.story.tsx
│ │ │ ├── Traces.page.tsx
│ │ │ ├── Workers.page.story.tsx
│ │ │ └── Workers.page.tsx
│ │ ├── store/
│ │ │ ├── hooks.ts
│ │ │ └── index.ts
│ │ ├── styles/
│ │ │ ├── app.css
│ │ │ └── theme.css
│ │ ├── theme.ts
│ │ ├── types.ts
│ │ ├── utils/
│ │ │ ├── error.ts
│ │ │ ├── format.ts
│ │ │ ├── mock.test.ts
│ │ │ ├── mock.ts
│ │ │ └── table.ts
│ │ └── vite-env.d.ts
│ ├── static/
│ │ └── mockServiceWorker.js
│ ├── test-utils/
│ │ ├── index.ts
│ │ ├── python-server.py
│ │ ├── render.tsx
│ │ └── server.ts
│ ├── tsconfig.json
│ ├── vite.config.mjs
│ ├── vitest.global-setup.mjs
│ ├── vitest.setup.mjs
│ └── vitest.shims.d.ts
├── docker/
│ ├── Dockerfile.dev
│ ├── compose.grafana.yml
│ ├── compose.mongo.yml
│ ├── compose.prometheus-memory-store.yml
│ ├── compose.prometheus-mongo-store.yml
│ ├── compose.store.yml
│ ├── grafana/
│ │ ├── dashboard-provider.yml
│ │ ├── dashboards/
│ │ │ ├── 1860_rev42.json
│ │ │ ├── 20192_rev1.json
│ │ │ └── agentlightning.json
│ │ └── datasource.yml
│ ├── prometheus/
│ │ ├── prometheus.base.yml
│ │ └── prometheus.mongo.yml
│ └── setup.sh
├── docs/
│ ├── algorithm-zoo/
│ │ ├── apo.md
│ │ ├── index.md
│ │ └── verl.md
│ ├── assets/
│ │ └── store-openapi.json
│ ├── changelog.md
│ ├── community/
│ │ ├── contributing.md
│ │ └── maintainers.md
│ ├── deep-dive/
│ │ ├── birds-eye-view.md
│ │ ├── serving-llm.md
│ │ └── store.md
│ ├── how-to/
│ │ ├── examples-catalog.md
│ │ ├── train-first-agent.md
│ │ ├── train-sql-agent.md
│ │ ├── unsloth-sft.md
│ │ └── write-first-algorithm.md
│ ├── index.md
│ ├── javascripts/
│ │ ├── charts.js
│ │ ├── katex.js
│ │ └── move-source-file.js
│ ├── macros/
│ │ └── source_links.py
│ ├── overrides/
│ │ ├── main.html
│ │ └── partials/
│ │ └── content.html
│ ├── reference/
│ │ ├── agent.md
│ │ ├── algorithm.md
│ │ ├── cli.md
│ │ ├── instrumentation.md
│ │ ├── internal.md
│ │ ├── restful.md
│ │ ├── runner.md
│ │ ├── semconv.md
│ │ ├── store.md
│ │ ├── trainer.md
│ │ ├── types.md
│ │ └── utilities.md
│ ├── stylesheets/
│ │ └── extra.css
│ └── tutorials/
│ ├── debug.md
│ ├── emitter.md
│ ├── installation.md
│ ├── parallelize.md
│ ├── traces.md
│ └── write-agents.md
├── examples/
│ ├── .gitignore
│ ├── README.md
│ ├── apo/
│ │ ├── README.md
│ │ ├── apo_custom_algorithm.py
│ │ ├── apo_custom_algorithm_trainer.py
│ │ ├── apo_debug.py
│ │ ├── legacy_apo_client.py
│ │ ├── legacy_apo_server.py
│ │ ├── room_selector.py
│ │ ├── room_selector_apo.py
│ │ └── room_tasks.jsonl
│ ├── azure/
│ │ ├── README.md
│ │ ├── aoai_finetune.py
│ │ ├── capital_agent.py
│ │ ├── capital_samples.csv
│ │ ├── tests/
│ │ │ └── test_deployment.py
│ │ └── train_capital_agent.py
│ ├── calc_x/
│ │ ├── README.md
│ │ ├── calc_agent.py
│ │ ├── eval_utils.py
│ │ ├── legacy_calc_agent.py
│ │ ├── legacy_calc_agent_debug.py
│ │ ├── legacy_train.sh
│ │ ├── tests/
│ │ │ ├── test_agentops.py
│ │ │ └── test_mcp_calculator.py
│ │ └── train_calc_agent.py
│ ├── chartqa/
│ │ ├── README.md
│ │ ├── chartqa_agent.py
│ │ ├── debug_chartqa_agent.py
│ │ ├── env_var.py
│ │ ├── multimodal_utils.py
│ │ ├── prepare_data.py
│ │ ├── prompts.py
│ │ └── train_chartqa_agent.py
│ ├── claude_code/
│ │ ├── README.md
│ │ ├── claude_code_agent.py
│ │ ├── claude_code_controller.py
│ │ ├── extended_adapter.py
│ │ ├── swebench_samples.jsonl
│ │ ├── swebench_utils/
│ │ │ ├── __init__.py
│ │ │ ├── docker_runtime.py
│ │ │ ├── evaluation.py
│ │ │ └── logging.py
│ │ └── templates/
│ │ ├── handle_hook.template.sh
│ │ └── settings.template.json
│ ├── minimal/
│ │ ├── README.md
│ │ ├── llm_proxy.py
│ │ ├── vllm_server.py
│ │ ├── write_metrics.py
│ │ └── write_traces.py
│ ├── rag/
│ │ ├── README.md
│ │ ├── metric_utils.py
│ │ ├── rag_agent.py
│ │ ├── train_rag.py
│ │ └── wiki_retriever_mcp.py
│ ├── spider/
│ │ ├── README.md
│ │ ├── spider_eval/
│ │ │ ├── __init__.py
│ │ │ ├── async_utils.py
│ │ │ ├── convert_dataset.py
│ │ │ ├── evaluation.py
│ │ │ ├── exec_eval.py
│ │ │ ├── parse.py
│ │ │ └── process_sql.py
│ │ ├── sql_agent.py
│ │ └── train_sql_agent.py
│ ├── tinker/
│ │ ├── README.md
│ │ ├── agl_tinker/
│ │ │ ├── __init__.py
│ │ │ ├── algo.py
│ │ │ ├── env.py
│ │ │ ├── llm.py
│ │ │ ├── rollout.py
│ │ │ └── train.py
│ │ ├── hello.py
│ │ ├── q20_agent.py
│ │ ├── q20_evaluate.py
│ │ ├── q20_nouns.csv
│ │ ├── q20_train.py
│ │ └── tests/
│ │ ├── __init__.py
│ │ └── test_tinker_llm.py
│ └── unsloth/
│ ├── README.md
│ ├── data_gsmhard.jsonl
│ ├── math_agent.py
│ ├── sft_algorithm.py
│ ├── sft_allinone.py
│ ├── sft_rollout_runners.py
│ └── unsloth_helper.py
├── mkdocs.yml
├── pyproject.toml
├── pyrightconfig.fast.json
├── pyrightconfig.json
├── scripts/
│ ├── badge_aggregation.js
│ ├── base.Dockerfile
│ ├── build_vm_image.sh
│ ├── bump_version.sh
│ ├── check_headers.py
│ ├── cleanup.sh
│ ├── cleanup_aoai.py
│ ├── export_openapi.py
│ ├── litellm_ci.yaml
│ ├── litellm_run.sh
│ ├── litellm_sanity_check.py
│ ├── mongodb_docker_run.sh
│ ├── mongodb_init_rs_host.js
│ ├── mongodb_init_rs_profiling.js
│ ├── restart_ray.sh
│ ├── setup_latest.sh
│ ├── setup_latest_gpu.sh
│ ├── setup_stable.sh
│ ├── setup_stable_gpu.sh
│ ├── setup_type_checking.sh
│ ├── validate_example_wandb.py
│ └── wandb_download_result.py
└── tests/
├── __init__.py
├── adapter/
│ ├── __init__.py
│ ├── test_llm_proxy.py
│ ├── test_messages_adapter.py
│ └── test_triplet_trace_tree.py
├── algorithm/
│ ├── __init__.py
│ ├── test_apo.py
│ ├── test_baseline.py
│ ├── test_decorator.py
│ └── test_utils.py
├── assets/
│ └── prompt_caches.jsonl
├── benchmark/
│ ├── analysis.py
│ ├── benchmark_store.py
│ ├── collection_benchmark.py
│ ├── micro_benchmark.py
│ └── utils.py
├── common/
│ ├── __init__.py
│ ├── network.py
│ ├── prometheus_stub.py
│ ├── tracer.py
│ └── vllm.py
├── emitter/
│ ├── __init__.py
│ ├── test_annotation.py
│ ├── test_exception.py
│ ├── test_message.py
│ ├── test_object.py
│ ├── test_operation.py
│ └── test_reward.py
├── execution/
│ ├── __init__.py
│ ├── test_client_server.py
│ └── test_shared_memory.py
├── instrumentation/
│ └── test_agentops.py
├── litagent/
│ ├── __init__.py
│ ├── test_decorator.py
│ └── test_resources.py
├── llm_proxy/
│ ├── __init__.py
│ ├── test_llm_proxy_cpu.py
│ ├── test_llm_proxy_gpu.py
│ └── test_stream.py
├── runner/
│ ├── __init__.py
│ ├── test_agent_integration.py
│ ├── test_agent_runner.py
│ └── test_runner_context.py
├── store/
│ ├── __init__.py
│ ├── conftest.py
│ ├── dummy_store.py
│ ├── test_client_server.py
│ ├── test_collection.py
│ ├── test_core.py
│ ├── test_restful.py
│ ├── test_threading.py
│ └── test_utils.py
├── test_client.py
├── test_config.py
├── test_env_var.py
├── test_logging.py
├── tracer/
│ ├── __init__.py
│ ├── test_agentops.py
│ ├── test_dummy.py
│ ├── test_integration.py
│ ├── test_otel.py
│ └── test_weave.py
├── trainer/
│ ├── __init__.py
│ ├── sample_components.py
│ ├── test_init_utils.py
│ ├── test_trainer_dev.py
│ └── test_trainer_init.py
├── types/
│ └── __init__.py
└── utils/
├── __init__.py
├── test_metrics.py
├── test_otel.py
├── test_otlp.py
├── test_server_launcher.py
└── test_system_snapshot.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .dockerignore
================================================
.venv
**/.venv
__pycache__
.git
.gitignore
**/node_modules
dist
build
.env
docker
.pytest_cache
.vscode
**/*.log
examples/**/data
================================================
FILE: .github/workflows/backport.yml
================================================
name: Backport Merged Pull Request
on:
pull_request_target:
types: [closed]
permissions:
contents: write
issues: write
pull-requests: write
# NOTE:
# Microsoft requires rotating BOT_PAT every 3 months.
# Log onto agent-lightning-bot account and rotate the PAT if needed.
jobs:
backport:
name: Backport pull request
runs-on: ubuntu-latest
# Don't run on closed unmerged pull requests
if: github.event.pull_request.merged
steps:
- uses: actions/checkout@v6
- name: Create backport pull requests
uses: korthout/backport-action@v3
with:
branch_name: 'backport/${pull_number}/${target_branch}'
label_pattern: ^(stable/[^ ]+)$
github_token: ${{ secrets.BOT_PAT }}
add_labels: backport
add_author_as_assignee: true
git_committer_name: agent-lightning-bot
# This email address is not monitored.
git_committer_email: agl.msft@outlook.com
================================================
FILE: .github/workflows/badge-apo.yml
================================================
name: Badge - APO
on:
workflow_run:
workflows:
- Examples - APO
types: [completed]
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
badge:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const badgeAggregation = require('./scripts/badge_aggregation.js');
const dependencies = [
{ workflow: 'examples-apo.yml', label: 'apo', variants: ['legacy', 'stable'] },
];
await badgeAggregation({ github, context, core, dependencies });
================================================
FILE: .github/workflows/badge-azure.yml
================================================
name: Badge - Azure
on:
workflow_run:
workflows:
- Examples - Azure
types: [completed]
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
badge:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const badgeAggregation = require('./scripts/badge_aggregation.js');
const dependencies = [
{ workflow: 'examples-azure.yml', label: 'azure', variants: ['stable'] },
];
await badgeAggregation({ github, context, core, dependencies });
================================================
FILE: .github/workflows/badge-calc-x.yml
================================================
name: Badge - Calc-X
on:
workflow_run:
workflows:
- Examples - Calc-X
types: [completed]
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
badge:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const badgeAggregation = require('./scripts/badge_aggregation.js');
const dependencies = [
{ workflow: 'examples-calc-x.yml', label: 'calc-x', variants: ['legacy', 'stable'] },
];
await badgeAggregation({ github, context, core, dependencies });
================================================
FILE: .github/workflows/badge-chartqa.yml
================================================
name: Badge - ChartQA
on:
workflow_run:
workflows:
- Examples - ChartQA
types: [completed]
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
badge:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const badgeAggregation = require('./scripts/badge_aggregation.js');
const dependencies = [
{ workflow: 'examples-chartqa.yml', label: 'chartqa', variants: ['stable'] },
];
await badgeAggregation({ github, context, core, dependencies });
================================================
FILE: .github/workflows/badge-claude-code.yml
================================================
name: Badge - Claude Code
on:
workflow_run:
workflows:
- Examples - Claude Code
types: [completed]
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
badge:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const badgeAggregation = require('./scripts/badge_aggregation.js');
const dependencies = [
{ workflow: 'examples-claude-code.yml', label: 'claude-code', variants: ['stable'] },
];
await badgeAggregation({ github, context, core, dependencies });
================================================
FILE: .github/workflows/badge-compat.yml
================================================
name: Badge - Compatibility
on:
workflow_run:
workflows:
- Examples - Backward Compatibility
types: [completed]
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
badge:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const badgeAggregation = require('./scripts/badge_aggregation.js');
const dependencies = [
{ workflow: 'examples-compat.yml', label: 'examples-compat', variants: ['legacy', 'stable'] },
];
await badgeAggregation({ github, context, core, dependencies });
================================================
FILE: .github/workflows/badge-examples.yml
================================================
name: Badge - Examples
on:
workflow_run:
workflows:
- Examples - Calc-X
- Examples - Spider
- Examples - APO
- Examples - Unsloth
- Examples - Tinker
- Examples - Azure
- Examples - Claude Code
- Examples - RAG
- Examples - ChartQA
types: [completed]
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
badge:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const badgeAggregation = require('./scripts/badge_aggregation.js');
const dependencies = [
{ workflow: 'examples-calc-x.yml', label: 'examples-calc-x.stable', variants: ['stable'] },
{ workflow: 'examples-spider.yml', label: 'examples-spider.stable', variants: ['stable'] },
{ workflow: 'examples-apo.yml', label: 'examples-apo.stable', variants: ['stable'] },
{ workflow: 'examples-unsloth.yml', label: 'examples-unsloth.stable', variants: ['stable'] },
{ workflow: 'examples-tinker.yml', label: 'examples-tinker.stable', variants: ['stable'] },
{ workflow: 'examples-azure.yml', label: 'examples-azure.stable', variants: ['stable'] },
{ workflow: 'examples-claude-code.yml', label: 'examples-claude-code.stable', variants: ['stable'] },
{ workflow: 'examples-rag.yml', label: 'examples-rag.stable', variants: ['stable'] },
{ workflow: 'examples-chartqa.yml', label: 'examples-chartqa.stable', variants: ['stable'] },
];
await badgeAggregation({ github, context, core, dependencies });
================================================
FILE: .github/workflows/badge-latest.yml
================================================
name: Badge - Latest
on:
workflow_run:
workflows:
- Examples - Calc-X
- Examples - Spider
- Examples - APO
- Examples - Unsloth
- Examples - RAG
- Examples - Claude Code
- GPU Test
types: [completed]
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
badge:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const badgeAggregation = require('./scripts/badge_aggregation.js');
const dependencies = [
{ workflow: 'examples-calc-x.yml', label: 'calc-x.latest', variants: ['latest'] },
{ workflow: 'examples-spider.yml', label: 'spider.latest', variants: ['latest'] },
{ workflow: 'examples-apo.yml', label: 'apo.latest', variants: ['latest'] },
{ workflow: 'examples-unsloth.yml', label: 'unsloth.latest', variants: ['latest'] },
{ workflow: 'examples-claude-code.yml', label: 'claude-code.latest', variants: ['latest'] },
{ workflow: 'examples-rag.yml', label: 'rag.latest', variants: ['latest'] },
{ workflow: 'tests-full.yml', label: 'tests-full.latest', variants: ['latest'] },
];
await badgeAggregation({ github, context, core, dependencies });
================================================
FILE: .github/workflows/badge-rag.yml
================================================
name: Badge - RAG
on:
workflow_run:
workflows:
- Examples - RAG
types: [completed]
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
badge:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const badgeAggregation = require('./scripts/badge_aggregation.js');
const dependencies = [
{ workflow: 'examples-rag.yml', label: 'rag', variants: ['legacy', 'stable'] },
];
await badgeAggregation({ github, context, core, dependencies });
================================================
FILE: .github/workflows/badge-spider.yml
================================================
name: Badge - Spider
on:
workflow_run:
workflows:
- Examples - Spider
types: [completed]
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
badge:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const badgeAggregation = require('./scripts/badge_aggregation.js');
const dependencies = [
{ workflow: 'examples-spider.yml', label: 'spider', variants: ['stable'] },
];
await badgeAggregation({ github, context, core, dependencies });
================================================
FILE: .github/workflows/badge-tinker.yml
================================================
name: Badge - Tinker
on:
workflow_run:
workflows:
- Examples - Tinker
types: [completed]
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
badge:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const badgeAggregation = require('./scripts/badge_aggregation.js');
const dependencies = [
{ workflow: 'examples-tinker.yml', label: 'tinker', variants: ['stable'] },
];
await badgeAggregation({ github, context, core, dependencies });
================================================
FILE: .github/workflows/badge-unit.yml
================================================
name: Badge - Unit Test
on:
workflow_run:
workflows:
- CPU Test
- GPU Test
types: [completed]
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
badge:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const badgeAggregation = require('./scripts/badge_aggregation.js');
const dependencies = [
{ workflow: 'tests-full.yml', label: 'tests-full', variants: ['legacy', 'stable'] },
{ workflow: 'tests.yml', label: 'tests', variants: ['legacy', 'stable', 'Lint', 'documentation', 'JavaScript'] },
];
await badgeAggregation({ github, context, core, dependencies });
================================================
FILE: .github/workflows/badge-unsloth.yml
================================================
name: Badge - Unsloth
on:
workflow_run:
workflows:
- Examples - Unsloth
types: [completed]
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
badge:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const badgeAggregation = require('./scripts/badge_aggregation.js');
const dependencies = [
{ workflow: 'examples-unsloth.yml', label: 'examples-unsloth.stable', variants: ['stable'] },
];
await badgeAggregation({ github, context, core, dependencies });
================================================
FILE: .github/workflows/benchmark.yml
================================================
name: Benchmark
permissions:
contents: read
on:
workflow_dispatch:
schedule:
# Every Monday and Thursday at 3 AM UTC+8
- cron: '0 19 * * 0,3'
jobs:
benchmark:
name: ${{ matrix.workload.kind }} (${{ matrix.backend.id }}, ${{ matrix.workload.display }})
runs-on: ${{ matrix.workload.runner }}
timeout-minutes: ${{ matrix.workload.timeout }}
strategy:
fail-fast: false
matrix:
backend:
- id: memory
compose_file: compose.prometheus-memory-store.yml
- id: mongo
compose_file: compose.prometheus-mongo-store.yml
workload:
- id: scenario-minimal-scale
display: Minimal production scale
kind: scenario
store_workers: 4
runner:
- self-hosted
- 1ES.Pool=agl-runner-cpu
timeout: 45
args: >-
--mode batch
--total-tasks 4096
--batch-size 256
--n-runners 32
--max-rounds 6
--sleep-seconds 0.5
- id: scenario-medium-scale
display: Medium production scale
kind: scenario
store_workers: 16
runner:
- self-hosted
- 1ES.Pool=agl-runner-cpu
timeout: 45
args: >-
--mode batch
--total-tasks 10000
--batch-size 1000
--n-runners 100
--max-rounds 10
--sleep-seconds 0.1
- id: scenario-midhigh-scale
display: Mid-high production scale
kind: scenario
store_workers: 24
runner:
- self-hosted
- 1ES.Pool=agl-runner-cpu
timeout: 60
args: >-
--mode batch
--total-tasks 20000
--batch-size 2048
--n-runners 300
--max-rounds 6
--sleep-seconds 0.1
- id: scenario-large-batch
display: Large batch waves
kind: scenario
store_workers: 96
runner:
- self-hosted
- 1ES.Pool=agl-runner-cpu-high
timeout: 120
args: >-
--mode batch
--total-tasks 50000
--batch-size 8192
--n-runners 1000
--max-rounds 3
--sleep-seconds 0.1
- id: scenario-long-queues
display: Long rollout queues
kind: scenario
store_workers: 48
runner:
- self-hosted
- 1ES.Pool=agl-runner-cpu
timeout: 120
args: >-
--mode batch_partial
--total-tasks 50000
--batch-size 1024
--n-runners 256
--remaining-tasks 4096
--max-rounds 4
--sleep-seconds 0.1
- id: scenario-high-concurrency
display: High-throughput concurrent requests
kind: scenario
store_workers: 96
runner:
- self-hosted
- 1ES.Pool=agl-runner-cpu-high
timeout: 120
args: >-
--mode single
--total-tasks 50000
--concurrency 2048
--n-runners 256
--max-rounds 2
--sleep-seconds 0.1
- id: scenario-heavy-traces
display: Heavy rollouts with deep traces
kind: scenario
store_workers: 96
runner:
- self-hosted
- 1ES.Pool=agl-runner-cpu-high
timeout: 60
args: >-
--mode batch_partial
--total-tasks 10000
--batch-size 1024
--remaining-tasks 256
--n-runners 512
--max-rounds 20
--sleep-seconds 1.0
- id: micro-worker
display: Update worker
kind: micro
store_workers: 8
runner: ubuntu-latest
timeout: 30
cli: worker
- id: micro-dequeue-empty
display: Dequeue empty
kind: micro
store_workers: 8
runner: ubuntu-latest
timeout: 30
cli: dequeue-empty
- id: micro-rollout
display: Rollout + span
kind: micro
store_workers: 8
runner: ubuntu-latest
timeout: 30
cli: rollout
- id: micro-dequeue-update-attempt
display: Dequeue + update attempt
kind: micro
store_workers: 8
runner: ubuntu-latest
timeout: 30
cli: dequeue-update-attempt
- id: micro-dequeue-only
display: Dequeue only
kind: micro
store_workers: 8
runner: ubuntu-latest
timeout: 30
cli: dequeue-only
- id: micro-metrics
display: Multi-metric fan-out
kind: micro
store_workers: 8
runner: ubuntu-latest
timeout: 15
cli: metrics
env:
PYTHONUNBUFFERED: "1"
STORE_URL: http://localhost:4747
STORE_API_URL: http://localhost:4747/v1/agl
PROM_URL: http://localhost:9090
GITHUB_ACTIONS_TIMEOUT_MINUTES: ${{ matrix.workload.timeout }}
WORKLOAD_KIND: ${{ matrix.workload.kind }}
WORKLOAD_ID: ${{ matrix.workload.id }}
BACKEND_ID: ${{ matrix.backend.id }}
ARTIFACT_DIR: ${{ format('artifacts/{0}-{1}', matrix.workload.id, matrix.backend.id) }}
COMPOSE_FILE: ${{ matrix.backend.compose_file }}
AGL_STORE_N_WORKERS: ${{ matrix.workload.store_workers }}
ANALYSIS_FILE: ${{ format('analysis-{0}.log', matrix.workload.id) }}
SUMMARY_FILE: ${{ format('summary-{0}.log', matrix.workload.id) }}
PROM_ARCHIVE_BASENAME: ${{ format('prometheus-{0}-{1}', matrix.workload.id, matrix.backend.id) }}
ARTIFACT_NAME: ${{ format('{0}-{1}', matrix.workload.id, matrix.backend.id) }}
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: '3.12'
- name: Sync dependencies
run: uv sync --frozen --extra mongo --group core-stable --group dev
- name: Check disk space
run: df -h
- name: Reset benchmark data directories
run: |
set -euo pipefail
cd docker
rm -rf data
bash setup.sh
- name: Launch ${{ matrix.backend.id }} Prometheus stack
run: |
set -euo pipefail
cd docker
docker compose -f "$COMPOSE_FILE" down -v || true
docker compose -f "$COMPOSE_FILE" up -d --quiet-pull
- name: Wait for store readiness
run: |
set -euo pipefail
for attempt in {1..60}; do
if curl -fsS "$STORE_API_URL/health" >/dev/null 2>&1; then
sleep 1
curl -fsS "$STORE_API_URL/rollouts" # Warm up the scraper
sleep 15 # Allow some time for the baseline metrics to be established
exit 0
fi
sleep 1
done
echo "Store did not become ready in time" >&2
# show logs for debugging
cd docker && docker compose -f "$COMPOSE_FILE" logs app
exit 1
- name: Prepare artifact directory
run: mkdir -p "$ARTIFACT_DIR"
- name: Record workload start
run: echo "BENCHMARK_START=$(date -u +%FT%TZ)" >> "$GITHUB_ENV"
- name: (Scenario) Run ${{ matrix.workload.display }} workload
if: ${{ matrix.workload.kind == 'scenario' }}
run: |
set -euo pipefail
uv run --locked --no-sync python -m tests.benchmark.benchmark_store \
--store-url "$STORE_URL" \
${{ matrix.workload.args }}
- name: (Micro) Run ${{ matrix.workload.display }}
if: ${{ matrix.workload.kind == 'micro' }}
run: |
set -euo pipefail
mkdir -p "$ARTIFACT_DIR"
uv run --locked --no-sync python -m tests.benchmark.micro_benchmark \
--store-url "$STORE_URL" \
--summary-file "$ARTIFACT_DIR/$SUMMARY_FILE" \
"${{ matrix.workload.cli }}" | tee "$ARTIFACT_DIR/${{ matrix.workload.id }}.txt"
- name: Record workload end
if: ${{ always() }}
run: echo "BENCHMARK_END=$(date -u +%FT%TZ)" >> "$GITHUB_ENV"
- name: Show micro benchmark summary
if: ${{ always() && matrix.workload.kind == 'micro' }}
run: |
set -euo pipefail
summary_file="$ARTIFACT_DIR/$SUMMARY_FILE"
if [ -f "$summary_file" ]; then
echo "Micro benchmark summary ($WORKLOAD_ID/$BACKEND_ID):"
cat "$summary_file"
else
echo "Summary file not found: $summary_file"
fi
- name: Run workload analysis
if: ${{ always() }}
run: |
set -euo pipefail
mkdir -p "$ARTIFACT_DIR"
if [ -z "${BENCHMARK_START:-}" ] || [ -z "${BENCHMARK_END:-}" ]; then
echo "Analysis skipped: benchmark window not recorded." > "$ARTIFACT_DIR/$ANALYSIS_FILE"
exit 1
fi
uv run --locked --no-sync python -m tests.benchmark.analysis \
--prom-url "$PROM_URL" \
--store-url "$STORE_API_URL" \
--start "$BENCHMARK_START" \
--end "$BENCHMARK_END" \
| tee "$ARTIFACT_DIR/$ANALYSIS_FILE"
- name: Collect docker logs
if: ${{ always() }}
run: |
set -euo pipefail
mkdir -p "$ARTIFACT_DIR"
cd docker
readarray -t services < <(docker compose -f "$COMPOSE_FILE" config --services)
if [ "${#services[@]}" -eq 0 ]; then
echo "No services defined in compose file."
exit 0
fi
for service in "${services[@]}"; do
docker compose -f "$COMPOSE_FILE" logs "$service" > "../$ARTIFACT_DIR/docker-${service}-${WORKLOAD_ID}-${BACKEND_ID}.log" || true
done
- name: Stop ${{ matrix.backend.id }} Prometheus stack
if: ${{ always() }}
run: |
set -euo pipefail
cd docker
docker compose -f "$COMPOSE_FILE" down -v || true
- name: Archive Prometheus metrics
if: ${{ always() }}
run: |
set -euo pipefail
mkdir -p "$ARTIFACT_DIR"
if [ -d docker/data/prometheus ]; then
tar -C docker/data -czf "$ARTIFACT_DIR/${PROM_ARCHIVE_BASENAME}.tar.gz" prometheus
fi
- name: Upload workload artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v6
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}
if-no-files-found: error
collection-benchmarks:
name: collection (${{ matrix.backend.id }}, ${{ matrix.workload.id }})
runs-on: ${{ matrix.backend.runner }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
backend:
- id: memory
needs_mongo: false
runner: ubuntu-latest
- id: mongo
needs_mongo: true
runner: ubuntu-latest
workload:
- id: high-insert
total_tasks: 50000
concurrency: 2048
type: insert
- id: medium-insert
total_tasks: 50000
concurrency: 128
type: insert
- id: low-insert
total_tasks: 50000
concurrency: 4
type: insert
- id: high-dequeue
total_tasks: 50000
concurrency: 2048
type: dequeue
- id: medium-dequeue
total_tasks: 50000
concurrency: 128
type: dequeue
- id: low-dequeue
total_tasks: 50000
concurrency: 4
type: dequeue
env:
ARTIFACT_DIR: ${{ format('artifacts/{0}-{1}', matrix.backend.id, matrix.workload.id) }}
SUMMARY_FILE: ${{ format('artifacts/{0}-{1}/summary-{0}-{1}.jsonl', matrix.backend.id, matrix.workload.id) }}
ARTIFACT_NAME: ${{ format('collections-{0}-{1}', matrix.backend.id, matrix.workload.id) }}
MONGO_URI: mongodb://localhost:27017/?replicaSet=rs0
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: '3.12'
- name: Sync dependencies
run: uv sync --frozen --extra mongo --group core-stable --group dev
- name: Launch MongoDB
if: ${{ matrix.backend.needs_mongo }}
run: |
set -euo pipefail
cd docker
docker compose -f compose.mongo.yml down -v || true
docker compose -f compose.mongo.yml up -d --quiet-pull
for attempt in {1..60}; do
if docker compose -f compose.mongo.yml exec -T mongo mongosh --quiet --eval 'db.runCommand({ping:1})' >/dev/null 2>&1; then
exit 0
fi
sleep 2
done
echo "MongoDB did not become ready in time" >&2
docker compose -f compose.mongo.yml logs mongo
exit 1
- name: Run collection benchmark
run: |
set -euo pipefail
mkdir -p "$ARTIFACT_DIR"
echo "Running collection benchmark (backend=${{ matrix.backend.id }}, workload=${{ matrix.workload.id }})"
uv run --locked --no-sync python -m tests.benchmark.collection_benchmark \
"${{ matrix.workload.type }}" \
--backend "${{ matrix.backend.id }}" \
--total-tasks "${{ matrix.workload.total_tasks }}" \
--concurrency "${{ matrix.workload.concurrency }}" \
--task-prefix "${{ matrix.backend.id }}-${{ matrix.workload.id }}" \
--summary-file "$SUMMARY_FILE" \
--mongo-uri "$MONGO_URI" \
--mongo-database agentlightning_collection_bench
- name: Show collection benchmark summary
if: ${{ always() }}
run: |
set -euo pipefail
if [ -f "$SUMMARY_FILE" ]; then
echo "Collection benchmark summary (${{ matrix.backend.id }}):"
cat "$SUMMARY_FILE"
else
echo "Summary file not found: $SUMMARY_FILE"
fi
- name: Stop MongoDB
if: ${{ always() && matrix.backend.needs_mongo }}
run: |
set -euo pipefail
cd docker
docker compose -f compose.mongo.yml down -v || true
- name: Upload collection artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v6
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_DIR }}
if-no-files-found: error
================================================
FILE: .github/workflows/dashboard.yml
================================================
name: Dashboard
permissions:
contents: read
on:
schedule:
# Every day at 5 AM UTC+8
- cron: '0 21 * * *'
workflow_dispatch:
push:
branches: [ main, stable/**/* ]
jobs:
dashboard:
name: Chromatic
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version: '22'
- name: Install JavaScript dependencies
run: cd dashboard && npm ci
- name: Run Chromatic
uses: chromaui/action@v13
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
workingDir: dashboard
exitZeroOnChanges: false
================================================
FILE: .github/workflows/docs.yml
================================================
name: Deploy Documentation
on:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:
concurrency:
group: docs-deploy
cancel-in-progress: false
permissions:
contents: write
pages: write
id-token: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Sync dependencies
run: uv sync --frozen --no-default-groups --group dev
- name: Configure Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Get version and commit
id: version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
SOURCE_COMMIT=${GITHUB_SHA}
else
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
SOURCE_COMMIT=${GITHUB_SHA}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "SOURCE_COMMIT=$SOURCE_COMMIT" >> $GITHUB_ENV
- name: Deploy versioned docs
if: startsWith(github.ref, 'refs/tags/')
run: |
uv run --locked --no-sync mike deploy --push --update-aliases ${{ steps.version.outputs.version }} stable
- name: Deploy dev docs
if: github.ref == 'refs/heads/main'
run: |
uv run --locked --no-sync mike deploy --push latest
# Always set stable to default
uv run --locked --no-sync mike set-default --push stable
================================================
FILE: .github/workflows/examples-apo.yml
================================================
name: Examples - APO
permissions:
contents: read
on:
schedule:
# Every day at 3 AM UTC+8
- cron: '0 19 * * *'
workflow_dispatch:
repository_dispatch:
types: [ci-apo, ci-all]
run-name: >-
${{ github.event_name == 'repository_dispatch'
&& format(
'APO - PR #{0} - {1} - {2}',
github.event.client_payload.pull_number,
github.event.client_payload.ci_label,
github.event.client_payload.correlation_id
)
|| format('APO - {0}', github.event_name) }}
jobs:
apo:
if: >
github.event_name != 'repository_dispatch' ||
github.event.action == 'ci-apo' ||
github.event.action == 'ci-all'
name: APO (Python ${{ matrix.python-version }}, ${{ matrix.setup-script }})
# This job is run on GitHub hosted runners rather than self-hosted runners because it needs no GPU.
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
include:
- python-version: '3.10'
setup-script: 'legacy'
- python-version: '3.12'
setup-script: 'stable'
- python-version: '3.13'
setup-script: 'latest'
fail-fast: false
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.pr_ref || (github.event.pull_request.number && format('refs/pull/{0}/merge', github.event.pull_request.number)) || github.ref }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Upgrade dependencies (latest)
run: uv lock --upgrade
if: matrix.setup-script == 'latest'
- name: Sync dependencies (latest)
run: |
uv sync --frozen --no-default-groups --extra apo \
--group dev --group experiment --group agents --group core-stable
if: matrix.setup-script == 'latest'
- name: Sync dependencies (stable & legacy)
run: |
uv sync --frozen --no-default-groups --extra apo \
--group dev --group experiment --group agents --group core-${{ matrix.setup-script }}
if: matrix.setup-script != 'latest'
- name: Freeze dependencies
run: |
set -ex
uv pip freeze | tee requirements-freeze.txt
echo "UV_LOCKED=1" >> $GITHUB_ENV
echo "UV_NO_SYNC=1" >> $GITHUB_ENV
- name: Upload dependencies artifact
uses: actions/upload-artifact@v6
with:
name: dependencies-apo-${{ matrix.python-version }}-${{ matrix.setup-script }}
path: requirements-freeze.txt
compression-level: 0
- name: Launch LiteLLM Proxy
run: |
./scripts/litellm_run.sh
env:
AZURE_API_BASE: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_BASE }}
AZURE_API_KEY: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_KEY }}
- name: APO custom algorithm
run: |
set -ex
cd examples/apo
uv run apo_custom_algorithm_trainer.py | tee _ci_apo.log
# Check whether the log contains "Best prompt found:"
grep "Best prompt found:" _ci_apo.log
env:
# New versions follow OPENAI_BASE_URL instead of OPENAI_API_BASE
OPENAI_BASE_URL: http://localhost:12306/
OPENAI_API_KEY: dummy
- name: APO custom algorithm debugger
run: |
set -ex
cd examples/apo
uv run apo_debug.py --mode runner
uv run apo_debug.py --mode hook
uv run apo_debug.py --mode trainer
env:
# New versions follow OPENAI_BASE_URL instead of OPENAI_API_BASE
OPENAI_BASE_URL: http://localhost:12306/
OPENAI_API_KEY: dummy
- name: APO built-in algorithm
run: |
set -ex
cd examples/apo
uv run room_selector_apo.py
env:
OPENAI_BASE_URL: http://localhost:12306/
OPENAI_API_KEY: dummy
if: matrix.setup-script != 'legacy'
================================================
FILE: .github/workflows/examples-azure.yml
================================================
name: Examples - Azure
permissions:
contents: read
on:
schedule:
# Every day at 4 AM UTC+8
- cron: '0 20 * * *'
workflow_dispatch:
repository_dispatch:
types: [ci-azure, ci-all]
run-name: >-
${{ github.event_name == 'repository_dispatch'
&& format(
'Azure - PR #{0} - {1} - {2}',
github.event.client_payload.pull_number,
github.event.client_payload.ci_label,
github.event.client_payload.correlation_id
)
|| format('Azure - {0}', github.event_name) }}
jobs:
azure:
if: >
github.event_name != 'repository_dispatch' ||
github.event.action == 'ci-azure' ||
github.event.action == 'ci-all'
name: Azure (Python ${{ matrix.python-version }}, ${{ matrix.setup-script }})
runs-on: [self-hosted, 1ES.Pool=agl-runner-cpu]
timeout-minutes: 400
strategy:
matrix:
include:
- python-version: '3.12'
setup-script: 'stable'
fail-fast: false
steps:
- name: Check disk space
run: df -h
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.pr_ref || (github.event.pull_request.number && format('refs/pull/{0}/merge', github.event.pull_request.number)) || github.ref }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Upgrade dependencies (latest)
run: uv lock --upgrade
if: matrix.setup-script == 'latest'
- name: Sync dependencies
run: |
uv sync --frozen --no-default-groups \
--group dev --group experiment --group agents --group core-stable
- name: Freeze dependencies
run: |
set -ex
uv pip freeze | tee requirements-freeze.txt
echo "UV_LOCKED=1" >> $GITHUB_ENV
echo "UV_NO_SYNC=1" >> $GITHUB_ENV
- name: Upload dependencies artifact
uses: actions/upload-artifact@v6
with:
name: dependencies-azure-${{ matrix.python-version }}-${{ matrix.setup-script }}
path: requirements-freeze.txt
compression-level: 0
- name: Azure Login
run: |
az login --identity
shell: bash
- name: Azure OpenAI Sanity Check
run: |
source .venv/bin/activate
cd examples/azure
python capital_agent.py
shell: bash
env:
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT_SWEDEN }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY_SWEDEN }}
id: azure_openai_sanity_check
- name: Azure OpenAI Supervised Fine-tuning
run: |
source .venv/bin/activate
cd examples/azure
python train_capital_agent.py --n-iterations 2 --cleanup
shell: bash
env:
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT_SWEDEN }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY_SWEDEN }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_OPENAI_API_VERSION: 2025-04-01-preview
AZURE_RESOURCE_GROUP: ${{ secrets.AZURE_RESOURCE_GROUP }}
AZURE_RESOURCE_NAME: ${{ secrets.AZURE_RESOURCE_NAME }}
id: azure_openai_finetune
================================================
FILE: .github/workflows/examples-calc-x.yml
================================================
name: Examples - Calc-X
permissions:
contents: read
on:
schedule:
# Every day at 3 AM UTC+8
- cron: '0 19 * * *'
workflow_dispatch:
repository_dispatch:
types: [ci-calc-x, ci-all]
run-name: >-
${{ github.event_name == 'repository_dispatch'
&& format(
'Calc-X - PR #{0} - {1} - {2}',
github.event.client_payload.pull_number,
github.event.client_payload.ci_label,
github.event.client_payload.correlation_id
)
|| format('Calc-X - {0}', github.event_name) }}
jobs:
calc-x-perf:
if: >
github.event_name != 'repository_dispatch' ||
github.event.action == 'ci-calc-x' ||
github.event.action == 'ci-all'
name: Calc-X Performance (Python ${{ matrix.python-version }}, ${{ matrix.setup-script }})
runs-on: [self-hosted, 1ES.Pool=agl-runner-gpu]
timeout-minutes: 90
strategy:
matrix:
include:
- python-version: '3.10'
setup-script: 'legacy'
- python-version: '3.12'
setup-script: 'stable'
- python-version: '3.13'
setup-script: 'latest'
fail-fast: false
steps:
- name: Check GPU status
run: nvidia-smi
- name: Check disk space
run: df -h
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.pr_ref || (github.event.pull_request.number && format('refs/pull/{0}/merge', github.event.pull_request.number)) || github.ref }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Upgrade dependencies (latest)
run: uv lock --upgrade
if: matrix.setup-script == 'latest'
- name: Sync dependencies (latest)
run: |
uv sync --frozen --no-default-groups --extra verl \
--group dev --group experiment --group agents --group torch-gpu-stable
if: matrix.setup-script == 'latest'
- name: Sync dependencies (stable & legacy)
run: |
uv sync --frozen --no-default-groups --extra verl \
--group dev --group experiment --group agents --group torch-gpu-${{ matrix.setup-script }}
if: matrix.setup-script != 'latest'
- name: Freeze dependencies
run: |
set -ex
uv pip freeze | tee requirements-freeze.txt
echo "UV_LOCKED=1" >> $GITHUB_ENV
echo "UV_NO_SYNC=1" >> $GITHUB_ENV
- name: Upload dependencies artifact
uses: actions/upload-artifact@v6
with:
name: dependencies-calc-x-performance-${{ matrix.python-version }}-${{ matrix.setup-script }}
path: requirements-freeze.txt
compression-level: 0
- name: Launch LiteLLM Proxy
run: |
./scripts/litellm_run.sh
env:
AZURE_API_BASE: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_BASE }}
AZURE_API_KEY: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_KEY }}
- name: Prepare Calc-X dataset
run: |
set -ex
cd examples/calc_x
uv run gdown --fuzzy https://drive.google.com/file/d/1FQMyKLLd6hP9dw9rfZn1EZOWNvKaDsqw/view
unzip calc-x-data.zip -d data
rm calc-x-data.zip
- name: Calc-X MCP sanity check
run: |
set -ex
cd examples/calc_x
uv run tests/test_mcp_calculator.py
env:
OPENAI_API_BASE: http://localhost:12306/
OPENAI_API_KEY: dummy
- name: Calc-X sanity check
run: |
set -ex
cd examples/calc_x
uv run legacy_calc_agent_debug.py
env:
OPENAI_BASE_URL: http://localhost:12306/
OPENAI_API_KEY: dummy
# Calc-X training suddenly works after running the sanity check.
# And it has to be run before Spider training.
# The client side used to hang in many of my attempts.
# Don't ask why. Don't touch this.
- name: Calc-X training
run: |
source .venv/bin/activate
cd examples/calc_x
../../scripts/restart_ray.sh
sleep 5
python train_calc_agent.py --val-file data/test_mini.parquet --ci
shell: bash
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
id: calc_x_train
- name: Validate Calc-X training
run: |
set -ex
uv run scripts/validate_example_wandb.py ${{ steps.calc_x_train.outputs.project_name }} ${{ steps.calc_x_train.outputs.run_name }}
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
calc-x-variants:
if: >
github.event_name != 'repository_dispatch' ||
github.event.action == 'ci-calc-x' ||
github.event.action == 'ci-all'
name: Calc-X Variants (Python ${{ matrix.python-version }}, ${{ matrix.setup-script }})
runs-on: [self-hosted, 1ES.Pool=agl-runner-gpu]
timeout-minutes: 90
strategy:
matrix:
include:
- python-version: '3.10'
setup-script: 'legacy'
- python-version: '3.12'
setup-script: 'stable'
- python-version: '3.13'
setup-script: 'latest'
fail-fast: false
steps:
- name: Check GPU status
run: nvidia-smi
- name: Check disk space
run: df -h
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.pr_ref || (github.event.pull_request.number && format('refs/pull/{0}/merge', github.event.pull_request.number)) || github.ref }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Upgrade dependencies (latest)
run: uv lock --upgrade
if: matrix.setup-script == 'latest'
- name: Sync dependencies (latest)
run: |
uv sync --frozen --no-default-groups --extra verl \
--group dev --group experiment --group agents --extra weave --extra mongo --group torch-gpu-stable
if: matrix.setup-script == 'latest'
- name: Sync dependencies (stable & legacy)
run: |
uv sync --frozen --no-default-groups --extra verl \
--group dev --group experiment --group agents --extra weave --extra mongo --group torch-gpu-${{ matrix.setup-script }}
if: matrix.setup-script != 'latest'
- name: Freeze dependencies
run: |
set -ex
uv pip freeze | tee requirements-freeze.txt
echo "UV_LOCKED=1" >> $GITHUB_ENV
echo "UV_NO_SYNC=1" >> $GITHUB_ENV
- name: Upload dependencies artifact
uses: actions/upload-artifact@v6
with:
name: dependencies-calc-x-variants-${{ matrix.python-version }}-${{ matrix.setup-script }}
path: requirements-freeze.txt
compression-level: 0
- name: Launch LiteLLM Proxy
run: |
./scripts/litellm_run.sh
env:
AZURE_API_BASE: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_BASE }}
AZURE_API_KEY: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_KEY }}
- name: Prepare Calc-X dataset
run: |
set -ex
cd examples/calc_x
uv run gdown --fuzzy https://drive.google.com/file/d/1FQMyKLLd6hP9dw9rfZn1EZOWNvKaDsqw/view
unzip calc-x-data.zip -d data
rm calc-x-data.zip
- name: Calc-X MCP sanity check
run: |
set -ex
cd examples/calc_x
uv run tests/test_mcp_calculator.py
env:
OPENAI_API_BASE: http://localhost:12306/
OPENAI_API_KEY: dummy
- name: Calc-X sanity check
run: |
set -ex
cd examples/calc_x
uv run legacy_calc_agent_debug.py
env:
OPENAI_BASE_URL: http://localhost:12306/
OPENAI_API_KEY: dummy
- name: Training with local model
run: |
set -ex
source .venv/bin/activate
cd examples/calc_x
../../scripts/restart_ray.sh
sleep 5
hf download Qwen/Qwen2.5-0.5B-Instruct --local-dir data/qwen_model
PYTHONUNBUFFERED=1 python train_calc_agent.py --val-file data/test_mini.parquet --ci-fast --model $(realpath data/qwen_model)
sleep 10
shell: bash
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
id: calc_x_train_local_model
- name: Validate training with local model
run: |
set -ex
uv run scripts/validate_example_wandb.py ${{ steps.calc_x_train_local_model.outputs.project_name }} ${{ steps.calc_x_train_local_model.outputs.run_name }}
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
- name: Training with LLM Proxy
run: |
set -ex
source .venv/bin/activate
cd examples/calc_x
../../scripts/restart_ray.sh
sleep 5
PYTHONUNBUFFERED=1 python train_calc_agent.py --val-file data/test_mini.parquet --ci-fast --llm-proxy
sleep 10
shell: bash
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
id: calc_x_train_llm_proxy
- name: Validate training with LLM Proxy
run: |
set -ex
uv run scripts/validate_example_wandb.py ${{ steps.calc_x_train_llm_proxy.outputs.project_name }} ${{ steps.calc_x_train_llm_proxy.outputs.run_name }}
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
- name: Setup Docker environments
run: ./scripts/mongodb_docker_run.sh
shell: bash
- name: Training with MongoDB
run: |
set -ex
source .venv/bin/activate
cd examples/calc_x
../../scripts/restart_ray.sh
sleep 5
PYTHONUNBUFFERED=1 python train_calc_agent.py --val-file data/test_mini.parquet --ci-fast --mongo-uri mongodb://localhost:27017/?replicaSet=rs0
sleep 10
shell: bash
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
id: calc_x_train_mongo
- name: Validate training with MongoDB
run: |
set -ex
uv run scripts/validate_example_wandb.py ${{ steps.calc_x_train_mongo.outputs.project_name }} ${{ steps.calc_x_train_mongo.outputs.run_name }}
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
- name: Training with LoRA
run: |
set -ex
source .venv/bin/activate
cd examples/calc_x
../../scripts/restart_ray.sh
sleep 5
PYTHONUNBUFFERED=1 python train_calc_agent.py --val-file data/test_mini.parquet --ci-fast --lora
sleep 10
shell: bash
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
id: calc_x_train_lora
if: matrix.setup-script != 'legacy'
- name: Validate training with LoRA
run: |
set -ex
uv run scripts/validate_example_wandb.py ${{ steps.calc_x_train_lora.outputs.project_name }} ${{ steps.calc_x_train_lora.outputs.run_name }}
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
if: matrix.setup-script != 'legacy'
- name: Training with trajectory level aggregation
run: |
set -ex
source .venv/bin/activate
cd examples/calc_x
../../scripts/restart_ray.sh
sleep 5
PYTHONUNBUFFERED=1 python train_calc_agent.py --val-file data/test_mini.parquet --ci-fast --trajectory-level
sleep 10
shell: bash
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
id: calc_x_train_trajectory_level
- name: Validate training with trajectory level aggregation
run: |
set -ex
uv run scripts/validate_example_wandb.py ${{ steps.calc_x_train_trajectory_level.outputs.project_name }} ${{ steps.calc_x_train_trajectory_level.outputs.run_name }}
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
- name: Training with Weave
run: |
set -ex
source .venv/bin/activate
cd examples/calc_x
../../scripts/restart_ray.sh
sleep 5
PYTHONUNBUFFERED=1 python train_calc_agent.py --val-file data/test_mini.parquet --ci-fast --weave
sleep 10
shell: bash
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
id: calc_x_train_weave
- name: Validate training with Weave
run: |
set -ex
uv run scripts/validate_example_wandb.py ${{ steps.calc_x_train_weave.outputs.project_name }} ${{ steps.calc_x_train_weave.outputs.run_name }}
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
- name: Training with external store
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/calc_x
../../scripts/restart_ray.sh
agl store --port 4747 &
sleep 5
AGL_MANAGED_STORE=0 AGL_CURRENT_ROLE=runner python train_calc_agent.py --external-store-address http://localhost:4747 --val-file data/test_mini.parquet --ci-fast &
sleep 5
AGL_MANAGED_STORE=0 AGL_CURRENT_ROLE=algorithm python train_calc_agent.py --external-store-address http://localhost:4747 --val-file data/test_mini.parquet --ci-fast
pkill -f agl && echo "SIGTERM sent to agl" || echo "No agl process found"
while pgrep -f agl; do
echo "Waiting for agl to finish..."
sleep 5
done
pkill -f train_calc_agent.py && echo "SIGTERM sent to train_calc_agent.py" || echo "No train_calc_agent.py process found"
while pgrep -f train_calc_agent.py; do
echo "Waiting for train_calc_agent.py to finish..."
sleep 5
done
echo "train_calc_agent.py has finished."
shell: bash
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
id: calc_x_train_external_store
- name: Validate training with external store
run: |
set -ex
uv run scripts/validate_example_wandb.py ${{ steps.calc_x_train_external_store.outputs.project_name }} ${{ steps.calc_x_train_external_store.outputs.run_name }}
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
- name: Training with role-based environment variables
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/calc_x
../../scripts/restart_ray.sh
PYTHONUNBUFFERED=1 AGL_SERVER_HOST=127.0.0.1 AGL_SERVER_PORT=5858 AGL_CURRENT_ROLE=runner python train_calc_agent.py --val-file data/test_mini.parquet --ci-fast &
sleep 5
PYTHONUNBUFFERED=1 AGL_SERVER_HOST=0.0.0.0 AGL_SERVER_PORT=5858 AGL_CURRENT_ROLE=algorithm python train_calc_agent.py --val-file data/test_mini.parquet --ci-fast
pkill -f train_calc_agent.py && echo "SIGTERM sent to train_calc_agent.py" || echo "No train_calc_agent.py process found"
while pgrep -f train_calc_agent.py; do
echo "Waiting for train_calc_agent.py to finish..."
sleep 5
done
echo "train_calc_agent.py has finished."
shell: bash
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
id: calc_x_train_role_based_env_var
- name: Validate training with role-based environment variables
run: |
set -ex
uv run scripts/validate_example_wandb.py ${{ steps.calc_x_train_role_based_env_var.outputs.project_name }} ${{ steps.calc_x_train_role_based_env_var.outputs.run_name }}
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
================================================
FILE: .github/workflows/examples-chartqa.yml
================================================
name: Examples - ChartQA
permissions:
contents: read
on:
schedule:
# Every day at 6 AM UTC+8
- cron: "0 22 * * *"
workflow_dispatch:
repository_dispatch:
types: [ci-chartqa, ci-all]
run-name: >-
${{ github.event_name == 'repository_dispatch'
&& format(
'ChartQA - PR #{0} - {1} - {2}',
github.event.client_payload.pull_number,
github.event.client_payload.ci_label,
github.event.client_payload.correlation_id
)
|| format('ChartQA - {0}', github.event_name) }}
jobs:
chartqa:
if: >
github.event_name != 'repository_dispatch' ||
github.event.action == 'ci-chartqa' ||
github.event.action == 'ci-all'
name: ChartQA (Python ${{ matrix.python-version }}, ${{ matrix.setup-script }})
runs-on: [self-hosted, 1ES.Pool=agl-runner-gpu]
timeout-minutes: 60
strategy:
matrix:
include:
- python-version: '3.12'
setup-script: 'stable'
fail-fast: false
steps:
- name: Check GPU status
run: nvidia-smi
- name: Check disk space
run: df -h
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.pr_ref || (github.event.pull_request.number && format('refs/pull/{0}/merge', github.event.pull_request.number)) || github.ref }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Upgrade dependencies (latest)
run: uv lock --upgrade
if: matrix.setup-script == 'latest'
- name: Sync dependencies
run: |
uv sync --frozen --no-default-groups --extra verl \
--group dev --group experiment --group image --group langchain --group vllm-0-10-2 --group torch-gpu-stable
- name: Freeze dependencies
run: |
set -ex
uv pip freeze | tee requirements-freeze.txt
echo "UV_LOCKED=1" >> $GITHUB_ENV
echo "UV_NO_SYNC=1" >> $GITHUB_ENV
- name: Upload dependencies artifact
uses: actions/upload-artifact@v6
with:
name: dependencies-chartqa-${{ matrix.python-version }}-${{ matrix.setup-script }}
path: requirements-freeze.txt
compression-level: 0
- name: Launch LiteLLM Proxy
run: |
./scripts/litellm_run.sh
env:
AZURE_API_BASE: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_BASE }}
AZURE_API_KEY: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_KEY }}
- name: Prepare ChartQA dataset
run: |
set -euo pipefail
cd examples/chartqa
uv run gdown --fuzzy "https://drive.google.com/file/d/1fWRt9hehg8_uV7BDWSCwKTycM60JcmGN/view?usp=sharing" -O chartqa-data.zip
unzip chartqa-data.zip
rm chartqa-data.zip
shell: bash
- name: ChartQA sanity check with GPT
run: |
set -euo pipefail
cd examples/chartqa
uv run python debug_chartqa_agent.py
shell: bash
env:
OPENAI_API_BASE: http://localhost:12306/
OPENAI_API_KEY: dummy
- name: Run vLLM Server
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/chartqa
uv run --no-sync vllm serve Qwen/Qwen2-VL-2B-Instruct \
--gpu-memory-utilization 0.9 \
--max-model-len 4096 \
--allowed-local-media-path "$(pwd)/data" \
--enable-prefix-caching \
--port 8088 &
VLLM_READY=0
for i in {1..100}; do
if curl -sSf http://localhost:8088/v1/models > /dev/null 2>&1; then
echo "vLLM server is ready!"
VLLM_READY=1
break
fi
echo "Waiting for vLLM server to be ready... (${i})"
sleep 5
done
if [[ "$VLLM_READY" != "1" ]]; then
echo "vLLM server failed to start!"
exit 1
fi
- name: ChartQA sanity check with vLLM
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/chartqa
uv run python debug_chartqa_agent.py
shell: bash
env:
USE_LLM_PROXY: "1"
OPENAI_API_BASE: http://localhost:8088/v1
OPENAI_MODEL: Qwen/Qwen2-VL-2B-Instruct
- name: Stop vLLM Server
run: |
set -euo pipefail
pkill -f vllm
for i in {1..60}; do
if ! pgrep -f vllm; then
break
fi
sleep 5
done
- name: ChartQA training
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/chartqa
../../scripts/restart_ray.sh
sleep 5
PYTHONUNBUFFERED=1 python train_chartqa_agent.py ci
sleep 10
shell: bash
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
id: chartqa_train
- name: Validate ChartQA training
run: |
set -euo pipefail
uv run scripts/validate_example_wandb.py ${{ steps.chartqa_train.outputs.project_name }} ${{ steps.chartqa_train.outputs.run_name }}
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
================================================
FILE: .github/workflows/examples-claude-code.yml
================================================
name: Examples - Claude Code
permissions:
contents: read
on:
schedule:
# Every day at 4 AM UTC+8
- cron: "0 20 * * *"
workflow_dispatch:
repository_dispatch:
types: [ci-claude-code, ci-all]
run-name: >-
${{ github.event_name == 'repository_dispatch'
&& format(
'Claude Code - PR #{0} - {1} - {2}',
github.event.client_payload.pull_number,
github.event.client_payload.ci_label,
github.event.client_payload.correlation_id
)
|| format('Claude Code - {0}', github.event_name) }}
jobs:
claude-code:
if: >
github.event_name != 'repository_dispatch' ||
github.event.action == 'ci-claude-code' ||
github.event.action == 'ci-all'
name: Claude Code (Python ${{ matrix.python-version }}, ${{ matrix.setup-script }})
runs-on: [self-hosted, 1ES.Pool=agl-runner-gpu]
timeout-minutes: 60
strategy:
matrix:
include:
- python-version: "3.12"
setup-script: "stable"
- python-version: "3.13"
setup-script: "latest"
fail-fast: false
steps:
- name: Check GPU status
run: nvidia-smi
- name: Check disk space
run: df -h
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.pr_ref || (github.event.pull_request.number && format('refs/pull/{0}/merge', github.event.pull_request.number)) || github.ref }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Upgrade dependencies (latest)
run: uv lock --upgrade
if: matrix.setup-script == 'latest'
- name: Sync dependencies
run: |
uv sync --frozen --no-default-groups \
--group dev --group experiment --group agents --group torch-gpu-stable
- name: Freeze dependencies
run: |
set -ex
uv pip freeze | tee requirements-freeze.txt
echo "UV_LOCKED=1" >> $GITHUB_ENV
echo "UV_NO_SYNC=1" >> $GITHUB_ENV
- name: Upload dependencies artifact
uses: actions/upload-artifact@v6
with:
name: dependencies-claude-code-${{ matrix.python-version }}-${{ matrix.setup-script }}
path: requirements-freeze.txt
compression-level: 0
- name: Download model
run: |
source .venv/bin/activate
python -c "from transformers import AutoModelForCausalLM; AutoModelForCausalLM.from_pretrained('Qwen/Qwen3-Coder-30B-A3B-Instruct')"
- name: Launch vLLM server
run: |
set -euo pipefail
source .venv/bin/activate
vllm serve Qwen/Qwen3-Coder-30B-A3B-Instruct \
--max-model-len 131072 \
--enable-auto-tool-choice \
--tool-call-parser qwen3_coder \
--port 45993 &
VLLM_READY=0
for i in {1..100}; do
if curl -sSf http://localhost:45993/v1/models > /dev/null 2>&1; then
echo "vLLM server is ready!"
VLLM_READY=1
break
fi
echo "Waiting for vLLM server to be ready... (${i})"
sleep 5
done
if [[ "$VLLM_READY" != "1" ]]; then
echo "vLLM server failed to start!"
exit 1
fi
- name: Claude Code sanity check with vLLM models
run: |
source .venv/bin/activate
cd examples/claude_code
python claude_code_agent.py vllm --backend-model-high Qwen/Qwen3-Coder-30B-A3B-Instruct --backend-model-low Qwen/Qwen3-Coder-30B-A3B-Instruct --base-url http://localhost:45993/v1 --debug
shell: bash
- name: Upload sanity check artifacts for vLLM
if: ${{ always() }}
uses: actions/upload-artifact@v6
with:
name: claude-code-sanity-check-vllm-${{ matrix.setup-script }}
path: |
examples/claude_code/data/
examples/claude_code/logs/
if-no-files-found: error
- name: Cleanup vLLM
run: |
set -euo pipefail
pkill -f vllm
for i in {1..60}; do
if ! pgrep -f vllm; then
break
fi
sleep 5
done
rm -rf examples/claude_code/data/
rm -rf examples/claude_code/logs/
- name: Claude Code sanity check with OpenAI models
run: |
source .venv/bin/activate
cd examples/claude_code
python claude_code_agent.py openai --backend-model-high gpt-5.1-codex-mini --backend-model-low gpt-4.1-mini --debug
shell: bash
env:
OPENAI_BASE_URL: ${{ secrets.AZURE_OPENAI_ENDPOINT_SWEDEN }}
OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY_SWEDEN }}
- name: Upload sanity check artifacts for OpenAI
if: ${{ always() }}
uses: actions/upload-artifact@v6
with:
name: claude-code-sanity-check-openai-${{ matrix.setup-script }}
path: |
examples/claude_code/data/
examples/claude_code/logs/
if-no-files-found: error
================================================
FILE: .github/workflows/examples-compat.yml
================================================
name: Examples - Backward Compatibility
permissions:
contents: read
on:
schedule:
# Every day at 6 AM UTC+8
- cron: '0 22 * * *'
workflow_dispatch:
repository_dispatch:
types: [ci-compat, ci-all]
run-name: >-
${{ github.event_name == 'repository_dispatch'
&& format(
'Backward Compatibility - PR #{0} - {1} - {2}',
github.event.client_payload.pull_number,
github.event.client_payload.ci_label,
github.event.client_payload.correlation_id
)
|| format('Backward Compatibility - {0}', github.event_name) }}
jobs:
backward-compatibility:
if: >
github.event_name != 'repository_dispatch' ||
github.event.action == 'ci-compat' ||
github.event.action == 'ci-all'
name: Backward Compatibility (Python ${{ matrix.python-version }}, ${{ matrix.setup-script }})
runs-on: [self-hosted, 1ES.Pool=agl-runner-gpu]
timeout-minutes: 30
strategy:
matrix:
include:
- python-version: '3.10'
setup-script: 'legacy'
- python-version: '3.12'
setup-script: 'stable'
fail-fast: false
steps:
- name: Check GPU status
run: nvidia-smi
- name: Check disk space
run: df -h
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.pr_ref || (github.event.pull_request.number && format('refs/pull/{0}/merge', github.event.pull_request.number)) || github.ref }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Sync dependencies
run: |
uv sync --frozen --no-default-groups --extra apo --extra verl \
--group dev --group experiment --group agents --group torch-gpu-${{ matrix.setup-script }}
- name: Override VERL (stable)
run: |
uv pip install verl==0.5.0 vllm==0.10.2
if: matrix.setup-script == 'stable'
- name: Freeze dependencies
run: |
set -ex
uv pip freeze | tee requirements-freeze.txt
echo "UV_LOCKED=1" >> $GITHUB_ENV
echo "UV_NO_SYNC=1" >> $GITHUB_ENV
- name: Upload dependencies artifact
uses: actions/upload-artifact@v6
with:
name: dependencies-backward-compatibility-${{ matrix.python-version }}-${{ matrix.setup-script }}
path: requirements-freeze.txt
compression-level: 0
- name: Launch LiteLLM Proxy
run: |
./scripts/litellm_run.sh
env:
AZURE_API_BASE: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_BASE }}
AZURE_API_KEY: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_KEY }}
- name: Prepare Calc-X dataset
run: |
set -ex
cd examples/calc_x
uv run gdown --fuzzy https://drive.google.com/file/d/1FQMyKLLd6hP9dw9rfZn1EZOWNvKaDsqw/view
unzip calc-x-data.zip -d data
rm calc-x-data.zip
- name: APO example (legacy client-server style)
run: |
set -ex
cd examples/apo
uv run legacy_apo_client.py &
sleep 3 # Wait for the client to be up
uv run legacy_apo_server.py
pkill -f legacy_apo_client.py && echo "SIGTERM sent to legacy_apo_client.py" || echo "No legacy_apo_client.py process found"
while pgrep -f legacy_apo_client.py; do
echo "Waiting for legacy_apo_client.py to finish..."
sleep 5
done
echo "legacy_apo_client.py has finished."
sleep 10
env:
OPENAI_API_BASE: http://localhost:12306/
OPENAI_API_KEY: dummy
- name: Calc-X MCP sanity check
run: |
set -ex
cd examples/calc_x
uv run tests/test_mcp_calculator.py
env:
OPENAI_API_BASE: http://localhost:12306/
OPENAI_API_KEY: dummy
- name: Calc-X sanity check
run: |
set -ex
cd examples/calc_x
uv run legacy_calc_agent_debug.py
env:
OPENAI_BASE_URL: http://localhost:12306/
OPENAI_API_KEY: dummy
- name: Calc-X training (legacy client-server style)
run: |
set -ex
source .venv/bin/activate
cd examples/calc_x
../../scripts/restart_ray.sh
sleep 5
PYTHONUNBUFFERED=1 python legacy_calc_agent.py &
bash legacy_train.sh
pkill -f legacy_calc_agent.py && echo "SIGTERM sent to legacy_calc_agent.py" || echo "No legacy_calc_agent.py process found"
while pgrep -f legacy_calc_agent.py; do
echo "Waiting for legacy_calc_agent.py to finish..."
sleep 5
done
echo "legacy_calc_agent.py has finished."
sleep 10
shell: bash
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
id: calc_x_train
- name: Validate Calc-X training
run: |
set -ex
uv run scripts/validate_example_wandb.py ${{ steps.calc_x_train.outputs.project_name }} ${{ steps.calc_x_train.outputs.run_name }}
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
================================================
FILE: .github/workflows/examples-rag.yml
================================================
name: Examples - RAG
permissions:
contents: read
on:
schedule:
# Every day at 6 AM UTC+8
- cron: '0 22 * * *'
workflow_dispatch:
repository_dispatch:
types: [ci-rag, ci-all]
run-name: >-
${{ github.event_name == 'repository_dispatch'
&& format(
'RAG - PR #{0} - {1} - {2}',
github.event.client_payload.pull_number,
github.event.client_payload.ci_label,
github.event.client_payload.correlation_id
)
|| format('RAG - {0}', github.event_name) }}
jobs:
rag:
if: >
github.event_name != 'repository_dispatch' ||
github.event.action == 'ci-rag' ||
github.event.action == 'ci-all'
name: RAG (Python ${{ matrix.python-version }}, ${{ matrix.setup-script }})
runs-on: [self-hosted, 1ES.Pool=agl-runner-gpu]
timeout-minutes: 60
strategy:
matrix:
include:
- python-version: '3.10'
setup-script: 'legacy'
- python-version: '3.12'
setup-script: 'stable'
- python-version: '3.13'
setup-script: 'latest'
fail-fast: false
steps:
- name: Check GPU status
run: nvidia-smi
- name: Check disk space
run: df -h
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.pr_ref || (github.event.pull_request.number && format('refs/pull/{0}/merge', github.event.pull_request.number)) || github.ref }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Upgrade dependencies (latest)
run: uv lock --upgrade
if: matrix.setup-script == 'latest'
- name: Sync dependencies (latest)
run: |
uv sync --frozen --no-default-groups --extra verl \
--group dev --group experiment --group agents --group rag --group torch-gpu-stable
if: matrix.setup-script == 'latest'
- name: Sync dependencies (stable & legacy)
run: |
uv sync --frozen --no-default-groups --extra verl \
--group dev --group experiment --group agents --group rag --group torch-gpu-${{ matrix.setup-script }}
if: matrix.setup-script != 'latest'
- name: Freeze dependencies
run: |
set -ex
uv pip freeze | tee requirements-freeze.txt
echo "UV_LOCKED=1" >> $GITHUB_ENV
echo "UV_NO_SYNC=1" >> $GITHUB_ENV
- name: Upload dependencies artifact
uses: actions/upload-artifact@v6
with:
name: dependencies-rag-${{ matrix.python-version }}-${{ matrix.setup-script }}
path: requirements-freeze.txt
compression-level: 0
- name: Launch LiteLLM Proxy
run: |
./scripts/litellm_run.sh
env:
AZURE_API_BASE: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_BASE }}
AZURE_API_KEY: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_KEY }}
- name: Prepare RAG dataset
run: |
set -euo pipefail
cd examples/rag
mkdir -p data
uv run gdown --fuzzy "https://drive.google.com/file/d/1Pq4Ag8zVoN8gUtLu0LcBfY35Dm5zL0hq/view?usp=drive_link" -O data/dataset_tiny.parquet
uv run gdown --fuzzy "https://drive.google.com/file/d/1REXCpRLbeZu1KfWWKhIGEQe_WNHUOBkS/view?usp=drive_link" -O data/chunks_candidate_tiny.pkl
uv run gdown --fuzzy "https://drive.google.com/file/d/1f6P-h_8KSRhe5pqDHWbRQWvUhTygfZ-c/view?usp=drive_link" -O data/index_hnsw_faiss_n32e40_tiny.index
- name: Run WIKI Retriever MCP Server
run: |
set -euo pipefail
cd examples/rag
uv run python wiki_retriever_mcp.py &
for i in {1..20}; do
sleep 5
if nc -z localhost 8099; then
echo "MCP server is up!"
exit 0
else
echo "Waiting for MCP server to start..."
fi
done
echo "MCP server failed to start within expected time."
exit 1
- name: Run vLLM Server
run: |
set -euo pipefail
source .venv/bin/activate
vllm serve Qwen/Qwen2.5-1.5B-Instruct \
--enable-auto-tool-choice \
--tool-call-parser hermes \
--port 8000 &
VLLM_READY=0
for i in {1..100}; do
if curl -sSf http://localhost:8000/v1/models > /dev/null 2>&1; then
echo "vLLM server is ready!"
VLLM_READY=1
break
fi
echo "Waiting for vLLM server to be ready... (${i})"
sleep 5
done
if [[ "$VLLM_READY" != "1" ]]; then
echo "vLLM server failed to start!"
exit 1
fi
- name: Run RAG Sanity check
run: |
set -ex
source .venv/bin/activate
cd examples/rag
uv run python rag_agent.py
shell: bash
- name: Stop vLLM Server
run: |
set -euo pipefail
pkill -f vllm
for i in {1..60}; do
if ! pgrep -f vllm; then
break
fi
sleep 5
done
- name: RAG training
run: |
set -ex
source .venv/bin/activate
cd examples/rag
../../scripts/restart_ray.sh
sleep 5
PYTHONUNBUFFERED=1 python train_rag.py fast
sleep 10
shell: bash
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
id: rag_train
- name: Validate RAG training
run: |
set -ex
# Allow up to 5 rollouts to fail to produce rewards
uv run scripts/validate_example_wandb.py ${{ steps.rag_train.outputs.project_name }} ${{ steps.rag_train.outputs.run_name }} --reward-tolerance 5
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
================================================
FILE: .github/workflows/examples-spider.yml
================================================
name: Examples - Spider
permissions:
contents: read
on:
schedule:
# Every day at 4 AM UTC+8
- cron: '0 20 * * *'
workflow_dispatch:
repository_dispatch:
types: [ci-spider, ci-all]
run-name: >-
${{ github.event_name == 'repository_dispatch'
&& format(
'Spider - PR #{0} - {1} - {2}',
github.event.client_payload.pull_number,
github.event.client_payload.ci_label,
github.event.client_payload.correlation_id
)
|| format('Spider - {0}', github.event_name) }}
jobs:
spider:
if: >
github.event_name != 'repository_dispatch' ||
github.event.action == 'ci-spider' ||
github.event.action == 'ci-all'
name: Spider (Python ${{ matrix.python-version }}, ${{ matrix.setup-script }})
runs-on: [self-hosted, 1ES.Pool=agl-runner-gpu]
timeout-minutes: 60
strategy:
matrix:
include:
# legacy is omitted because langchain doesn't work with legacy vllm versions
- python-version: '3.12'
setup-script: 'stable'
- python-version: '3.13'
setup-script: 'latest'
fail-fast: false
steps:
- name: Check GPU status
run: nvidia-smi
- name: Check disk space
run: df -h
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.pr_ref || (github.event.pull_request.number && format('refs/pull/{0}/merge', github.event.pull_request.number)) || github.ref }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Upgrade dependencies (latest)
run: uv lock --upgrade
if: matrix.setup-script == 'latest'
- name: Sync dependencies (latest)
run: |
uv sync --frozen --no-default-groups --extra verl \
--group dev --group experiment --group agents --group langchain --group torch-gpu-stable
if: matrix.setup-script == 'latest'
- name: Sync dependencies (stable)
run: |
uv sync --frozen --no-default-groups --extra verl \
--group dev --group experiment --group agents --group langchain --group torch-gpu-${{ matrix.setup-script }}
if: matrix.setup-script == 'stable'
- name: Freeze dependencies
run: |
set -ex
uv pip freeze | tee requirements-freeze.txt
echo "UV_LOCKED=1" >> $GITHUB_ENV
echo "UV_NO_SYNC=1" >> $GITHUB_ENV
- name: Upload dependencies artifact
uses: actions/upload-artifact@v6
with:
name: dependencies-spider-${{ matrix.python-version }}-${{ matrix.setup-script }}
path: requirements-freeze.txt
compression-level: 0
- name: Launch LiteLLM Proxy
run: |
./scripts/litellm_run.sh
env:
AZURE_API_BASE: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_BASE }}
AZURE_API_KEY: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_KEY }}
- name: Prepare Spider dataset
run: |
set -ex
cd examples/spider
uv run gdown --fuzzy https://drive.google.com/file/d/1oi9J1jZP9TyM35L85CL3qeGWl2jqlnL6/view
unzip -q spider-data.zip -d data
rm spider-data.zip
- name: Spider sanity check
run: |
set -ex
cd examples/spider
uv run sql_agent.py
env:
OPENAI_API_BASE: http://localhost:12306/
OPENAI_API_KEY: dummy
if: success() || failure()
- name: Spider training
run: |
set -ex
source .venv/bin/activate
cd examples/spider
../../scripts/restart_ray.sh
sleep 5
PYTHONUNBUFFERED=1 python train_sql_agent.py fast
sleep 10
shell: bash
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
id: spider_train
- name: Validate Spider training
run: |
set -ex
uv run scripts/validate_example_wandb.py ${{ steps.spider_train.outputs.project_name }} ${{ steps.spider_train.outputs.run_name }} --reward-tolerance 5
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
================================================
FILE: .github/workflows/examples-tinker.yml
================================================
name: Examples - Tinker
permissions:
contents: read
on:
schedule:
# Every day at 3 AM UTC+8
- cron: '0 19 * * *'
workflow_dispatch:
repository_dispatch:
types: [ci-tinker, ci-all]
run-name: >-
${{ github.event_name == 'repository_dispatch'
&& format(
'Tinker - PR #{0} - {1} - {2}',
github.event.client_payload.pull_number,
github.event.client_payload.ci_label,
github.event.client_payload.correlation_id
)
|| format('Tinker - {0}', github.event_name) }}
jobs:
tinker:
if: >
github.event_name != 'repository_dispatch' ||
github.event.action == 'ci-tinker' ||
github.event.action == 'ci-all'
name: Tinker (Python ${{ matrix.python-version }}, ${{ matrix.setup-script }})
runs-on: [self-hosted, 1ES.Pool=agl-runner-cpu]
timeout-minutes: 150
strategy:
matrix:
include:
- python-version: '3.12'
setup-script: 'stable'
- python-version: '3.13'
setup-script: 'latest'
fail-fast: false
steps:
- name: Check disk space
run: df -h
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.pr_ref || (github.event.pull_request.number && format('refs/pull/{0}/merge', github.event.pull_request.number)) || github.ref }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Upgrade dependencies (latest)
run: uv lock --upgrade
if: matrix.setup-script == 'latest'
- name: Sync dependencies
run: |
uv sync --frozen --no-default-groups \
--group dev --group experiment --group agents --group torch-cpu --group core-stable --group tinker
- name: Freeze dependencies
run: |
set -euo pipefail
uv pip freeze | tee requirements-freeze.txt
echo "UV_LOCKED=1" >> $GITHUB_ENV
echo "UV_NO_SYNC=1" >> $GITHUB_ENV
- name: Upload dependencies artifact
uses: actions/upload-artifact@v6
with:
name: dependencies-tinker-${{ matrix.python-version }}-${{ matrix.setup-script }}
path: requirements-freeze.txt
compression-level: 0
# TODO: Currently only test the client tracer implementation.
- name: Tinker LLM sanity check (tracer text)
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/tinker
python -m tests.test_tinker_llm tracer-text
shell: bash
env:
TINKER_API_KEY: ${{ secrets.TINKER_API_KEY }}
- name: Tinker LLM sanity check (tracer tool)
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/tinker
python -m tests.test_tinker_llm tracer-tool
shell: bash
env:
TINKER_API_KEY: ${{ secrets.TINKER_API_KEY }}
- name: Tinker Hello
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/tinker
python hello.py oneclick --ci
shell: bash
env:
TINKER_API_KEY: ${{ secrets.TINKER_API_KEY }}
- name: Tinker Q20 Evaluate (GPT-4.1)
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/tinker
mkdir -p logs
python q20_evaluate.py --ci --model gpt-4.1 --output-file logs/q20_evaluate_gpt-4.1.jsonl
shell: bash
env:
OPENAI_BASE_URL: ${{ secrets.AZURE_OPENAI_ENDPOINT_SWEDEN }}
OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY_SWEDEN }}
CREWAI_DISABLE_TELEMETRY: true
TINKER_API_KEY: ${{ secrets.TINKER_API_KEY }}
- name: Tinker Q20 Evaluate (Qwen3-30B-A3B-Instruct-2507)
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/tinker
python q20_evaluate.py --ci --model Qwen/Qwen3-30B-A3B-Instruct-2507 --output-file logs/q20_evaluate_qwen3-30b-a3b.jsonl
shell: bash
env:
OPENAI_BASE_URL: ${{ secrets.AZURE_OPENAI_ENDPOINT_SWEDEN }}
OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY_SWEDEN }}
CREWAI_DISABLE_TELEMETRY: true
TINKER_API_KEY: ${{ secrets.TINKER_API_KEY }}
- name: Tinker Q20 Training Dry Run
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/tinker
python q20_train.py dryrun --model qwen4b
shell: bash
env:
OPENAI_BASE_URL: ${{ secrets.AZURE_OPENAI_ENDPOINT_SWEDEN }}
OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY_SWEDEN }}
CREWAI_DISABLE_TELEMETRY: true
TINKER_API_KEY: ${{ secrets.TINKER_API_KEY }}
- name: Tinker Q20 Training
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/tinker
agl store --port 4747 &
sleep 5
python q20_train.py runner --n-runners 4 &
sleep 5
python q20_train.py algo --model qwen4b --ci
sleep 5
pkill -f agl && echo "SIGTERM sent to agl" || echo "No agl process found"
while pgrep -f agl; do
echo "Waiting for agl to finish..."
sleep 5
done
pkill -f q20_train.py && echo "SIGTERM sent to q20_train.py" || echo "No q20_train.py process found"
while pgrep -f q20_train.py; do
echo "Waiting for q20_train.py to finish..."
sleep 5
done
echo "q20_train.py has finished."
shell: bash
env:
OPENAI_BASE_URL: ${{ secrets.AZURE_OPENAI_ENDPOINT_SWEDEN }}
OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY_SWEDEN }}
CREWAI_DISABLE_TELEMETRY: true
TINKER_API_KEY: ${{ secrets.TINKER_API_KEY }}
================================================
FILE: .github/workflows/examples-unsloth.yml
================================================
name: Examples - Unsloth
permissions:
contents: read
on:
schedule:
# Every day at 5 AM UTC+8
- cron: '0 21 * * *'
workflow_dispatch:
repository_dispatch:
types: [ci-unsloth, ci-all]
run-name: >-
${{ github.event_name == 'repository_dispatch'
&& format(
'Unsloth - PR #{0} - {1} - {2}',
github.event.client_payload.pull_number,
github.event.client_payload.ci_label,
github.event.client_payload.correlation_id
)
|| format('Unsloth - {0}', github.event_name) }}
jobs:
unsloth:
if: >
github.event_name != 'repository_dispatch' ||
github.event.action == 'ci-unsloth' ||
github.event.action == 'ci-all'
name: Unsloth (Python ${{ matrix.python-version }}, ${{ matrix.setup-script }})
runs-on: [self-hosted, 1ES.Pool=agl-runner-gpu]
timeout-minutes: 60
strategy:
matrix:
# Legacy versions are not supported for Unsloth examples.
include:
- python-version: '3.12'
setup-script: 'stable'
- python-version: '3.13'
setup-script: 'latest'
fail-fast: false
steps:
- name: Check GPU status
run: nvidia-smi
- name: Check disk space
run: df -h
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.pr_ref || (github.event.pull_request.number && format('refs/pull/{0}/merge', github.event.pull_request.number)) || github.ref }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Upgrade dependencies (latest)
run: uv lock --upgrade
if: matrix.setup-script == 'latest'
- name: Sync dependencies
run: |
uv sync --frozen --no-default-groups --extra verl \
--group dev --group experiment --group trl --group agents --group torch-gpu-stable
- name: Freeze dependencies
run: |
set -ex
uv pip freeze | tee requirements-freeze.txt
echo "UV_LOCKED=1" >> $GITHUB_ENV
echo "UV_NO_SYNC=1" >> $GITHUB_ENV
- name: Upload dependencies artifact
uses: actions/upload-artifact@v6
with:
name: dependencies-unsloth-${{ matrix.python-version }}-${{ matrix.setup-script }}
path: requirements-freeze.txt
compression-level: 0
- name: Prepare Unsloth model
run: |
set -ex
cd examples/unsloth
rm -rf models
uv run hf download unsloth/Qwen3-4B-Instruct-2507 --local-dir models/version_0
- name: Unsloth SFT example
run: |
set -ex
source .venv/bin/activate
cd examples/unsloth
agl store --port 4747 &
sleep 5
python sft_rollout_runners.py &
sleep 5
python sft_algorithm.py
pkill -f agl && echo "SIGTERM sent to agl" || echo "No agl process found"
while pgrep -f agl; do
echo "Waiting for agl to finish..."
sleep 5
done
pkill -f sft_rollout_runners.py && echo "SIGTERM sent to sft_rollout_runners.py" || echo "No sft_rollout_runners.py process found"
while pgrep -f sft_rollout_runners.py; do
echo "Waiting for sft_rollout_runners.py to finish..."
sleep 5
done
echo "sft_rollout_runners.py has finished."
sleep 10
# Check models/version_2 must exist
if [ ! -d "models/version_2" ]; then
echo "models/version_2 does not exist"
exit 1
fi
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
- name: Unsloth SFT example all-in-one
run: |
set -ex
source .venv/bin/activate
cd examples/unsloth
rm -rf models/version_1 models/version_2
python sft_allinone.py
if [ ! -d "models/version_2" ]; then
echo "models/version_2 does not exist"
exit 1
fi
env:
WANDB_BASE_URL: ${{ secrets.MSR_WANDB_BASE_URL }}
WANDB_API_KEY: ${{ secrets.MSR_WANDB_API_KEY }}
================================================
FILE: .github/workflows/issue-comment.yml
================================================
name: Issue Comment
on:
issue_comment:
types: [created]
permissions:
pull-requests: write
issues: write
contents: write
actions: read
jobs:
dispatch:
# Only run for comments on pull requests AND when the comment starts with "/ci"
if: >
github.event.issue.pull_request != null &&
startsWith(github.event.comment.body, '/ci')
runs-on: ubuntu-latest
outputs:
dispatched: ${{ steps.dispatch.outputs.dispatched }}
event_types: ${{ steps.dispatch.outputs.event_types }}
correlation_id: ${{ steps.dispatch.outputs.correlation_id }}
trigger_comment_id: ${{ steps.dispatch.outputs.trigger_comment_id }}
ack_comment_id: ${{ steps.ack.outputs.comment_id }}
steps:
- name: Guardrail — allow only members/collaborators
id: guard
uses: actions/github-script@v8
with:
script: |
const allowed = ['MEMBER','OWNER','COLLABORATOR'];
const assoc = context.payload.comment.author_association;
if (!allowed.includes(assoc)) {
core.notice(`Ignoring /ci from ${context.payload.comment.user.login} (author_association=${assoc}).`);
core.setOutput('skip', 'true');
}
- name: Trigger repository dispatch
id: dispatch
if: steps.guard.outputs.skip != 'true'
uses: actions/github-script@v8
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const pull_number = context.payload.issue.number;
const comment = context.payload.comment;
// Fetch current PR state
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number });
// Add reaction so folks know we saw it
try {
await github.rest.reactions.createForIssueComment({
owner,
repo,
comment_id: comment.id,
content: 'rocket'
});
} catch (e) {
core.info('Could not add reaction (likely due to permissions). Continuing.');
}
const labels = (pr.labels ?? []).map(label => label.name);
const directCiLabels = labels.filter(label => label.startsWith('ci-'));
const hasCiAll = directCiLabels.includes('ci-all');
const dedupe = new Set(
directCiLabels.filter(label => label !== 'ci-all')
);
if (!hasCiAll && dedupe.size === 0) {
core.notice('No ci-* labels found on the pull request; nothing to dispatch.');
core.setOutput('dispatched', 'false');
core.setOutput('event_types', '');
return;
}
const correlation_id = `id-${comment.id}-${Date.now().toString(36)}`;
const clientPayload = {
correlation_id,
pull_number,
pr_ref: `refs/pull/${pull_number}/merge`,
pr_head_ref: pr.head.ref,
pr_head_sha: pr.head.sha,
pr_base_ref: pr.base.ref,
pr_base_sha: pr.base.sha,
trigger_comment_id: comment.id,
trigger_comment_user: comment.user.login,
};
const eventTypes = hasCiAll
? ['ci-all']
: Array.from(dedupe);
for (const eventType of eventTypes) {
await github.rest.repos.createDispatchEvent({
owner,
repo,
event_type: eventType,
client_payload: { ...clientPayload, ci_label: eventType }
});
core.notice(`Dispatched '${eventType}' event for PR #${pull_number}.`);
}
core.setOutput('dispatched', 'true');
core.setOutput('event_types', eventTypes.join(','));
core.setOutput('correlation_id', correlation_id);
core.setOutput('trigger_comment_id', String(comment.id));
- name: Acknowledge in thread (optional)
if: steps.guard.outputs.skip != 'true' && steps.dispatch.outputs.dispatched == 'true'
id: ack
uses: actions/github-script@v8
env:
EVENT_TYPES: ${{ steps.dispatch.outputs.event_types }}
CORRELATION_ID: ${{ steps.dispatch.outputs.correlation_id }}
with:
script: |
const eventTypes = (process.env.EVENT_TYPES || '')
.split(',')
.map(label => label.trim())
.filter(Boolean);
const formatted = eventTypes.map(label => `\`repository_dispatch:${label}\``).join(', ');
const { owner, repo } = context.repo;
const issue_number = context.payload.issue.number;
const body = [
`✅ CI trigger requested by @${context.payload.comment.user.login}.`,
`Fired ${formatted}.`,
'',
`_Collecting run links for correlation \`${process.env.CORRELATION_ID}\`…_`
].join('\n');
const { data: comment } = await github.rest.issues.createComment({
owner, repo, issue_number,
body
});
core.setOutput('comment_id', String(comment.id));
- name: Notify missing ci label
if: steps.guard.outputs.skip != 'true' && steps.dispatch.outputs.dispatched != 'true'
uses: actions/github-script@v8
with:
script: |
const { owner, repo } = context.repo;
const issue_number = context.payload.issue.number;
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: `⚠️ CI trigger ignored because the pull request has no \`ci-*\` labels (e.g. \`ci-apo\`, \`ci-calc-x\`). Add the desired labels and try \`/ci\` again.`
});
watch:
needs: dispatch
if: needs.dispatch.outputs.dispatched == 'true'
runs-on: ubuntu-latest
timeout-minutes: 180
steps:
- name: Track dispatched runs and update comment
uses: actions/github-script@v8
env:
CORRELATION_ID: ${{ needs.dispatch.outputs.correlation_id }}
ACK_COMMENT_ID: ${{ needs.dispatch.outputs.ack_comment_id }}
TRIGGER_COMMENT_ID: ${{ needs.dispatch.outputs.trigger_comment_id }}
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const correlationId = process.env.CORRELATION_ID;
if (!correlationId) {
core.warning('No correlation id supplied; nothing to watch.');
return;
}
const ackCommentId = Number(process.env.ACK_COMMENT_ID || 0);
if (!ackCommentId) {
core.warning('No comment id available for updates; skipping watch.');
return;
}
const triggerCommentId = Number(process.env.TRIGGER_COMMENT_ID || 0);
if (!triggerCommentId) {
core.warning('No trigger comment id available; skipping watch.');
return;
}
const prefix = `🚀 CI Watcher for correlation ${correlationId} triggered by comment ${triggerCommentId}`;
core.notice(`Watching workflow runs for correlation '${correlationId}' using comment ${ackCommentId}.`);
function fmt(run) {
const status = run.status;
const conclusion = run.conclusion;
const badge = status === 'completed'
? (conclusion === 'success' ? '🟢' : conclusion === 'failure' ? '🔴' : '🟡')
: (status === 'in_progress' ? '🟣' : '⚪️');
const title = run.display_title || run.name || `run ${run.id}`;
const statusText = status === 'completed' ? `${status}/${conclusion}` : status;
return `- ${badge} [${title}](${run.html_url}) — \`${statusText}\``;
}
const signatureOf = runs =>
runs
.map(run => `${run.id}:${run.status}/${run.conclusion || ''}`)
.sort()
.join('|');
const deadlineMs = Date.now() + 175 * 60 * 1000; // 175 minutes
let found = [];
async function searchOnce() {
const runs = await github.paginate(
github.rest.actions.listWorkflowRunsForRepo,
{ owner, repo, event: 'repository_dispatch', per_page: 100 }
);
const cutoff = new Date(Date.now() - 60 * 60 * 1000); // last hour
return runs.filter(run => {
const createdAt = new Date(run.created_at);
const title = String(run.display_title || run.name || '');
return createdAt >= cutoff && title.includes(correlationId);
});
}
while (Date.now() < deadlineMs) {
found = await searchOnce();
if (found.length > 0) {
core.notice(`Discovered ${found.length} workflow run(s) for correlation '${correlationId}'.`);
break;
}
core.notice(`No runs found yet for correlation '${correlationId}'; retrying shortly.`);
await new Promise(res => setTimeout(res, 10000));
}
if (found.length === 0) {
core.notice(`Watcher timed out with no runs for correlation '${correlationId}'; notifying thread.`);
await github.rest.issues.updateComment({
owner,
repo,
comment_id: ackCommentId,
body: [
prefix,
`⚠️ I couldn't find any workflow runs for correlation \`${correlationId}\`.`,
`They may be delayed or misconfigured.`
].join('\n')
});
return;
}
const runIds = new Set(found.map(run => run.id));
let lastSignature = '';
async function refreshRuns() {
const ids = Array.from(runIds);
const refreshed = [];
for (const id of ids) {
const { data } = await github.rest.actions.getWorkflowRun({
owner,
repo,
run_id: id
});
refreshed.push(data);
}
return refreshed;
}
async function updateCommentIfChanged(runs, allDone) {
const signature = signatureOf(runs);
if (signature === lastSignature) {
// Run statuses unchanged; skipping comment update.
return;
}
lastSignature = signature;
core.notice(`Updating comment ${ackCommentId} with ${runs.length} run status entries (allDone=${allDone}).`);
await github.rest.issues.updateComment({
owner,
repo,
comment_id: ackCommentId,
body: [
prefix,
`🏃♀️ Tracking ${runs.length} workflow run(s):`,
'',
...runs.map(fmt),
'',
allDone ? '✅ All runs completed.' : '_Still running…_'
].join('\n')
});
}
await updateCommentIfChanged(found, found.every(run => run.status === 'completed'));
while (Date.now() < deadlineMs) {
const latest = await searchOnce();
for (const run of latest) {
if (!runIds.has(run.id)) {
runIds.add(run.id);
core.notice(`Detected additional run ${run.id} (${run.name || run.display_title || 'unnamed'}) for correlation '${correlationId}'.`);
}
}
const current = await refreshRuns();
const allDone = current.every(run => run.status === 'completed');
await updateCommentIfChanged(current, allDone);
if (allDone) {
core.notice(`All runs for correlation '${correlationId}' completed; stopping watcher.`);
break;
}
await new Promise(res => setTimeout(res, 60000));
}
if (Date.now() >= deadlineMs) {
core.warning(`Watcher hit the deadline while monitoring correlation '${correlationId}'.`);
}
================================================
FILE: .github/workflows/playground.yml
================================================
# Pre-defined workflow with workflow_dispatch trigger,
# convenient for testing and debugging.
name: Playground
permissions:
contents: read
on:
workflow_dispatch:
jobs:
playground:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Run script
run: |
echo "Hello, world!"
================================================
FILE: .github/workflows/pypi-nightly.yml
================================================
name: PyPI Nightly Build
on:
schedule:
# Run daily at 6:00 AM UTC+8
- cron: '0 22 * * *'
workflow_dispatch: # Allow manual trigger
jobs:
publish-test-pypi:
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
contents: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Sync dependencies
run: uv sync --frozen --no-default-groups --group dev
- uses: actions/setup-node@v6
with:
node-version: '22'
- name: Install JavaScript dependencies
run: cd dashboard && npm ci
- name: Build dashboard
run: cd dashboard && npm run build
- name: Get current version
id: get_version
run: |
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Current version: $VERSION"
- name: Create development version
run: |
# Create a dev version with timestamp
TIMESTAMP=$(date +%Y%m%d%H%M%S)
DEV_VERSION="${{ steps.get_version.outputs.version }}.dev$TIMESTAMP"
echo "Creating dev version: $DEV_VERSION"
./scripts/bump_version.sh "$DEV_VERSION"
- name: Build package
run: |
uv build
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
================================================
FILE: .github/workflows/pypi-release.yml
================================================
name: PyPI Release
on:
push:
tags:
- 'v*' # Trigger on version tags like v1.0.0, v1.2.3, etc.
workflow_dispatch: # Allow manual trigger
jobs:
check-version:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
version: ${{ steps.get_version.outputs.version }}
tag_version: ${{ steps.get_tag.outputs.tag_version }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Get version from pyproject.toml
id: get_version
run: |
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Package version: $VERSION"
- name: Get tag version
id: get_tag
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
echo "tag_version=$TAG_VERSION" >> $GITHUB_OUTPUT
echo "Tag version: $TAG_VERSION"
- name: Verify version matches tag
run: |
if [ "${{ steps.get_version.outputs.version }}" != "${{ steps.get_tag.outputs.tag_version }}" ]; then
echo "Error: Version in pyproject.toml (${{ steps.get_version.outputs.version }}) does not match tag (${{ steps.get_tag.outputs.tag_version }})"
exit 1
fi
echo "Version check passed!"
publish-pypi:
needs: check-version
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
contents: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Sync dependencies
run: uv sync --frozen --no-default-groups --group dev
- uses: actions/setup-node@v6
with:
node-version: '22'
- name: Install JavaScript dependencies
run: cd dashboard && npm ci
- name: Build dashboard
run: cd dashboard && npm run build
- name: Build package
run: |
uv build
- name: Verify package contents
run: |
uv run --locked --no-sync python -m tarfile -l dist/*.tar.gz
uv run --locked --no-sync python -m zipfile -l dist/*.whl
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
================================================
FILE: .github/workflows/tests-full.yml
================================================
name: GPU Test
permissions:
contents: read
on:
schedule:
# Every day at 5 AM UTC+8
- cron: '0 21 * * *'
workflow_dispatch:
repository_dispatch:
types: [ci-gpu, ci-all]
run-name: >-
${{ github.event_name == 'repository_dispatch'
&& format(
'GPU Test - PR #{0} - {1} - {2}',
github.event.client_payload.pull_number,
github.event.client_payload.ci_label,
github.event.client_payload.correlation_id
)
|| format('GPU Test - {0}', github.event_name) }}
jobs:
tests-full:
if: >
github.event_name != 'repository_dispatch' ||
github.event.action == 'ci-gpu' ||
github.event.action == 'ci-all'
name: Full Test (${{ matrix.mark.display-name }}, ${{ matrix.env.setup-script }}, Python ${{ matrix.env.python-version }})
runs-on: ${{ matrix.mark.runs-on }}
timeout-minutes: 30
strategy:
matrix:
mark:
- id: store
display-name: Store
pytest-mark: 'store' # store tests should not require gpu
runs-on: ubuntu-latest
has-gpu: false
# AgentOps needs to be separated because it injects tricky global state.
- id: agentops
display-name: AgentOps
pytest-mark: 'agentops' # including agentops+litellm tests here
runs-on: [self-hosted, 1ES.Pool=agl-runner-gpu]
has-gpu: true
# Similar for Weave.
- id: weave
display-name: Weave
pytest-mark: 'weave'
runs-on: ubuntu-latest # No GPU tests for Weave.
has-gpu: false
# Other tests that require GPU
- id: gpu
display-name: GPU required
pytest-mark: '(gpu or llmproxy) and not agentops'
runs-on: [self-hosted, 1ES.Pool=agl-runner-gpu]
has-gpu: true
# Other uncovered tests
- id: others
display-name: Others
pytest-mark: 'not store and not agentops and not weave and not gpu and not llmproxy'
runs-on: ubuntu-latest
has-gpu: false
env:
- python-version: '3.10'
setup-script: 'legacy'
- python-version: '3.12'
setup-script: 'stable'
- python-version: '3.13'
setup-script: 'latest'
fail-fast: false
steps:
- name: Check GPU status
if: matrix.mark.has-gpu
run: nvidia-smi
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.pr_ref || (github.event.pull_request.number && format('refs/pull/{0}/merge', github.event.pull_request.number)) || github.ref }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.env.python-version }}
- name: Upgrade dependencies (latest)
run: uv lock --upgrade
if: matrix.env.setup-script == 'latest'
- name: Sync dependencies (latest, gpu)
if: matrix.env.setup-script == 'latest' && matrix.mark.has-gpu
run: uv sync --frozen --no-default-groups --extra apo --extra weave --extra mongo --group dev --group agents --group langchain --group torch-gpu-stable
# Don't install vllm/pytorch on CPU counterparts
- name: Sync dependencies (latest, cpu)
if: matrix.env.setup-script == 'latest' && !matrix.mark.has-gpu
run: uv sync --frozen --no-default-groups --extra apo --extra weave --extra mongo --group dev --group agents --group langchain --group core-stable
- name: Sync dependencies (stable, gpu)
if: matrix.env.setup-script == 'stable' && matrix.mark.has-gpu
run: uv sync --frozen --no-default-groups --extra apo --extra weave --extra mongo --group dev --group agents --group langchain --group torch-gpu-${{ matrix.env.setup-script }}
- name: Sync dependencies (stable, cpu)
if: matrix.env.setup-script == 'stable' && !matrix.mark.has-gpu
run: uv sync --frozen --no-default-groups --extra apo --extra weave --extra mongo --group dev --group agents --group langchain --group core-stable
# Don't install langchain for legacy dependency because it has conflicts with torch.
- name: Sync dependencies (legacy, gpu)
if: matrix.env.setup-script == 'legacy' && matrix.mark.has-gpu
run: uv sync --frozen --no-default-groups --extra apo --extra weave --extra mongo --group dev --group agents --group torch-gpu-legacy
- name: Sync dependencies (legacy, cpu)
if: matrix.env.setup-script == 'legacy' && !matrix.mark.has-gpu
run: uv sync --frozen --no-default-groups --extra apo --extra weave --extra mongo --group dev --group agents --group core-legacy
- name: Freeze dependencies
run: |
set -ex
uv pip freeze | tee requirements-freeze.txt
echo "UV_LOCKED=1" >> $GITHUB_ENV
echo "UV_NO_SYNC=1" >> $GITHUB_ENV
- name: Upload dependencies artifact
uses: actions/upload-artifact@v6
with:
name: dependencies-tests-full-${{ matrix.mark.id }}-${{ matrix.env.python-version }}-${{ matrix.env.setup-script }}
path: requirements-freeze.txt
compression-level: 0
- uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: dashboard/package-lock.json
- name: Install JavaScript dependencies
run: cd dashboard && npm ci
- name: Build dashboard
run: cd dashboard && npm run build
- name: Setup Docker environments
run: ./scripts/mongodb_docker_run.sh
shell: bash
- name: Launch LiteLLM Proxy
run: |
./scripts/litellm_run.sh
env:
AZURE_API_BASE: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_BASE }}
AZURE_API_KEY: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_KEY }}
# mongo, openai, gpu, all enabled by default
- name: Run tests
run: |
uv run pytest -v --durations=0 tests -m "${{ matrix.mark.pytest-mark }}${{ matrix.env.setup-script == 'legacy' && ' and not langchain' || '' }}"
env:
PYTEST_ADDOPTS: "--color=yes"
OPENAI_BASE_URL: http://localhost:12306/
OPENAI_API_KEY: dummy
AGL_TEST_MONGO_URI: mongodb://localhost:27017/?replicaSet=rs0
minimal-examples:
if: >
github.event_name != 'repository_dispatch' ||
github.event.action == 'ci-gpu' ||
github.event.action == 'ci-all'
name: Minimal Examples with Python ${{ matrix.python-version }} (${{ matrix.setup-script }})
runs-on: [self-hosted, 1ES.Pool=agl-runner-gpu]
timeout-minutes: 30
strategy:
matrix:
include:
- python-version: '3.10'
setup-script: 'legacy'
- python-version: '3.12'
setup-script: 'stable'
- python-version: '3.13'
setup-script: 'latest'
fail-fast: false
steps:
- name: Check GPU status
run: nvidia-smi
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.pr_ref || (github.event.pull_request.number && format('refs/pull/{0}/merge', github.event.pull_request.number)) || github.ref }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Upgrade dependencies (latest)
run: uv lock --upgrade
if: matrix.setup-script == 'latest'
- name: Sync dependencies (latest)
run: uv sync --frozen --no-default-groups --extra apo --group dev --group agents --group langchain --group torch-gpu-stable
if: matrix.setup-script == 'latest'
- name: Sync dependencies (stable)
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group langchain --group torch-gpu-${{ matrix.setup-script }}
if: matrix.setup-script == 'stable'
# Don't install langchain for legacy dependency because it has conflicts with torch.
- name: Sync dependencies (legacy)
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group torch-gpu-legacy
if: matrix.setup-script == 'legacy'
- name: Freeze dependencies
run: |
set -ex
uv pip freeze | tee requirements-freeze.txt
echo "UV_LOCKED=1" >> $GITHUB_ENV
echo "UV_NO_SYNC=1" >> $GITHUB_ENV
- name: Upload dependencies artifact
uses: actions/upload-artifact@v6
with:
name: dependencies-minimal-examples-${{ matrix.python-version }}-${{ matrix.setup-script }}
path: requirements-freeze.txt
compression-level: 0
- name: Launch LiteLLM Proxy
run: |
./scripts/litellm_run.sh
env:
AZURE_API_BASE: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_BASE }}
AZURE_API_KEY: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_KEY }}
- name: Write Traces via Otel Tracer
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/minimal
python write_traces.py otel
sleep 5
- name: Write Traces via AgentOps Tracer
env:
OPENAI_BASE_URL: http://localhost:12306/
OPENAI_API_KEY: dummy
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/minimal
python write_traces.py agentops
sleep 5
- name: Write Traces with Operations
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/minimal
python write_traces.py operation
sleep 5
- name: Write Traces via Otel Tracer with Client
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/minimal
agl store --port 45993 --log-level DEBUG &
sleep 5
python write_traces.py otel --use-client
pkill -f agl && echo "SIGTERM sent to agl" || echo "No agl process found"
while pgrep -f agl; do
echo "Waiting for agl to finish..."
sleep 5
done
- name: Write Traces via AgentOps Tracer with Client
env:
OPENAI_BASE_URL: http://localhost:12306/
OPENAI_API_KEY: dummy
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/minimal
agl store --port 45993 --log-level DEBUG &
sleep 5
python write_traces.py agentops --use-client
pkill -f agl && echo "SIGTERM sent to agl" || echo "No agl process found"
while pgrep -f agl; do
echo "Waiting for agl to finish..."
sleep 5
done
- name: vLLM Server
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/minimal
python vllm_server.py Qwen/Qwen2.5-0.5B-Instruct
- name: LLM Proxy (OpenAI backend)
env:
OPENAI_API_BASE: http://localhost:12306/
OPENAI_API_KEY: dummy
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/minimal
python llm_proxy.py openai gpt-4.1-mini &
LLM_PROXY_READY=0
for attempt in $(seq 1 30); do
if curl -sSf http://localhost:43886/health > /dev/null 2>&1; then
LLM_PROXY_READY=1
break
fi
sleep 2
done
if [[ "$LLM_PROXY_READY" != "1" ]]; then
echo "LLM proxy failed to become healthy" >&2
exit 1
fi
python llm_proxy.py test gpt-4.1-mini
pkill -f llm_proxy.py && echo "SIGTERM sent to llm_proxy.py" || echo "No llm_proxy.py process found"
while pgrep -f llm_proxy.py; do
echo "Waiting for llm_proxy.py to finish..."
sleep 5
done
- name: LLM Proxy (vLLM backend)
if: matrix.setup-script != 'legacy' # Skip if return_token_ids is not supported
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/minimal
python llm_proxy.py vllm Qwen/Qwen2.5-0.5B-Instruct &
LLM_PROXY_READY=0
for attempt in $(seq 1 30); do
if curl -sSf http://localhost:43886/health > /dev/null 2>&1; then
LLM_PROXY_READY=1
break
fi
sleep 2
done
if [[ "$LLM_PROXY_READY" != "1" ]]; then
echo "LLM proxy failed to become healthy" >&2
exit 1
fi
python llm_proxy.py test Qwen/Qwen2.5-0.5B-Instruct
pkill -f llm_proxy.py && echo "SIGTERM sent to llm_proxy.py" || echo "No llm_proxy.py process found"
while pgrep -f llm_proxy.py; do
echo "Waiting for llm_proxy.py to finish..."
sleep 5
done
- name: MultiMetrics backend example
run: |
set -euo pipefail
source .venv/bin/activate
cd examples/minimal
python write_metrics.py --duration 8 --prom-port 9105 --prom-host 0.0.0.0 2>&1 | tee metrics.log &
pid=$!
for attempt in $(seq 1 20); do
if curl -sSf http://localhost:9105/metrics | grep -q minimal_requests_total; then
echo "Metrics endpoint responding"
wait $pid
cat metrics.log
exit 0
fi
sleep 1
done
echo "Metrics endpoint did not respond"
exit 1
================================================
FILE: .github/workflows/tests.yml
================================================
name: CPU Test
permissions:
contents: read
on:
push:
branches: [ main, stable/**/* ]
pull_request:
branches: [ main, stable/**/* ]
workflow_dispatch:
schedule:
# Every day at noon and midnight
- cron: '0 0,12 * * *'
jobs:
lint:
strategy:
matrix:
setup: [fast, slow, next]
fail-fast: false
name: Lint - ${{ matrix.setup }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: '3.12'
- name: Sync dependencies (fast)
run: uv sync --frozen --group dev --no-default-groups
if: matrix.setup == 'fast'
- name: Upgrade dependencies (next)
run: uv lock --upgrade
if: matrix.setup == 'next'
- name: Sync dependencies (slow)
run: |
uv sync --frozen \
--extra apo \
--extra weave \
--extra verl \
--extra mongo \
--group dev \
--group torch-cpu \
--group torch-stable \
--group trl \
--group tinker \
--group agents \
--group langchain \
--no-default-groups
if: matrix.setup != 'fast'
# This pre-commit skips JavaScript on purpose.
- name: Run pre-commit
uses: pre-commit/action@v3.0.1
- name: Check Python headers
run: uv run --locked --no-sync scripts/check_headers.py
if: matrix.setup == 'fast'
- name: Run Black
run: uv run --locked --no-sync black --check .
if: matrix.setup != 'next'
- name: Run isort
run: uv run --locked --no-sync isort --check-only .
if: matrix.setup != 'next'
- name: Run pyright (fast)
run: uv run --locked --no-sync pyright -p pyrightconfig.fast.json
if: matrix.setup == 'fast'
- name: Run pyright (slow)
run: uv run --locked --no-sync pyright -p pyrightconfig.json
if: matrix.setup != 'fast'
lint-js:
name: Lint - JavaScript
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: dashboard/package-lock.json
- name: Install dependencies
run: cd dashboard && npm ci
- name: Run ESLint
run: cd dashboard && npm run eslint
- name: Run Prettier
run: cd dashboard && npm run prettier
- name: Run Stylelint
run: cd dashboard && npm run stylelint
- name: Run Typecheck
run: cd dashboard && npm run typecheck
- name: Verify build
run: cd dashboard && npm run build
docs:
name: Build documentation
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Sync dependencies
run: uv sync --frozen --no-default-groups --group dev
- name: Set source commit for docs
run: |
echo "SOURCE_COMMIT=${{ github.sha }}" >> $GITHUB_ENV
- name: Verify OpenAPI specification is up-to-date
run: |
uv run --locked --no-sync python scripts/export_openapi.py
git diff --exit-code docs/assets/store-openapi.json
- name: Build documentation
run: uv run --locked --no-sync mkdocs build --strict
- name: Upload docs artifact
uses: actions/upload-artifact@v6
with:
name: documentation-site
path: site/
compression-level: 6
test:
strategy:
matrix:
mark:
# store has many tests and is a good isolated group.
- id: store
display-name: Store
pytest-mark: 'store'
# AgentOps needs to be separated because it injects tricky global state.
- id: agentops
display-name: AgentOps
pytest-mark: 'agentops'
# Similar for Weave.
- id: weave
display-name: Weave
pytest-mark: 'weave'
# litellm proxy tests are slow
- id: llmproxy
display-name: LLM proxy
pytest-mark: 'llmproxy'
# Robustness of utilities is important. There are many tests.
- id: utils
display-name: Utilities
pytest-mark: 'utils'
# unmarked tests: adapter, execution engine, etc.
- id: others
display-name: Others
pytest-mark: 'not store and not agentops and not weave and not llmproxy and not utils'
env:
- python-version: '3.10'
setup-script: 'legacy'
- python-version: '3.11'
setup-script: 'stable'
- python-version: '3.12'
setup-script: 'stable'
- python-version: '3.13'
setup-script: 'latest'
fail-fast: false
name: Test (${{ matrix.mark.display-name }}, ${{ matrix.env.setup-script }}, Python ${{ matrix.env.python-version }})
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.env.python-version }}
- name: Upgrade dependencies (latest)
run: uv lock --upgrade
if: matrix.env.setup-script == 'latest'
- name: Sync dependencies (latest)
run: uv sync --frozen --no-default-groups --extra apo --extra weave --group dev --group agents --group langchain --group core-stable
if: matrix.env.setup-script == 'latest'
- name: Sync dependencies (stable & legacy)
run: uv sync --frozen --no-default-groups --extra apo --extra weave --group dev --group agents --group langchain --group core-${{ matrix.env.setup-script }}
if: matrix.env.setup-script != 'latest'
- name: Freeze dependencies
run: |
set -ex
uv pip freeze | tee requirements-freeze.txt
echo "UV_LOCKED=1" >> $GITHUB_ENV
echo "UV_NO_SYNC=1" >> $GITHUB_ENV
- name: Upload dependencies artifact
uses: actions/upload-artifact@v6
with:
name: dependencies-${{ matrix.mark.id }}-${{ matrix.env.python-version }}-${{ matrix.env.setup-script }}
path: requirements-freeze.txt
compression-level: 0
- uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: dashboard/package-lock.json
- name: Install JavaScript dependencies
run: cd dashboard && npm ci
- name: Build dashboard
run: cd dashboard && npm run build
- name: Run tests
run: |
uv run pytest -v --durations=0 tests -m "not mongo and not openai and not gpu and (${{ matrix.mark.pytest-mark }})"
env:
PYTEST_ADDOPTS: "--color=yes"
test-js:
name: Test (JavaScript)
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: dashboard/package-lock.json
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: '3.12'
- name: Sync Python dependencies
run: uv sync --frozen --no-default-groups --extra apo --group dev --group agents --group core-stable
- name: Install JavaScript dependencies
run: cd dashboard && npm ci
- name: Run vitest
run: cd dashboard && npm run vitest
================================================
FILE: .gitignore
================================================
# Agentlightning specific files
verl_old
meta-llama/**
**/debug/**/*.png
**/debug/**/*.json
requirements-freeze*.txt
/playground
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# MacOS
.DS_Store
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Abstra
# Abstra is an AI-powered process automation framework.
# Ignore directories containing user credentials, local state, and settings.
# Learn more at https://abstra.io/docs
.abstra/
# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# you could uncomment the following to ignore the enitre vscode folder
.vscode/
# Emacs backup files
*~
# Ruff stuff:
.ruff_cache/
# PyPI configuration file
.pypirc
# Cursor
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
# refer to https://docs.cursor.com/context/ignore-files
.cursorignore
.cursorindexingignore
# Claude
.claude/*.local.json
# Dashboard generated files
agentlightning/dashboard/**/*.css
agentlightning/dashboard/**/*.js
agentlightning/dashboard/**/*.html
agentlightning/dashboard/**/*.svg
# Docker data
docker/data/
================================================
FILE: .pre-commit-config.yaml
================================================
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: end-of-file-fixer
exclude: (.*store-openapi\.json$)
- id: trailing-whitespace
- id: check-yaml
exclude: ^mkdocs\.yml$
- id: check-toml
- id: check-added-large-files
args: ["--maxkb=1024"]
exclude: (^uv\.lock$)|(^docs/assets/.*\.svg$)|(.*store-openapi\.json$)
- id: check-shebang-scripts-are-executable
- id: detect-private-key
- repo: https://github.com/pycqa/isort
rev: 6.0.1
hooks:
- id: isort
args: ["."]
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
pass_filenames: false
always_run: true
args: ["."]
- repo: local
hooks:
- id: prettier
name: prettier (dashboard)
language: system
pass_filenames: false
always_run: true
entry: >
bash -c '
cd dashboard || exit 1
if [ -d node_modules ]; then
echo "✅ node_modules already exists"
npx prettier --cache --write "**/*.{ts,tsx,mjs,cjs}"
else
echo "⚠️ node_modules not found — npx is not reliable. Skipping."
fi
'
- id: eslint
name: eslint (dashboard)
language: system
pass_filenames: false
always_run: true
entry: >
bash -c '
cd dashboard || exit 1
if [ -d node_modules ]; then
echo "✅ node_modules already exists"
npx eslint --cache --fix .
else
echo "⚠️ node_modules not found — npx is not reliable. Skipping."
fi
'
- id: stylelint
name: stylelint (dashboard)
language: system
pass_filenames: false
always_run: true
entry: >
bash -c '
cd dashboard || exit 1
if [ -d node_modules ]; then
echo "✅ node_modules already exists"
npx stylelint --cache --fix "**/*.css"
else
echo "⚠️ node_modules not found — npx is not reliable. Skipping."
fi
'
================================================
FILE: .python-version
================================================
3.12
================================================
FILE: AGENTS.md
================================================
# Repository Guidelines
## Architecture Overview
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.
## Project Structure & Module Organization
- `agentlightning/`: adapters, execution stack, training loop, tracer, reward logic, and the `agl` CLI.
- `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.
- `dashboard/`, `scripts/`, `tests/`: UI bundles, release/dataset/CI automation, and mirrored coverage of the runtime tree. Record download steps rather than committing binaries.
## Build, Test, and Development Commands
- `uv sync --group dev` — provision tooling once per environment.
- `uv run --no-sync pytest -v` — execute the full suite; add a path or `-k expr` to narrow the run.
- `uv run --no-sync pyright` — enforce static typing parity with CI.
- `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.
Always commit the refreshed `uv.lock` when dependencies shift, and mention optional groups (VERL, APO, GPU) in PR notes.
## Common Issues & Fixes
- When `uv run` errors with `Permission denied` under `~/.cache`, override both cache locations inline: ``UV_CACHE="$(pwd)/.cache_uv" XDG_CACHE_HOME="$(pwd)/.cache_xdg" uv run --no-sync <command>``.
## Coding Style & Naming Conventions
- 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.
- Maintain exhaustive type hints (pyright enforces them) and prefer shared dataclasses or Pydantic models from `agentlightning.types`.
- Author Google-style docstrings for new modules or public methods—succinct descriptions, no redundant type info, no redundant `Key features/components` bullet points. Use mkdocs styles: `[][]` syntax for cross-references and single backticks for inline code blocks.
- 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.
## Testing Guidelines
- Mirror runtime directories under `tests/` and match filenames for quick traceability.
- 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.
- Lean on fixtures, favor real stores/spans/agents over mocks, and drive coverage across the majority of branches.
- 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.
## Example Contributions
- 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.
- 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.
- 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.
## Commit & Pull Request Guidelines
- Branch from a fresh `main` using `feature/<slug>`, `fix/<slug>`, `docs/<slug>`, or `chore/<slug>`.
- Write imperative, scoped commits, reference issues with `Fixes #123`, and rerun pre-commit plus the relevant pytest/doc builds before pushing.
- 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.
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: RAI_README.md
================================================
# Responsible AI Transparency Documentation - Agent Lightning
## OVERVIEW
Agent Lightning is a flexible and extensible framework that enables seamless agent optimization for any existing agent framework. Agent optimization includes various data-driven techniques to customize the agent for better performance, including but not limited to model fine-tuning, prompt tuning, and model selection. And the agent frameworks refer to popular and easy-to-use agent developing frameworks such as OpenAI Agents SDK, Microsoft AutoGen, and LangChain.
### WHAT CAN AGENT LIGHTNING DO
Agent lightning was developed to bridge the gap between agent workflow development and agent optimization, empowering developers to go beyond static, pre-trained models and unlock the full potential of adaptive, learning-based agents. Agent Lightning is a training framework which can be used for any LLMs.
### INTENDED USES
Agent Lightning is best suited for agent researchers and developers. They can easily fine-tune models in existing agent frameworks with Agent Lightning. This can improve model performance on the targeted scenarios.
### OUT-OF-SCOPE USES
Agent Lightning is not well-suited for users who are not familiar with agent development and machine learning concepts.
We do not recommend using Agent Lightning in commercial or real-world applications without further testing and development. It is being released for research purposes.
Agent Lightning was not designed or evaluated for all possible downstream purposes. Developers should consider its inherent limitations as they select use cases, and evaluate and mitigate for accuracy, safety, and fairness concerns specific to each intended downstream use.
Agent Lightning should not be used in highly regulated domains where inaccurate outputs could suggest actions that lead to injury or negatively impact an individual's legal, financial, or life opportunities.
We do not recommend using Agent Lightning in the context of high-risk decision making (e.g. in law enforcement, legal, finance, or healthcare).
## HOW TO GET STARTED
To begin using Agent Lightning, here are some instructions.
1. Install dependencies, including Python, uv, PyTorch, FlashAttention, vLLM, verl.
2. Clone and install Agent Lightning.
3. Convert the dataset (provided by the user) into parquet file, which contains multiple columns. Each column contains a data id, an input and an expected output.
4. Run agent, which is developed by the user.
5. Run the training process via “bash train.sh”
## EVALUATION
Agent Lightning was evaluated on its ability to correctly complete 3 example tasks: (1) Math. The model needs to answer some math questions, and when answering one question, the model can use the calculator as its tool to help answer. (2) Text2SQL. The model is given a question related to the database, and it is required to generate a SQL which can query the database, find the information to answer the question. (3) Retrieval-Augmented Generation (RAG). The model is given a question which needs some information from Wikipedia to answer. The model is required to generate some queries to find the related information in Wikipedia, and answer the question according to retrieved documents.
### EVALUATION METHODS AND RESULTS
For detailed evaluation methods and results, please refer to the latest version of our [technical report](https://arxiv.org/abs/2508.03680).
## LIMITATIONS
Agent Lightning was developed for research and experimental purposes. Further testing and validation are needed before considering its application in commercial or real-world scenarios.
Agent Lightning was designed and tested using the English language. Performance in other languages may vary and should be assessed by someone who is both an expert in the expected outputs and a native speaker of that language.
Outputs generated by AI may include factual errors, fabrication, or speculation. Users are responsible for assessing the accuracy of generated content. All decisions leveraging outputs of the system should be made with human oversight and not be based solely on system outputs.
Agent Lightning inherits any biases, errors, or omissions produced by its base model. Developers are advised to choose an appropriate base LLM/MLLM carefully, depending on the intended use case.
We use some demo cases to show the effectiveness of our training framework. See their links to understand the capabilities and limitations of this model.
## BEST PRACTICES
Better performance can be achieved by following the instructions in how to get started section.
We strongly encourage users to use LLMs/MLLMs that support robust Responsible AI mitigations, such as Azure Open AI (AOAI) services. Such services continually update their safety and RAI mitigations with the latest industry standards for responsible use. For more on AOAI’s best practices when employing foundations models for scripts and applications:
- [Blog post on responsible AI features in AOAI that were presented at Ignite 2023](https://techcommunity.microsoft.com/t5/ai-azure-ai-services-blog/announcing-new-ai-safety-amp-responsible-ai-features-in-azure/ba-p/3983686)
- [Overview of Responsible AI practices for Azure OpenAI models](https://learn.microsoft.com/en-us/legal/cognitive-services/openai/overview)
- [Azure OpenAI Transparency Note](https://learn.microsoft.com/en-us/legal/cognitive-services/openai/transparency-note)
- [OpenAI’s Usage policies](https://openai.com/policies/usage-policies)
- [Azure OpenAI’s Code of Conduct](https://learn.microsoft.com/en-us/legal/cognitive-services/openai/code-of-conduct)
Users are responsible for sourcing their datasets legally and ethically. This could include securing appropriate rights, ensuring consent for use of audio/images, and/or the anonymization of data prior to use in research.
Users are reminded to be mindful of data privacy concerns and are encouraged to review the privacy policies associated with any models and data storage solutions interfacing with Agent Lightning.
It is the user’s responsibility to ensure that the use of Agent Lightning complies with relevant data protection regulations and organizational guidelines.
## LICENSE
We use the MIT license.
## CONTACT
We welcome feedback and collaboration from our audience. If you have suggestions, questions, or observe unexpected/offensive behavior in our technology, please contact us at agent-lightning@microsoft.com.
If the team receives reports of undesired behavior or identifies issues independently, we will update this repository with appropriate mitigations.
---
*Last updated: September 6, 2025*
*Document version: 1.0*
================================================
FILE: README.md
================================================
<p align="center">
<img src="docs/assets/readme-banner.svg" alt="Agent-lightning-banner" style="width:600px"/>
</p>
# Agent Lightning⚡
[](https://github.com/microsoft/agent-lightning/actions/workflows/badge-unit.yml)
[](https://microsoft.github.io/agent-lightning/)
[](https://badge.fury.io/py/agentlightning)
[](LICENSE)
[](https://deepwiki.com/microsoft/agent-lightning)
[](https://discord.gg/RYk7CdvDR7)
**The absolute trainer to light up AI agents.**
Join our [Discord community](https://discord.gg/RYk7CdvDR7) to connect with other users and contributors.
## ⚡ Core Features
- Turn your agent into an optimizable beast with **ZERO CODE CHANGE** (almost)! 💤
- Build with **ANY** agent framework (LangChain, OpenAI Agent SDK, AutoGen, CrewAI, Microsoft Agent Framework...); or even WITHOUT agent framework (Python OpenAI). You name it! 🤖
- **Selectively** optimize one or more agents in a multi-agent system. 🎯
- Embraces **Algorithms** like Reinforcement Learning, Automatic Prompt Optimization, Supervised Fine-tuning and more. 🤗
Read more on our [documentation website](https://microsoft.github.io/agent-lightning/).
<p align="center">
<img src="docs/assets/readme-diff.svg" alt="Agent-Lightning Core Quickstart" style="width:100%"/>
</p>
## ⚡ Installation
```bash
pip install agentlightning
```
For the latest nightly build (cutting-edge features), you can install from Test PyPI:
```bash
pip install --upgrade --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ --pre agentlightning
```
Please refer to our [installation guide](https://microsoft.github.io/agent-lightning/stable/tutorials/installation/) for more details.
To start using Agent-lightning, check out our [documentation](https://microsoft.github.io/agent-lightning/) and [examples](./examples).
## ⚡ Articles
- 12/17/2025 [Adopting the Trajectory Level Aggregation for Faster Training](https://agent-lightning.github.io/posts/trajectory_level_aggregation/) Agent-lightning blog.
- 11/4/2025 [Tuning ANY AI agent with Tinker ✕ Agent-lightning](https://medium.com/@yugez/tuning-any-ai-agent-with-tinker-agent-lightning-part-1-1d8c9a397f0e) Medium. See also [Part 2](https://medium.com/@yugez/tuning-any-ai-agent-with-tinker-agent-lightning-part-2-332c5437f0dc).
- 10/22/2025 [No More Retokenization Drift: Returning Token IDs via the OpenAI Compatible API Matters in Agent RL](https://blog.vllm.ai/2025/10/22/agent-lightning.html) vLLM blog. See also [Zhihu writeup](https://zhuanlan.zhihu.com/p/1965067274642785725).
- 8/11/2025 [Training AI Agents to Write and Self-correct SQL with Reinforcement Learning](https://medium.com/@yugez/training-ai-agents-to-write-and-self-correct-sql-with-reinforcement-learning-571ed31281ad) Medium.
- 8/5/2025 [Agent Lightning: Train ANY AI Agents with Reinforcement Learning](https://arxiv.org/abs/2508.03680) arXiv paper.
- 7/26/2025 [We discovered an approach to train any AI agent with RL, with (almost) zero code changes.](https://www.reddit.com/r/LocalLLaMA/comments/1m9m670/we_discovered_an_approach_to_train_any_ai_agent/) Reddit.
- 6/6/2025 [Agent Lightning - Microsoft Research](https://www.microsoft.com/en-us/research/project/agent-lightning/) Project page.
## ⚡ Community Projects
- [DeepWerewolf](https://github.com/af-74413592/DeepWerewolf) — A case study of agent RL training for the Chinese Werewolf game built with AgentScope and Agent Lightning.
- [AgentFlow](https://agentflow.stanford.edu/) — A modular multi-agent framework that combines planner, executor, verifier, and generator agents with the Flow-GRPO algorithm to tackle long-horizon, sparse-reward tasks.
- [Youtu-Agent](https://github.com/TencentCloudADP/Youtu-agent) — Youtu-Agent lets you build and train your agent with ease. Built with [a modified branch](https://github.com/microsoft/agent-lightning/tree/contrib/youtu-agent-lightning) of Agent Lightning, Youtu-Agent has verified up to 128 GPUs RL training on maths/code and search capabilities with steady convergence. Also check [the recipe](https://github.com/TencentCloudADP/youtu-agent/tree/rl/agl) and their blog [*Stop Wrestling with Your Agent RL: How Youtu-Agent Achieved Stable, 128-GPU Scaling Without Breaking a Sweat*](https://spotted-coconut-df8.notion.site/Stop-Wrestling-with-Your-Agent-RL-How-Youtu-Agent-Achieved-Stable-128-GPU-Scaling-Without-Breaking-2ca5e8f089ba80539a98c582b65e0233).
## ⚡ Architecture
Agent Lightning keeps the moving parts to a minimum so you can focus on your idea, not the plumbing. Your agent continues to run as usual; you can still use any agent framework you like; you drop in the lightweight `agl.emit_xxx()` helper, or let the tracer collect every prompt, tool call, and reward. Those events become structured spans that flow into the LightningStore, a central hub that keeps tasks, resources, and traces in sync.
On the other side of the store sits the algorithm you choose, or write yourself. The algorithm reads spans, learns from them, and posts updated resources such as refined prompt templates or new policy weights. The Trainer ties it all together: it streams datasets to runners, ferries resources between the store and the algorithm, and updates the inference engine when improvements land. You can either stop there, or simply let the same loop keep turning.
No rewrites, no lock-in, just a clear path from first rollout to steady improvement.
<p align="center">
<img src="docs/assets/readme-architecture.svg" alt="Agent-lightning Architecture" style="width:100%"/>
</p>
## ⚡ CI Status
| Workflow | Status |
|----------|--------|
| CPU Tests | [](https://github.com/microsoft/agent-lightning/actions/workflows/tests.yml) |
| Full Tests | [](https://github.com/microsoft/agent-lightning/actions/workflows/badge-unit.yml) |
| UI Tests | [](https://github.com/microsoft/agent-lightning/actions/workflows/dashboard.yml) |
| Examples Integration | [](https://github.com/microsoft/agent-lightning/actions/workflows/badge-examples.yml) |
| Latest Dependency Compatibility | [](https://github.com/microsoft/agent-lightning/actions/workflows/badge-latest.yml) |
| Legacy Examples Compatibility | [](https://github.com/microsoft/agent-lightning/actions/workflows/badge-compat.yml) |
## ⚡ Citation
If you find Agent Lightning useful in your research or projects, please cite our paper:
```bibtex
@misc{luo2025agentlightningtrainai,
title={Agent Lightning: Train ANY AI Agents with Reinforcement Learning},
author={Xufang Luo and Yuge Zhang and Zhiyuan He and Zilong Wang and Siyun Zhao and Dongsheng Li and Luna K. Qiu and Yuqing Yang},
year={2025},
eprint={2508.03680},
archivePrefix={arXiv},
primaryClass={cs.AI},
url={https://arxiv.org/abs/2508.03680},
}
```
## ⚡ Contributing
This project welcomes contributions and suggestions. Start by reading the [Contributing Guide](docs/community/contributing.md) for recommended contribution points, environment setup, branching conventions, and pull request expectations. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
## ⚡ Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.
## ⚡ Responsible AI
This project has been evaluated and certified to comply with the Microsoft Responsible AI Standard. The team will continue to monitor and maintain the repository, addressing any severe issues, including potential harms, if they arise.
## ⚡ License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
================================================
FILE: SECURITY.md
================================================
<!-- BEGIN MICROSOFT SECURITY.MD V1.0.0 BLOCK -->
## Security
Microsoft takes the security of our software products and services seriously, which
includes all source code repositories in our GitHub organizations.
**Please do not report security vulnerabilities through public GitHub issues.**
For security reporting information, locations, contact information, and policies,
please review the latest guidance for Microsoft repositories at
[https://aka.ms/SECURITY.md](https://aka.ms/SECURITY.md).
<!-- END MICROSOFT SECURITY.MD BLOCK -->
================================================
FILE: agentlightning/__init__.py
================================================
# Copyright (c) Microsoft. All rights reserved.
__version__ = "0.3.1"
from .adapter import *
from .algorithm import *
from .client import AgentLightningClient, DevTaskLoader # deprecated # type: ignore
from .config import *
from .emitter import *
from .env_var import *
from .execution import *
from .litagent import *
from .llm_proxy import *
from .logging import configure_logger # deprecated # type: ignore
from .logging import setup as setup_logging # type: ignore
from .logging import setup_module as setup_module_logging # type: ignore
from .runner import *
from .server import AgentLightningServer # deprecated # type: ignore
from .store import *
from .tracer import *
from .trainer import *
from .types import *
================================================
FILE: agentlightning/adapter/__init__.py
================================================
# Copyright (c) Microsoft. All rights reserved.
from .base import Adapter, OtelTraceAdapter, TraceAdapter
from .messages import TraceToMessages
from .triplet import LlmProxyTraceToTriplet, TracerTraceToTriplet, TraceToTripletBase
__all__ = [
"TraceAdapter",
"OtelTraceAdapter",
"Adapter",
"TraceToTripletBase",
"TracerTraceToTriplet",
"LlmProxyTraceToTriplet",
"TraceToMessages",
]
================================================
FILE: agentlightning/adapter/base.py
================================================
# Copyright (c) Microsoft. All rights reserved.
from typing import Generic, Sequence, TypeVar
from opentelemetry.sdk.trace import ReadableSpan
from agentlightning.types import Span
T_from = TypeVar("T_from")
T_to = TypeVar("T_to")
class Adapter(Generic[T_from, T_to]):
"""Base class for synchronous adapters that convert data from one format to another.
The class defines a minimal protocol so that adapters can be treated like callables while
still allowing subclasses to supply the concrete transformation logic.
!!! note
Subclasses must override [`adapt()`][agentlightning.Adapter.adapt] to provide
the actual conversion.
Type Variables:
T_from: Source data type supplied to the adapter.
T_to: Target data type produced by the adapter.
Examples:
>>> class IntToStrAdapter(Adapter[int, str]):
... def adapt(self, source: int) -> str:
... return str(source)
...
>>> adapter = IntToStrAdapter()
>>> adapter(42)
'42'
"""
def __call__(self, source: T_from, /) -> T_to:
"""Convert the data to the target format.
This method delegates to [`adapt()`][agentlightning.Adapter.adapt] so that an
instance of [`Adapter`][agentlightning.Adapter] can be used like a standard
function.
Args:
source: Input data in the source format.
Returns:
Data converted to the target format.
"""
return self.adapt(source)
def adapt(self, source: T_from, /) -> T_to:
"""Convert the data to the target format.
Subclasses must override this method with the concrete transformation logic. The base
implementation raises `NotImplementedError` to make the requirement explicit.
Args:
source: Input data in the source format.
Returns:
Data converted to the target format.
"""
raise NotImplementedError("Adapter.adapt() is not implemented")
class OtelTraceAdapter(Adapter[Sequence[ReadableSpan], T_to], Generic[T_to]):
"""Base class for adapters that convert OpenTelemetry trace spans into other formats.
This specialization of [`Adapter`][agentlightning.Adapter] expects a list of
`opentelemetry.sdk.trace.ReadableSpan` instances and produces any target format, such as
reinforcement learning trajectories, structured logs, or analytics-ready payloads.
Examples:
>>> class TraceToDictAdapter(OtelTraceAdapter[dict]):
... def adapt(self, spans: List[ReadableSpan]) -> dict:
... return {"count": len(spans)}
...
>>> adapter = TraceToDictAdapter()
>>> adapter([span1, span2])
{'count': 2}
"""
class TraceAdapter(Adapter[Sequence[Span], T_to], Generic[T_to]):
"""Base class for adapters that convert trace spans into other formats.
This class specializes [`Adapter`][agentlightning.Adapter] for working with
[`Span`][agentlightning.Span] instances emitted by Agent Lightning instrumentation.
Subclasses receive entire trace slices and return a format suited for the downstream consumer,
for example reinforcement learning training data or observability metrics.
"""
================================================
FILE: agentlightning/adapter/messages.py
================================================
# Copyright (c) Microsoft. All rights reserved.
from __future__ import annotations
import json
from collections import defaultdict
from typing import TYPE_CHECKING, Any, Dict, Generator, Iterable, List, Optional, Sequence, TypedDict, Union, cast
from pydantic import TypeAdapter
from agentlightning.types import Span
from .base import TraceAdapter
if TYPE_CHECKING:
from openai.types.chat import (
ChatCompletionFunctionToolParam,
ChatCompletionMessageFunctionToolCallParam,
ChatCompletionMessageParam,
)
class OpenAIMessages(TypedDict):
"""OpenAI-style chat messages with optional tool definitions.
Attributes:
messages: Ordered chat messages that describe the conversation.
tools: Tool specifications available to the assistant, if any.
"""
messages: List[ChatCompletionMessageParam]
tools: Optional[List[ChatCompletionFunctionToolParam]]
class _RawSpanInfo(TypedDict):
"""Intermediate representation parsed from a span.
Attributes:
prompt: Prompt messages reconstructed from span attributes.
completion: Assistant completions following tool invocations.
request: Request payload recorded in the trace.
response: Response payload recorded in the trace.
tools: Tool call metadata extracted from child spans.
"""
prompt: List[Dict[str, Any]]
completion: List[Dict[str, Any]]
request: Dict[str, Any]
response: Dict[str, Any]
tools: List[Dict[str, Any]]
def group_genai_dict(data: Dict[str, Any], prefix: str) -> Union[Dict[str, Any], List[Any]]:
"""Convert flattened trace attributes into nested structures.
Attributes emitted by the tracing pipeline often arrive as dotted paths (for example
`gen_ai.prompt.0.role`). This helper groups those keys into nested dictionaries or lists so that
downstream processing can operate on structured data.
Args:
data: Flat dictionary whose keys are dotted paths.
prefix: Top-level key (for example `gen_ai.prompt`) that determines which attributes are
grouped.
Returns:
A nested dictionary (no numeric index detected) or list (numeric indices detected) containing
the grouped values.
"""
result: Union[Dict[str, Any], List[Any]] = {}
# Collect keys that match the prefix
relevant = {k[len(prefix) + 1 :]: v for k, v in data.items() if k.startswith(prefix + ".")}
# Detect if we have numeric indices (-> list) or not (-> dict)
indexed = any(part.split(".")[0].isdigit() for part in relevant.keys())
if indexed:
# Group by index
grouped: Dict[int, Dict[str, Any]] = defaultdict(dict)
for k, v in relevant.items():
parts = k.split(".")
if not parts[0].isdigit():
continue
idx, rest = int(parts[0]), ".".join(parts[1:])
grouped[idx][rest] = v
# Recursively build
result = []
for i in sorted(grouped.keys()):
result.append(group_genai_dict({f"{prefix}.{rest}": val for rest, val in grouped[i].items()}, prefix))
else:
# No indices: build dict
nested: Dict[str, Any] = defaultdict(dict)
for k, v in relevant.items():
if "." in k:
head, _tail = k.split(".", 1)
nested[head][f"{prefix}.{k}"] = v
else:
result[k] = v
# Recurse into nested dicts
for head, subdict in nested.items():
result[head] = group_genai_dict(subdict, prefix + "." + head)
return result
def convert_to_openai_messages(prompt_completion_list: List[_RawSpanInfo]) -> Generator[OpenAIMessages, None, None]:
"""Convert raw trace payloads into OpenAI-style chat messages.
The function consumes an iterable produced by
[`TraceToMessages.adapt()`][agentlightning.TraceToMessages.adapt] and yields
structures that match the OpenAI fine-tuning JSONL schema, including tool definitions.
Args:
prompt_completion_list: Raw prompt/completion/tool payloads extracted from a trace.
Returns:
A generator that yields [`OpenAIMessages`][agentlightning.adapter.messages.OpenAIMessages]
entries compatible with the OpenAI Functions fine-tuning format.
"""
# Import locally to avoid legacy OpenAI version type import errors
from openai.types.chat import (
ChatCompletionAssistantMessageParam,
ChatCompletionFunctionToolParam,
ChatCompletionMessageFunctionToolCallParam,
ChatCompletionMessageParam,
)
for pc_entry in prompt_completion_list:
messages: List[ChatCompletionMessageParam] = []
# Extract messages
for msg in pc_entry["prompt"]:
role = msg["role"]
if role == "assistant" and "tool_calls" in msg:
# Use the tool_calls directly
# This branch is usually not used in the wild.
tool_calls: List[ChatCompletionMessageFunctionToolCallParam] = [
ChatCompletionMessageFunctionToolCallParam(
id=call["id"],
type="function",
function={"name": call["name"], "arguments": call["arguments"]},
)
for call in msg["tool_calls"]
]
messages.append(
ChatCompletionAssistantMessageParam(role="assistant", content=None, tool_calls=tool_calls)
)
else:
# Normal user/system/tool content
message = cast(
ChatCompletionMessageParam,
TypeAdapter(ChatCompletionMessageParam).validate_python(
dict(role=role, content=msg.get("content", ""), tool_call_id=msg.get("tool_call_id", None))
),
)
messages.append(message)
# Extract completions (assistant outputs after tool responses)
for comp in pc_entry["completion"]:
if comp.get("role") == "assistant":
content = comp.get("content")
if pc_entry["tools"]:
tool_calls = [
ChatCompletionMessageFunctionToolCallParam(
id=tool["call"]["id"],
type=tool["call"]["type"],
function={"name": tool["name"], "arguments": tool["parameters"]},
)
for tool in pc_entry["tools"]
]
messages.append(
ChatCompletionAssistantMessageParam(role="assistant", content=content, tool_calls=tool_calls)
)
else:
messages.append(ChatCompletionAssistantMessageParam(role="assistant", content=content))
# Build tools definitions (if available)
if "functions" in pc_entry["request"]:
tools = [
ChatCompletionFunctionToolParam(
type="function",
function={
"name": fn["name"],
"description": fn.get("description", ""),
"parameters": (
json.loads(fn["parameters"]) if isinstance(fn["parameters"], str) else fn["parameters"]
),
},
)
for fn in pc_entry["request"]["functions"]
]
yield OpenAIMessages(messages=messages, tools=tools)
else:
yield OpenAIMessages(messages=messages, tools=None)
class TraceToMessages(TraceAdapter[List[OpenAIMessages]]):
"""Convert trace spans into OpenAI-compatible conversation messages.
The adapter reconstructs prompts, completions, tool calls, and function definitions from
`gen_ai.*` span attributes. The resulting objects match the JSONL structure expected by the
OpenAI fine-tuning pipeline.
!!! warning
The adapter assumes all spans share a common trace and that tool call spans are direct
children of the associated completion span.
"""
def get_tool_calls(self, completion: Span, all_spans: Sequence[Span], /) -> Iterable[Dict[str, Any]]:
"""Yield tool call payloads for a completion span.
Args:
completion: The completion span whose descendants should be inspected.
all_spans: The complete span list belonging to the trace.
Yields:
Dictionaries describing tool calls with identifiers, names, and arguments.
Raises:
ValueError: If a candidate tool span cannot be converted into a dictionary.
"""
# Get all the spans that are children of the completion span
children = [span for span in all_spans if span.parent_id == completion.span_id]
# Get the tool calls from the children
for maybe_tool_call in children:
tool_call = group_genai_dict(maybe_tool_call.attributes, "tool")
if not isinstance(tool_call, dict):
raise ValueError(f"Extracted tool call from trace is not a dict: {tool_call}")
if tool_call:
yield tool_call
def adapt(self, source: Sequence[Span], /) -> List[OpenAIMessages]:
"""Transform trace spans into OpenAI chat payloads.
Args:
source: Spans containing `gen_ai.*` attributes emitted by the tracing pipeline.
Returns:
A list of [`OpenAIMessages`][agentlightning.adapter.messages.OpenAIMessages] entries that
capture prompts, completions, tools, and metadata.
"""
raw_prompt_completions: List[_RawSpanInfo] = []
for span in source:
attributes = {k: v for k, v in span.attributes.items()}
# Get all related information from the trace span
prompt = group_genai_dict(attributes, "gen_ai.prompt") or []
completion = group_genai_dict(attributes, "gen_ai.completion") or []
request = group_genai_dict(attributes, "gen_ai.request") or {}
response = group_genai_dict(attributes, "gen_ai.response") or {}
if not isinstance(prompt, list):
raise ValueError(f"Extracted prompt from trace is not a list: {prompt}")
if not isinstance(completion, list):
raise ValueError(f"Extracted completion from trace is not a list: {completion}")
if not isinstance(request, dict):
raise ValueError(f"Extracted request from trace is not a dict: {request}")
if not isinstance(response, dict):
raise ValueError(f"Extracted response from trace is not a dict: {response}")
if prompt or completion or request or response:
tools = list(self.get_tool_calls(span, source)) or []
raw_prompt_completions.append(
_RawSpanInfo(
prompt=prompt or [], completion=completion, request=request, response=response, tools=tools
)
)
return list(convert_to_openai_messages(raw_prompt_completions))
================================================
FILE: agentlightning/adapter/triplet.py
================================================
# Copyright (c) Microsoft. All rights reserved.
from __future__ import annotations
import json
import logging
import re
from enum import Enum
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union, cast
from opentelemetry.sdk.trace import ReadableSpan
from pydantic import BaseModel
from agentlightning.emitter.reward import get_reward_value
from agentlightning.semconv import AGL_OPERATION, AGL_REWARD, LightningSpanAttributes
from agentlightning.types import Span, Triplet
from agentlightning.utils.otel import filter_and_unflatten_attributes
from .base import TraceAdapter
logger = logging.getLogger(__name__)
def _attributes_get_multiple(attributes: Dict[str, Any], keys: List[str]) -> Optional[str]:
"""Get a string from the attributes, if present.
If there are multiple matches, the first one is returned.
"""
for key in keys:
if key in attributes:
if isinstance(attributes[key], str):
return attributes[key]
else:
logger.warning(f"Attribute {key} is found but is not a string: {attributes[key]}")
return None
def _attributes_get_ids_multiple(attributes: Dict[str, Any], keys: List[str]) -> Optional[List[int]]:
"""Get a list of integers from the attributes, if present.
If there are multiple matches, the first one is returned.
"""
for key in keys:
if key in attributes:
if (isinstance(attributes[key], list) or isinstance(attributes[key], tuple)) and all(
isinstance(x, int) for x in attributes[key]
):
return list(attributes[key])
else:
logger.warning(f"Attribute {key} is found but is not a list of integers: {attributes[key]}")
return None
def _attributes_unflatten_multiple(
attributes: Dict[str, Any], keys: List[str]
) -> Union[Dict[str, Any], List[Any], None]:
"""Unflatten the attributes, if present.
If there are multiple matches, the first one is returned.
"""
for key in keys:
result = filter_and_unflatten_attributes(attributes, key)
if result:
return result
return None
class Transition(BaseModel):
"""A single transition within a reinforcement learning trajectory.
Attributes:
state: Token identifiers describing the model input state.
action: Token identifiers representing the model output.
response_id: Identifier of the LLM response used to deduplicate spans.
agent_name: Human-readable agent name captured from the trace.
reward: Scalar reward associated with the transition, if available.
"""
state: List[int]
action: List[int]
response_id: Optional[str]
# action_logprobs: List[float]
agent_name: str
reward: Optional[float]
class RewardMatchPolicy(str, Enum):
"""Strategies for matching rewards to LLM call spans.
!!! note
Each reward span must expose a payload shaped like `{"type": "reward", "value": <float>|None}`
as described in `reward.py`.
"""
FIRST_SIBLING = "first_sibling"
"""Use the first sibling in the current trace subtree as the reward unless another LLM call match is found."""
FIRST_OCCURRENCE = "first_occurrence"
"""Use the first reward encountered in chronological order after the current LLM call match."""
class TraceTree:
"""Tree representation of a trace span and its descendants.
Attributes:
id: Unique identifier for the span node.
span: [`Span`][agentlightning.Span] backing this node.
children: Child nodes connected to the current span.
"""
def __init__(
self,
id: str,
span: Span,
children: Optional[List["TraceTree"]] = None,
):
self.id = id
self.span = span
self.children = children or []
@property
def start_time(self):
return self.span.start_time
@property
def end_time(self):
return self.span.end_time
def find_id(self, id: str) -> "TraceTree | None":
if self.id == id:
return self
for child in self.children:
found = child.find_id(id)
if found:
return found
return None
def add_child(self, child: "TraceTree") -> None:
self.children.append(child)
def visualize(self, filename: str, interested_span_match: str | None = None) -> None:
"""Render the trace tree with Graphviz for debugging purposes.
Args:
filename: Base filename for the generated `.png` diagram.
interested_span_match: Optional regular expression used to keep only matching spans
(and their ancestors) in the output.
!!! note
The method requires the optional `graphviz` dependency to be available in the runtime
environment.
"""
import graphviz
dot = graphviz.Digraph(comment="Trace Tree")
should_visit_cache: Dict[str, bool] = {}
def should_visit(node: "TraceTree") -> bool:
if node.id in should_visit_cache:
return should_visit_cache[node.id]
if interested_span_match is not None:
if re.search(interested_span_match, node.span.name):
should_visit_cache[node.id] = True
return True
else:
should_visit_cache[node.id] = False
for child in node.children:
if should_visit(child):
should_visit_cache[node.id] = True
return should_visit_cache[node.id]
else:
return True
def visit(node: "TraceTree") -> bool:
if not should_visit(node):
return False
agent_name = node.agent_name()
vis_name = node.id[-8:] + " (" + node.span.name + ")"
if agent_name is not None:
vis_name += " [" + agent_name + "]"
dot.node(node.id, vis_name) # type: ignore
for child in node.children:
if visit(child):
dot.edge(node.id, child.id) # type: ignore
return True
visit(self)
dot.render(filename, format="png", cleanup=True) # type: ignore
def names_tuple(self) -> Tuple[str, List[Any]]:
"""Return the span name alongside nested child names.
Returns:
A tuple of the current span name and a list of tuples for each child containing the
child name and its descendants.
"""
name = self.span.name
agent_name = self.agent_name()
if agent_name is not None:
name += " [" + agent_name + "]"
children_names: List[Tuple[str, List[Any]]] = []
for child in self.children:
child_name, child_children = child.names_tuple()
children_names.append((child_name, child_children))
return name, children_names
def traverse(self) -> List["TraceTree"]:
"""Traverse the tree depth first and return every node."""
spans: List["TraceTree"] = [self]
for child in self.children:
spans.extend(child.traverse())
return spans
def to_json(self) -> dict[str, Any]:
"""Convert the tree node into a JSON-serialisable structure."""
if isinstance(self.span, ReadableSpan):
span_data = json.loads(self.span.to_json())
else:
span_data = self.span.model_dump()
return {
"id": self.id,
"span": span_data,
"children": [child.to_json() for child in self.children],
}
@classmethod
def from_spans(cls, spans: List[Span]) -> "TraceTree":
"""Construct a tree from a flat list of spans.
Args:
spans: Spans that collectively form a single trace segment.
Returns:
A [`TraceTree`][agentlightning.adapter.triplet.TraceTree] rooted at either the
discovered root span or a synthetic root when multiple roots are present.
Raises:
ValueError: If the span list is empty or no root span can be inferred.
"""
if not spans:
raise ValueError("No spans provided to create TraceTree.")
# Process trace items in topological order
id_to_span = {span.span_id: span for span in spans}
forward_graph: dict[str, list[str]] = {}
root_ids: list[str] = []
for span in spans:
span_id = span.span_id
if span.parent_id is None:
root_ids.append(span.span_id)
else:
if span.parent_id not in forward_graph:
forward_graph[span.parent_id] = []
forward_graph[span.parent_id].append(span_id)
# Diff between span with data and forward_graph keys
# Sometimes the top-level session span is lost.
unfound_roots = set(forward_graph.keys()) - set(id_to_span.keys())
for unfound_root in unfound_roots:
root_ids.append(unfound_root)
def visit(node_id: str) -> "TraceTree":
children: list[TraceTree] = []
if node_id in forward_graph:
for child_id in forward_graph[node_id]:
children.append(visit(child_id))
if node_id not in id_to_span:
assert len(children) > 0
virtual_span = Span.from_attributes(
rollout_id=children[0].span.rollout_id,
attempt_id=children[0].span.attempt_id,
sequence_id=children[0].span.sequence_id,
trace_id=children[0].span.trace_id,
span_id=node_id,
parent_id=None,
attributes={},
start_time=min(child.start_time for child in children if child.start_time is not None),
end_time=max(child.end_time for child in children if child.end_time is not None),
)
return cls(node_id, virtual_span, children=children)
else:
return cls(
node_id,
id_to_span[node_id],
children=children,
)
# Create a virtual root span if multiple root spans are found
if len(root_ids) > 1:
root_spans = [visit(root_id) for root_id in root_ids]
virtual_root = TraceTree(
id="virtual-root",
span=Span.from_attributes(
rollout_id=root_spans[0].span.rollout_id,
attempt_id=root_spans[0].span.attempt_id,
sequence_id=root_spans[0].span.sequence_id,
trace_id=root_spans[0].span.trace_id,
span_id=None, # Generate one
parent_id=None,
name="virtual-root",
attributes={},
start_time=root_spans[0].start_time,
end_time=root_spans[-1].end_time,
),
children=root_spans,
)
return virtual_root
elif len(root_ids) == 0:
# No root spans found
raise ValueError("No root spans found in the trace.")
else:
root_span = visit(root_ids[0])
return root_span
def agent_name(self) -> Optional[str]:
"""Return the agent name associated with the span, if any.
Returns:
Agent name extracted from known attributes, otherwise `None`.
"""
attributes = self.span.attributes
if attributes is None: # type: ignore
return None
# Case 1: OpenAI Agent SDK
agent_name = cast(Optional[str], attributes.get("agent.name"))
if agent_name is not None:
return agent_name
# Case 2: Agentops decorator @agent
is_agent = attributes.get("agentops.span.kind") == "agent"
if is_agent:
agent_name = cast(Optional[str], attributes.get("operation.name"))
if agent_name is not None:
return agent_name
# Case 3: Autogen team
agent_name = cast(Optional[str], attributes.get("recipient_agent_type"))
if agent_name is not None:
return agent_name
# Case 4: LangGraph
agent_name = cast(Optional[str], attributes.get("langchain.chain.type"))
if agent_name is not None:
return agent_name
# Case 5: agent-framework
agent_name = cast(Optional[str], attributes.get("executor.id"))
if agent_name is not None:
return agent_name
# Case 6: Weave
is_agent_type = attributes.get("type") == "agent"
if is_agent_type:
agent_name = cast(Optional[str], attributes.get("agentlightning.operation.input.name"))
if agent_name is not None:
return agent_name
# Case 7: Weave + LangChain
if self.span.name.startswith("langchain.Chain."):
attributes_lc_name = cast(Optional[str], attributes.get("lc_name"))
if attributes_lc_name is not None:
return attributes_lc_name
def maybe_reward_dict(self) -> dict[str, Any]:
"""Return a reward payload if the span encodes one.
Returns:
Dictionary containing reward metadata, or an empty dictionary when no reward is found.
"""
reward_value = get_reward_value(self.span)
if reward_value is not None:
return {"type": "reward", "value": reward_value}
else:
return {}
def is_reward_span(self) -> bool:
"""Return whether the span explicitly encodes a reward.
Returns:
`True` when the span payload describes a reward, otherwise `False`.
"""
maybe_reward = self.maybe_reward_dict()
if maybe_reward and maybe_reward.get("type") == "reward": # type: ignore
return True
# Agent-lightning 0.3+
if (
self.span.name == AGL_OPERATION
and self.span.attributes.get(LightningSpanAttributes.OPERATION_NAME.value) == AGL_REWARD
):
return True
return False
def find_llm_calls(
self,
*,
llm_call_match: str,
agent_match: Optional[str],
within_matching_subtree: str | None = None,
within_reward: Optional[bool] = None,
within_llm_call: Optional[bool] = None,
existing_llm_call_response_ids: Optional[set[str]] = None,
) -> List[Tuple["TraceTree", str]]:
"""Find LLM call spans matching the supplied filters.
Args:
llm_call_match: Regular expression used to match span names that qualify as LLM calls.
agent_match: Optional regular expression that must match the enclosing agent span name.
within_matching_subtree: Marker propagated through recursive calls to record matching agents.
within_reward: When `True`, suppresses LLM matches under reward spans.
within_llm_call: When `True`, prevents duplicate matches for nested LLM calls.
existing_llm_call_response_ids: Known response identifiers used to deduplicate spans.
Returns:
A list of tuples pairing the matching node with the agent subtree label that triggered the
match.
"""
llm_calls: List[Tuple[TraceTree, str]] = []
is_llm_call = True
if within_matching_subtree is None or within_reward is True:
# We must be in an interesting agent subtree, and not in a reward span.
is_llm_call = False
if re.search(llm_call_match, self.span.name) is None:
# The span name does not match the LLM call match.
is_llm_call = False
if is_llm_call:
# Check the response id
response_id = _attributes_get_multiple(
self.span.attributes, ["gen_ai.response.id", "agentlightning.operation.output.id"]
)
if response_id is None and within_llm_call is True:
is_llm_call = False
if (
response_id is not None
and existing_llm_call_response_ids is not None
and response_id in existing_llm_call_response_ids
):
is_llm_call = False
if is_llm_call:
llm_calls.append((self, within_matching_subtree)) # type: ignore
if existing_llm_call_response_ids is None:
existing_llm_call_response_ids = set()
if response_id is not None:
existing_llm_call_response_ids.add(response_id)
if within_llm_call is not None:
within_llm_call = True
agent_name = self.agent_name()
if agent_name is not None:
if agent_match is None or re.search(agent_match, agent_name):
gitextract_mrw4kizu/
├── .dockerignore
├── .github/
│ └── workflows/
│ ├── backport.yml
│ ├── badge-apo.yml
│ ├── badge-azure.yml
│ ├── badge-calc-x.yml
│ ├── badge-chartqa.yml
│ ├── badge-claude-code.yml
│ ├── badge-compat.yml
│ ├── badge-examples.yml
│ ├── badge-latest.yml
│ ├── badge-rag.yml
│ ├── badge-spider.yml
│ ├── badge-tinker.yml
│ ├── badge-unit.yml
│ ├── badge-unsloth.yml
│ ├── benchmark.yml
│ ├── dashboard.yml
│ ├── docs.yml
│ ├── examples-apo.yml
│ ├── examples-azure.yml
│ ├── examples-calc-x.yml
│ ├── examples-chartqa.yml
│ ├── examples-claude-code.yml
│ ├── examples-compat.yml
│ ├── examples-rag.yml
│ ├── examples-spider.yml
│ ├── examples-tinker.yml
│ ├── examples-unsloth.yml
│ ├── issue-comment.yml
│ ├── playground.yml
│ ├── pypi-nightly.yml
│ ├── pypi-release.yml
│ ├── tests-full.yml
│ └── tests.yml
├── .gitignore
├── .pre-commit-config.yaml
├── .python-version
├── AGENTS.md
├── LICENSE
├── RAI_README.md
├── README.md
├── SECURITY.md
├── agentlightning/
│ ├── __init__.py
│ ├── adapter/
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── messages.py
│ │ └── triplet.py
│ ├── algorithm/
│ │ ├── __init__.py
│ │ ├── apo/
│ │ │ ├── __init__.py
│ │ │ ├── apo.py
│ │ │ └── prompts/
│ │ │ ├── apply_edit_variant01.poml
│ │ │ ├── apply_edit_variant02.poml
│ │ │ ├── text_gradient_variant01.poml
│ │ │ ├── text_gradient_variant02.poml
│ │ │ └── text_gradient_variant03.poml
│ │ ├── base.py
│ │ ├── decorator.py
│ │ ├── fast.py
│ │ ├── utils.py
│ │ └── verl/
│ │ ├── __init__.py
│ │ └── interface.py
│ ├── cli/
│ │ ├── __init__.py
│ │ ├── prometheus.py
│ │ ├── store.py
│ │ └── vllm.py
│ ├── client.py
│ ├── config.py
│ ├── emitter/
│ │ ├── __init__.py
│ │ ├── annotation.py
│ │ ├── exception.py
│ │ ├── message.py
│ │ ├── object.py
│ │ └── reward.py
│ ├── env_var.py
│ ├── execution/
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── client_server.py
│ │ ├── events.py
│ │ ├── inter_process.py
│ │ └── shared_memory.py
│ ├── instrumentation/
│ │ ├── __init__.py
│ │ ├── agentops.py
│ │ ├── agentops_langchain.py
│ │ ├── litellm.py
│ │ ├── vllm.py
│ │ └── weave.py
│ ├── litagent/
│ │ ├── __init__.py
│ │ ├── decorator.py
│ │ └── litagent.py
│ ├── llm_proxy.py
│ ├── logging.py
│ ├── reward.py
│ ├── runner/
│ │ ├── __init__.py
│ │ ├── agent.py
│ │ ├── base.py
│ │ └── legacy.py
│ ├── semconv.py
│ ├── server.py
│ ├── store/
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── client_server.py
│ │ ├── collection/
│ │ │ ├── __init__.py
│ │ │ ├── base.py
│ │ │ ├── memory.py
│ │ │ └── mongo.py
│ │ ├── collection_based.py
│ │ ├── memory.py
│ │ ├── mongo.py
│ │ ├── sqlite.py
│ │ ├── threading.py
│ │ └── utils.py
│ ├── tracer/
│ │ ├── __init__.py
│ │ ├── agentops.py
│ │ ├── base.py
│ │ ├── dummy.py
│ │ ├── otel.py
│ │ └── weave.py
│ ├── trainer/
│ │ ├── __init__.py
│ │ ├── init_utils.py
│ │ ├── legacy.py
│ │ ├── registry.py
│ │ └── trainer.py
│ ├── types/
│ │ ├── __init__.py
│ │ ├── core.py
│ │ ├── resources.py
│ │ └── tracer.py
│ ├── utils/
│ │ ├── __init__.py
│ │ ├── id.py
│ │ ├── metrics.py
│ │ ├── otel.py
│ │ ├── otlp.py
│ │ ├── server_launcher.py
│ │ └── system_snapshot.py
│ └── verl/
│ ├── __init__.py
│ ├── __main__.py
│ ├── async_server.py
│ ├── config.yaml
│ ├── daemon.py
│ ├── dataset.py
│ ├── entrypoint.py
│ └── trainer.py
├── contrib/
│ ├── .gitignore
│ ├── CODEOWNERS
│ ├── README.md
│ ├── agentlightning/
│ │ └── contrib/
│ │ ├── __init__.py
│ │ ├── adapter/
│ │ │ ├── __init__.py
│ │ │ ├── agentos.py
│ │ │ └── triplet_group.py
│ │ ├── agent/
│ │ │ └── env_agent.py
│ │ ├── algorithm/
│ │ │ └── env_verl/
│ │ │ ├── daemon.py
│ │ │ └── trainer.py
│ │ ├── reward/
│ │ │ ├── __init__.py
│ │ │ └── agentos.py
│ │ └── runner/
│ │ ├── __init__.py
│ │ └── agentos.py
│ └── recipes/
│ ├── agentos/
│ │ ├── README.md
│ │ └── demo_governed_training.py
│ ├── envs/
│ │ ├── README.md
│ │ ├── add_instruction.py
│ │ ├── config_env/
│ │ │ ├── alfworld.yaml
│ │ │ └── scienceworld.yaml
│ │ ├── config_verl/
│ │ │ ├── alfworld/
│ │ │ │ └── grpo.yaml
│ │ │ └── scienceworld/
│ │ │ └── grpo.yaml
│ │ ├── install_agl.sh
│ │ ├── prompt_builder.py
│ │ └── train_env_agent.py
│ ├── search_r1/
│ │ ├── README.md
│ │ ├── data_process.sh
│ │ ├── qa_em.py
│ │ ├── retrieval_launch.sh
│ │ ├── retrieval_server.py
│ │ ├── search_r1_agent.py
│ │ └── train_search_r1_agent.py
│ └── webshop/
│ ├── .gitignore
│ ├── Dockerfile
│ ├── Makefile
│ ├── README.md
│ ├── agl/
│ │ ├── __init__.py
│ │ ├── config.py
│ │ ├── generate_tasks.py
│ │ ├── requirements.txt
│ │ ├── run_training.py
│ │ ├── sample_tasks.json
│ │ ├── tasks.py
│ │ └── webshop_tasks.json
│ ├── aml/
│ │ ├── compute.yml
│ │ ├── jobs/
│ │ │ └── webshop-qwen.yml
│ │ └── run_webshop_aml.sh
│ ├── package.json
│ ├── scripts/
│ │ ├── headless-runner.ts
│ │ └── run_stack.sh
│ ├── server/
│ │ ├── .dockerignore
│ │ ├── requirements.txt
│ │ └── webshop_server.py
│ ├── src/
│ │ ├── agent/
│ │ │ ├── prompts.ts
│ │ │ └── webshop-agent.ts
│ │ ├── data/
│ │ │ └── sample-tasks.ts
│ │ ├── environment/
│ │ │ ├── index.ts
│ │ │ ├── types.ts
│ │ │ └── webshop-server.ts
│ │ └── utils/
│ │ └── agentlightning/
│ │ ├── index.ts
│ │ ├── otel.ts
│ │ ├── proxy-llm.ts
│ │ ├── store-client.ts
│ │ └── types.ts
│ ├── tests/
│ │ ├── __init__.py
│ │ ├── conftest.py
│ │ ├── test_span_adapter.py
│ │ └── test_store_integration.py
│ ├── tsconfig.json
│ └── tsup.config.ts
├── dashboard/
│ ├── .gitignore
│ ├── .prettierrc.mjs
│ ├── .storybook/
│ │ ├── constants.ts
│ │ ├── main.ts
│ │ ├── modes.ts
│ │ ├── preview.tsx
│ │ └── vitest.setup.ts
│ ├── .stylelintignore
│ ├── .stylelintrc.json
│ ├── README.md
│ ├── eslint.config.js
│ ├── package.json
│ ├── postcss.config.cjs
│ ├── public/
│ │ ├── index.html
│ │ └── main.tsx
│ ├── src/
│ │ ├── App.tsx
│ │ ├── Router.tsx
│ │ ├── components/
│ │ │ ├── AppAlertBanner.story.tsx
│ │ │ ├── AppAlertBanner.tsx
│ │ │ ├── AppDrawer.component.tsx
│ │ │ ├── AppDrawer.story.tsx
│ │ │ ├── ResourcesTable.component.tsx
│ │ │ ├── ResourcesTable.story.tsx
│ │ │ ├── ResourcesTree.component.tsx
│ │ │ ├── ResourcesTree.story.tsx
│ │ │ ├── RolloutTable.component.tsx
│ │ │ ├── RolloutTable.story.tsx
│ │ │ ├── TracesTable.component.tsx
│ │ │ ├── TracesTable.story.tsx
│ │ │ ├── WorkersTable.component.tsx
│ │ │ └── WorkersTable.story.tsx
│ │ ├── cssVariableResolver.ts
│ │ ├── features/
│ │ │ ├── config/
│ │ │ │ ├── index.ts
│ │ │ │ ├── selectors.ts
│ │ │ │ └── slice.ts
│ │ │ ├── resources/
│ │ │ │ ├── index.ts
│ │ │ │ ├── resources.test.ts
│ │ │ │ ├── selectors.ts
│ │ │ │ └── slice.ts
│ │ │ ├── rollouts/
│ │ │ │ ├── api.ts
│ │ │ │ ├── index.ts
│ │ │ │ ├── rollouts.test.ts
│ │ │ │ ├── selectors.ts
│ │ │ │ └── slice.ts
│ │ │ ├── traces/
│ │ │ │ ├── index.ts
│ │ │ │ ├── selectors.ts
│ │ │ │ ├── slice.ts
│ │ │ │ └── traces.test.ts
│ │ │ ├── ui/
│ │ │ │ ├── alert/
│ │ │ │ │ ├── index.ts
│ │ │ │ │ ├── selectors.ts
│ │ │ │ │ └── slice.ts
│ │ │ │ └── drawer/
│ │ │ │ ├── index.ts
│ │ │ │ ├── selectors.ts
│ │ │ │ └── slice.ts
│ │ │ └── workers/
│ │ │ ├── index.ts
│ │ │ ├── selectors.ts
│ │ │ ├── slice.ts
│ │ │ └── workers.test.ts
│ │ ├── layouts/
│ │ │ ├── AppLayout.story.tsx
│ │ │ ├── AppLayout.tsx
│ │ │ └── helper.ts
│ │ ├── main.tsx
│ │ ├── pages/
│ │ │ ├── Resources.page.story.tsx
│ │ │ ├── Resources.page.tsx
│ │ │ ├── Rollouts.page.story.tsx
│ │ │ ├── Rollouts.page.tsx
│ │ │ ├── Settings.page.story.tsx
│ │ │ ├── Settings.page.tsx
│ │ │ ├── Traces.page.story.tsx
│ │ │ ├── Traces.page.tsx
│ │ │ ├── Workers.page.story.tsx
│ │ │ └── Workers.page.tsx
│ │ ├── store/
│ │ │ ├── hooks.ts
│ │ │ └── index.ts
│ │ ├── styles/
│ │ │ ├── app.css
│ │ │ └── theme.css
│ │ ├── theme.ts
│ │ ├── types.ts
│ │ ├── utils/
│ │ │ ├── error.ts
│ │ │ ├── format.ts
│ │ │ ├── mock.test.ts
│ │ │ ├── mock.ts
│ │ │ └── table.ts
│ │ └── vite-env.d.ts
│ ├── static/
│ │ └── mockServiceWorker.js
│ ├── test-utils/
│ │ ├── index.ts
│ │ ├── python-server.py
│ │ ├── render.tsx
│ │ └── server.ts
│ ├── tsconfig.json
│ ├── vite.config.mjs
│ ├── vitest.global-setup.mjs
│ ├── vitest.setup.mjs
│ └── vitest.shims.d.ts
├── docker/
│ ├── Dockerfile.dev
│ ├── compose.grafana.yml
│ ├── compose.mongo.yml
│ ├── compose.prometheus-memory-store.yml
│ ├── compose.prometheus-mongo-store.yml
│ ├── compose.store.yml
│ ├── grafana/
│ │ ├── dashboard-provider.yml
│ │ ├── dashboards/
│ │ │ ├── 1860_rev42.json
│ │ │ ├── 20192_rev1.json
│ │ │ └── agentlightning.json
│ │ └── datasource.yml
│ ├── prometheus/
│ │ ├── prometheus.base.yml
│ │ └── prometheus.mongo.yml
│ └── setup.sh
├── docs/
│ ├── algorithm-zoo/
│ │ ├── apo.md
│ │ ├── index.md
│ │ └── verl.md
│ ├── assets/
│ │ └── store-openapi.json
│ ├── changelog.md
│ ├── community/
│ │ ├── contributing.md
│ │ └── maintainers.md
│ ├── deep-dive/
│ │ ├── birds-eye-view.md
│ │ ├── serving-llm.md
│ │ └── store.md
│ ├── how-to/
│ │ ├── examples-catalog.md
│ │ ├── train-first-agent.md
│ │ ├── train-sql-agent.md
│ │ ├── unsloth-sft.md
│ │ └── write-first-algorithm.md
│ ├── index.md
│ ├── javascripts/
│ │ ├── charts.js
│ │ ├── katex.js
│ │ └── move-source-file.js
│ ├── macros/
│ │ └── source_links.py
│ ├── overrides/
│ │ ├── main.html
│ │ └── partials/
│ │ └── content.html
│ ├── reference/
│ │ ├── agent.md
│ │ ├── algorithm.md
│ │ ├── cli.md
│ │ ├── instrumentation.md
│ │ ├── internal.md
│ │ ├── restful.md
│ │ ├── runner.md
│ │ ├── semconv.md
│ │ ├── store.md
│ │ ├── trainer.md
│ │ ├── types.md
│ │ └── utilities.md
│ ├── stylesheets/
│ │ └── extra.css
│ └── tutorials/
│ ├── debug.md
│ ├── emitter.md
│ ├── installation.md
│ ├── parallelize.md
│ ├── traces.md
│ └── write-agents.md
├── examples/
│ ├── .gitignore
│ ├── README.md
│ ├── apo/
│ │ ├── README.md
│ │ ├── apo_custom_algorithm.py
│ │ ├── apo_custom_algorithm_trainer.py
│ │ ├── apo_debug.py
│ │ ├── legacy_apo_client.py
│ │ ├── legacy_apo_server.py
│ │ ├── room_selector.py
│ │ ├── room_selector_apo.py
│ │ └── room_tasks.jsonl
│ ├── azure/
│ │ ├── README.md
│ │ ├── aoai_finetune.py
│ │ ├── capital_agent.py
│ │ ├── capital_samples.csv
│ │ ├── tests/
│ │ │ └── test_deployment.py
│ │ └── train_capital_agent.py
│ ├── calc_x/
│ │ ├── README.md
│ │ ├── calc_agent.py
│ │ ├── eval_utils.py
│ │ ├── legacy_calc_agent.py
│ │ ├── legacy_calc_agent_debug.py
│ │ ├── legacy_train.sh
│ │ ├── tests/
│ │ │ ├── test_agentops.py
│ │ │ └── test_mcp_calculator.py
│ │ └── train_calc_agent.py
│ ├── chartqa/
│ │ ├── README.md
│ │ ├── chartqa_agent.py
│ │ ├── debug_chartqa_agent.py
│ │ ├── env_var.py
│ │ ├── multimodal_utils.py
│ │ ├── prepare_data.py
│ │ ├── prompts.py
│ │ └── train_chartqa_agent.py
│ ├── claude_code/
│ │ ├── README.md
│ │ ├── claude_code_agent.py
│ │ ├── claude_code_controller.py
│ │ ├── extended_adapter.py
│ │ ├── swebench_samples.jsonl
│ │ ├── swebench_utils/
│ │ │ ├── __init__.py
│ │ │ ├── docker_runtime.py
│ │ │ ├── evaluation.py
│ │ │ └── logging.py
│ │ └── templates/
│ │ ├── handle_hook.template.sh
│ │ └── settings.template.json
│ ├── minimal/
│ │ ├── README.md
│ │ ├── llm_proxy.py
│ │ ├── vllm_server.py
│ │ ├── write_metrics.py
│ │ └── write_traces.py
│ ├── rag/
│ │ ├── README.md
│ │ ├── metric_utils.py
│ │ ├── rag_agent.py
│ │ ├── train_rag.py
│ │ └── wiki_retriever_mcp.py
│ ├── spider/
│ │ ├── README.md
│ │ ├── spider_eval/
│ │ │ ├── __init__.py
│ │ │ ├── async_utils.py
│ │ │ ├── convert_dataset.py
│ │ │ ├── evaluation.py
│ │ │ ├── exec_eval.py
│ │ │ ├── parse.py
│ │ │ └── process_sql.py
│ │ ├── sql_agent.py
│ │ └── train_sql_agent.py
│ ├── tinker/
│ │ ├── README.md
│ │ ├── agl_tinker/
│ │ │ ├── __init__.py
│ │ │ ├── algo.py
│ │ │ ├── env.py
│ │ │ ├── llm.py
│ │ │ ├── rollout.py
│ │ │ └── train.py
│ │ ├── hello.py
│ │ ├── q20_agent.py
│ │ ├── q20_evaluate.py
│ │ ├── q20_nouns.csv
│ │ ├── q20_train.py
│ │ └── tests/
│ │ ├── __init__.py
│ │ └── test_tinker_llm.py
│ └── unsloth/
│ ├── README.md
│ ├── data_gsmhard.jsonl
│ ├── math_agent.py
│ ├── sft_algorithm.py
│ ├── sft_allinone.py
│ ├── sft_rollout_runners.py
│ └── unsloth_helper.py
├── mkdocs.yml
├── pyproject.toml
├── pyrightconfig.fast.json
├── pyrightconfig.json
├── scripts/
│ ├── badge_aggregation.js
│ ├── base.Dockerfile
│ ├── build_vm_image.sh
│ ├── bump_version.sh
│ ├── check_headers.py
│ ├── cleanup.sh
│ ├── cleanup_aoai.py
│ ├── export_openapi.py
│ ├── litellm_ci.yaml
│ ├── litellm_run.sh
│ ├── litellm_sanity_check.py
│ ├── mongodb_docker_run.sh
│ ├── mongodb_init_rs_host.js
│ ├── mongodb_init_rs_profiling.js
│ ├── restart_ray.sh
│ ├── setup_latest.sh
│ ├── setup_latest_gpu.sh
│ ├── setup_stable.sh
│ ├── setup_stable_gpu.sh
│ ├── setup_type_checking.sh
│ ├── validate_example_wandb.py
│ └── wandb_download_result.py
└── tests/
├── __init__.py
├── adapter/
│ ├── __init__.py
│ ├── test_llm_proxy.py
│ ├── test_messages_adapter.py
│ └── test_triplet_trace_tree.py
├── algorithm/
│ ├── __init__.py
│ ├── test_apo.py
│ ├── test_baseline.py
│ ├── test_decorator.py
│ └── test_utils.py
├── assets/
│ └── prompt_caches.jsonl
├── benchmark/
│ ├── analysis.py
│ ├── benchmark_store.py
│ ├── collection_benchmark.py
│ ├── micro_benchmark.py
│ └── utils.py
├── common/
│ ├── __init__.py
│ ├── network.py
│ ├── prometheus_stub.py
│ ├── tracer.py
│ └── vllm.py
├── emitter/
│ ├── __init__.py
│ ├── test_annotation.py
│ ├── test_exception.py
│ ├── test_message.py
│ ├── test_object.py
│ ├── test_operation.py
│ └── test_reward.py
├── execution/
│ ├── __init__.py
│ ├── test_client_server.py
│ └── test_shared_memory.py
├── instrumentation/
│ └── test_agentops.py
├── litagent/
│ ├── __init__.py
│ ├── test_decorator.py
│ └── test_resources.py
├── llm_proxy/
│ ├── __init__.py
│ ├── test_llm_proxy_cpu.py
│ ├── test_llm_proxy_gpu.py
│ └── test_stream.py
├── runner/
│ ├── __init__.py
│ ├── test_agent_integration.py
│ ├── test_agent_runner.py
│ └── test_runner_context.py
├── store/
│ ├── __init__.py
│ ├── conftest.py
│ ├── dummy_store.py
│ ├── test_client_server.py
│ ├── test_collection.py
│ ├── test_core.py
│ ├── test_restful.py
│ ├── test_threading.py
│ └── test_utils.py
├── test_client.py
├── test_config.py
├── test_env_var.py
├── test_logging.py
├── tracer/
│ ├── __init__.py
│ ├── test_agentops.py
│ ├── test_dummy.py
│ ├── test_integration.py
│ ├── test_otel.py
│ └── test_weave.py
├── trainer/
│ ├── __init__.py
│ ├── sample_components.py
│ ├── test_init_utils.py
│ ├── test_trainer_dev.py
│ └── test_trainer_init.py
├── types/
│ └── __init__.py
└── utils/
├── __init__.py
├── test_metrics.py
├── test_otel.py
├── test_otlp.py
├── test_server_launcher.py
└── test_system_snapshot.py
Showing preview only (400K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (3998 symbols across 291 files)
FILE: agentlightning/adapter/base.py
class Adapter (line 13) | class Adapter(Generic[T_from, T_to]):
method __call__ (line 39) | def __call__(self, source: T_from, /) -> T_to:
method adapt (line 54) | def adapt(self, source: T_from, /) -> T_to:
class OtelTraceAdapter (line 69) | class OtelTraceAdapter(Adapter[Sequence[ReadableSpan], T_to], Generic[T_...
class TraceAdapter (line 87) | class TraceAdapter(Adapter[Sequence[Span], T_to], Generic[T_to]):
FILE: agentlightning/adapter/messages.py
class OpenAIMessages (line 23) | class OpenAIMessages(TypedDict):
class _RawSpanInfo (line 35) | class _RawSpanInfo(TypedDict):
function group_genai_dict (line 53) | def group_genai_dict(data: Dict[str, Any], prefix: str) -> Union[Dict[st...
function convert_to_openai_messages (line 106) | def convert_to_openai_messages(prompt_completion_list: List[_RawSpanInfo...
class TraceToMessages (line 199) | class TraceToMessages(TraceAdapter[List[OpenAIMessages]]):
method get_tool_calls (line 211) | def get_tool_calls(self, completion: Span, all_spans: Sequence[Span], ...
method adapt (line 234) | def adapt(self, source: Sequence[Span], /) -> List[OpenAIMessages]:
FILE: agentlightning/adapter/triplet.py
function _attributes_get_multiple (line 24) | def _attributes_get_multiple(attributes: Dict[str, Any], keys: List[str]...
function _attributes_get_ids_multiple (line 37) | def _attributes_get_ids_multiple(attributes: Dict[str, Any], keys: List[...
function _attributes_unflatten_multiple (line 52) | def _attributes_unflatten_multiple(
class Transition (line 65) | class Transition(BaseModel):
class RewardMatchPolicy (line 84) | class RewardMatchPolicy(str, Enum):
class TraceTree (line 99) | class TraceTree:
method __init__ (line 108) | def __init__(
method start_time (line 119) | def start_time(self):
method end_time (line 123) | def end_time(self):
method find_id (line 126) | def find_id(self, id: str) -> "TraceTree | None":
method add_child (line 135) | def add_child(self, child: "TraceTree") -> None:
method visualize (line 138) | def visualize(self, filename: str, interested_span_match: str | None =...
method names_tuple (line 189) | def names_tuple(self) -> Tuple[str, List[Any]]:
method traverse (line 206) | def traverse(self) -> List["TraceTree"]:
method to_json (line 213) | def to_json(self) -> dict[str, Any]:
method from_spans (line 226) | def from_spans(cls, spans: List[Span]) -> "TraceTree":
method agent_name (line 317) | def agent_name(self) -> Optional[str]:
method maybe_reward_dict (line 367) | def maybe_reward_dict(self) -> dict[str, Any]:
method is_reward_span (line 379) | def is_reward_span(self) -> bool:
method find_llm_calls (line 398) | def find_llm_calls(
method repair_hierarchy (line 478) | def repair_hierarchy(self) -> None:
method match_rewards (line 522) | def match_rewards(self, reward_match: str, llm_calls: List["TraceTree"...
method extract_prompt_image_urls (line 577) | def extract_prompt_image_urls(self, prompt_raw_content: Any) -> List[s...
method span_to_triplet (line 631) | def span_to_triplet(self, span: Span, agent_name: str) -> Triplet:
method to_trajectory (line 702) | def to_trajectory(
method __repr__ (line 760) | def __repr__(self):
class TraceToTripletBase (line 767) | class TraceToTripletBase(TraceAdapter[List[Triplet]]):
class TracerTraceToTriplet (line 771) | class TracerTraceToTriplet(TraceToTripletBase):
method __init__ (line 786) | def __init__(
method visualize (line 802) | def visualize(
method adapt (line 831) | def adapt(self, source: Union[Sequence[Span], Sequence[ReadableSpan]],...
class LlmProxyTraceToTriplet (line 857) | class LlmProxyTraceToTriplet(TraceToTripletBase):
method _literal_eval_maybe (line 877) | def _literal_eval_maybe(self, v: Any) -> Any:
method _extract_tokens_from_raw (line 887) | def _extract_tokens_from_raw(self, attrs: Dict[str, Any]) -> Tuple[Lis...
method _extract_tokens_from_openai (line 924) | def _extract_tokens_from_openai(self, attrs: Dict[str, Any]) -> Tuple[...
method _maybe_reward_value (line 935) | def _maybe_reward_value(self, span: Span) -> Optional[float]:
method _request_id_from_attrs (line 939) | def _request_id_from_attrs(self, attrs: Dict[str, Any]) -> Optional[str]:
method adapt (line 944) | def adapt(self, source: Sequence[Span], /) -> List[Triplet]: # type: ...
FILE: agentlightning/algorithm/__init__.py
function APO (line 20) | def APO(*args: Any, **kwargs: Any) -> APOType[Any]:
function VERL (line 26) | def VERL(*args: Any, **kwargs: Any) -> VERLType:
FILE: agentlightning/algorithm/apo/apo.py
class RolloutResultForAPO (line 53) | class RolloutResultForAPO(TypedDict):
class VersionedPromptTemplate (line 63) | class VersionedPromptTemplate:
class APO (line 81) | class APO(Algorithm, Generic[T_task]):
method __init__ (line 101) | def __init__(
method _create_versioned_prompt (line 162) | def _create_versioned_prompt(
method _format_log_prefix (line 175) | def _format_log_prefix(
method _log (line 199) | def _log(self, level: int, message: str, *, prefix: Optional[str] = No...
method get_seed_prompt_template (line 209) | def get_seed_prompt_template(self) -> Tuple[str, PromptTemplate]:
method get_adapter (line 230) | def get_adapter(self) -> TraceToMessages:
method get_best_prompt (line 245) | def get_best_prompt(self) -> PromptTemplate:
method compute_textual_gradient (line 259) | async def compute_textual_gradient(
method textual_gradient_and_apply_edit (line 324) | async def textual_gradient_and_apply_edit(
method get_rollout_results (line 391) | async def get_rollout_results(
method evaluate_prompt_on_batch (line 430) | async def evaluate_prompt_on_batch(
method _initialize_beam (line 512) | def _initialize_beam(
method _sample_parent_prompts (line 546) | def _sample_parent_prompts(
method _generate_candidate_prompts (line 577) | async def _generate_candidate_prompts(
method _evaluate_and_select_beam (line 689) | async def _evaluate_and_select_beam(
method _update_best_prompt (line 758) | async def _update_best_prompt(
method run (line 809) | async def run(
FILE: agentlightning/algorithm/base.py
class Algorithm (line 25) | class Algorithm:
method is_async (line 34) | def is_async(self) -> bool:
method set_trainer (line 38) | def set_trainer(self, trainer: Trainer) -> None:
method get_trainer (line 47) | def get_trainer(self) -> Trainer:
method set_llm_proxy (line 61) | def set_llm_proxy(self, llm_proxy: LLMProxy | None) -> None:
method get_llm_proxy (line 70) | def get_llm_proxy(self) -> Optional[LLMProxy]:
method set_adapter (line 86) | def set_adapter(self, adapter: TraceAdapter[Any]) -> None:
method get_adapter (line 92) | def get_adapter(self) -> TraceAdapter[Any]:
method set_store (line 103) | def set_store(self, store: LightningStore) -> None:
method get_store (line 112) | def get_store(self) -> LightningStore:
method get_initial_resources (line 120) | def get_initial_resources(self) -> Optional[NamedResources]:
method set_initial_resources (line 126) | def set_initial_resources(self, resources: NamedResources) -> None:
method __call__ (line 132) | def __call__(self, *args: Any, **kwargs: Any) -> Any:
method run (line 135) | def run(
method get_client (line 151) | def get_client(self) -> AgentLightningClient:
FILE: agentlightning/algorithm/decorator.py
class AlgorithmFuncSyncFull (line 36) | class AlgorithmFuncSyncFull(Protocol):
method __call__ (line 37) | def __call__(
class AlgorithmFuncSyncOnlyStore (line 49) | class AlgorithmFuncSyncOnlyStore(Protocol):
method __call__ (line 50) | def __call__(self, *, store: LightningStore) -> None: ...
class AlgorithmFuncSyncOnlyDataset (line 53) | class AlgorithmFuncSyncOnlyDataset(Protocol):
method __call__ (line 54) | def __call__(self, *, train_dataset: Optional[Dataset[Any]], val_datas...
class AlgorithmFuncAsyncFull (line 57) | class AlgorithmFuncAsyncFull(Protocol):
method __call__ (line 58) | def __call__(
class AlgorithmFuncAsyncOnlyStore (line 70) | class AlgorithmFuncAsyncOnlyStore(Protocol):
method __call__ (line 71) | def __call__(self, *, store: LightningStore) -> Awaitable[None]: ...
class AlgorithmFuncAsyncOnlyDataset (line 74) | class AlgorithmFuncAsyncOnlyDataset(Protocol):
method __call__ (line 75) | def __call__(
class AlgorithmFuncSyncFallback (line 85) | class AlgorithmFuncSyncFallback(Protocol):
method __call__ (line 86) | def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
class AlgorithmFuncAsyncFallback (line 89) | class AlgorithmFuncAsyncFallback(Protocol):
method __call__ (line 90) | def __call__(self, *args: Any, **kwargs: Any) -> Awaitable[Any]: ...
class FunctionalAlgorithm (line 103) | class FunctionalAlgorithm(Algorithm, Generic[AF]):
method __init__ (line 113) | def __init__(self: "FunctionalAlgorithm[Literal[False]]", algorithm_fu...
method __init__ (line 116) | def __init__(self: "FunctionalAlgorithm[Literal[True]]", algorithm_fun...
method __init__ (line 118) | def __init__(self, algorithm_func: Union[AlgorithmFuncSyncLike, Algori...
method is_async (line 134) | def is_async(self) -> bool:
method run (line 138) | def run(
method run (line 145) | def run(
method __call__ (line 151) | def __call__(self, *args: Any, **kwargs: Any) -> Any:
method run (line 154) | def run(
function algo (line 203) | def algo(func: AlgorithmFuncAsync) -> FunctionalAlgorithm[Literal[True]]...
function algo (line 207) | def algo(func: AlgorithmFuncAsyncFallback) -> FunctionalAlgorithm[Any]: ...
function algo (line 211) | def algo(func: AlgorithmFuncSync) -> FunctionalAlgorithm[Literal[False]]...
function algo (line 215) | def algo(func: AlgorithmFuncSyncFallback) -> FunctionalAlgorithm[Any]: ...
function algo (line 218) | def algo(
FILE: agentlightning/algorithm/fast.py
class FastAlgorithm (line 24) | class FastAlgorithm(Algorithm):
function _timestamp_to_iso_str (line 33) | def _timestamp_to_iso_str(timestamp: float) -> str:
class Baseline (line 37) | class Baseline(FastAlgorithm):
method __init__ (line 69) | def __init__(
method _span_to_string (line 89) | def _span_to_string(self, rollout_id: str, attempt: Attempt, span: Spa...
method _handle_rollout_finish (line 109) | async def _handle_rollout_finish(self, rollout: Rollout) -> None:
method _enqueue_rollouts (line 146) | async def _enqueue_rollouts(
method _harvest_rollout_spans (line 162) | async def _harvest_rollout_spans(self, rollout_id: str):
method run (line 192) | async def run(
FILE: agentlightning/algorithm/utils.py
function batch_iter_over_dataset (line 42) | def batch_iter_over_dataset(dataset: Dataset[T_task], batch_size: int) -...
function with_store (line 77) | def with_store(
function with_llm_proxy (line 104) | def with_llm_proxy(
function with_llm_proxy (line 114) | def with_llm_proxy(
function with_llm_proxy (line 123) | def with_llm_proxy(
FILE: agentlightning/algorithm/verl/interface.py
class VERL (line 20) | class VERL(Algorithm):
method __init__ (line 125) | def __init__(
method run (line 145) | def run(
method get_client (line 195) | def get_client(self) -> AgentLightningClient:
FILE: agentlightning/cli/__init__.py
function main (line 24) | def main(argv: Iterable[str] | None = None) -> int:
FILE: agentlightning/cli/prometheus.py
function ensure_prometheus_dir (line 24) | def ensure_prometheus_dir() -> str:
function create_prometheus_app (line 36) | def create_prometheus_app(metrics_path: str = "/v1/prometheus") -> FastAPI:
function main (line 64) | def main(argv: Iterable[str] | None = None) -> int:
FILE: agentlightning/cli/store.py
function main (line 26) | def main(argv: Iterable[str] | None = None) -> int:
FILE: agentlightning/cli/vllm.py
function main (line 8) | def main(argv: Iterable[str] | None = None) -> int:
FILE: agentlightning/client.py
class AgentLightningClient (line 26) | class AgentLightningClient:
method __init__ (line 52) | def __init__(self, endpoint: str, poll_interval: float = 5.0, timeout:...
method _request_json_async (line 70) | async def _request_json_async(self, url: str) -> Optional[Dict[str, An...
method _post_json_async (line 89) | async def _post_json_async(self, url: str, payload: Dict[str, Any]) ->...
method poll_next_task_async (line 109) | async def poll_next_task_async(self) -> Optional[Task]:
method get_resources_by_id_async (line 128) | async def get_resources_by_id_async(self, resource_id: str) -> Optiona...
method get_latest_resources_async (line 152) | async def get_latest_resources_async(self) -> Optional[ResourcesUpdate]:
method post_rollout_async (line 168) | async def post_rollout_async(self, rollout: RolloutLegacy) -> Optional...
method _request_json (line 181) | def _request_json(self, url: str) -> Optional[Dict[str, Any]]:
method _post_json (line 198) | def _post_json(self, url: str, payload: Dict[str, Any]) -> Optional[Di...
method poll_next_task (line 216) | def poll_next_task(self) -> Optional[Task]:
method get_resources_by_id (line 235) | def get_resources_by_id(self, resource_id: str) -> Optional[ResourcesU...
method get_latest_resources (line 259) | def get_latest_resources(self) -> Optional[ResourcesUpdate]:
method post_rollout (line 274) | def post_rollout(self, rollout: RolloutLegacy) -> Optional[Dict[str, A...
class DevTaskLoader (line 288) | class DevTaskLoader(AgentLightningClient):
method __init__ (line 301) | def __init__(
method rollouts (line 343) | def rollouts(self) -> List[RolloutLegacy]:
method poll_next_task (line 347) | def poll_next_task(self) -> Optional[Task]:
method get_resources_by_id (line 378) | def get_resources_by_id(self, resource_id: str) -> Optional[ResourcesU...
method get_latest_resources (line 386) | def get_latest_resources(self) -> Optional[ResourcesUpdate]:
method post_rollout (line 390) | def post_rollout(self, rollout: RolloutLegacy) -> Optional[Dict[str, A...
method poll_next_task_async (line 395) | async def poll_next_task_async(self) -> Optional[Task]:
method get_resources_by_id_async (line 398) | async def get_resources_by_id_async(self, resource_id: str) -> Optiona...
method get_latest_resources_async (line 401) | async def get_latest_resources_async(self) -> Optional[ResourcesUpdate]:
method post_rollout_async (line 404) | async def post_rollout_async(self, rollout: RolloutLegacy) -> Optional...
method __repr__ (line 407) | def __repr__(self):
FILE: agentlightning/config.py
function nullable_str (line 45) | def nullable_str(value: str) -> str | None:
function nullable_int (line 52) | def nullable_int(value: str) -> int | None:
function nullable_float (line 62) | def nullable_float(value: str) -> float | None:
function _str_to_bool (line 72) | def _str_to_bool(v: str) -> bool:
function _get_param_type_details (line 85) | def _get_param_type_details(param_annotation: Any) -> Tuple[Any, bool, b...
function _determine_argparse_type (line 118) | def _determine_argparse_type(param_type: Any) -> Callable[[str], Any]:
function _determine_argparse_type_and_nargs (line 134) | def _determine_argparse_type_and_nargs(
function _build_help_string (line 155) | def _build_help_string(cls_name: str, param_name: str, core_type: Any, i...
function _add_argument_for_parameter (line 179) | def _add_argument_for_parameter(
function _add_arguments_for_class (line 219) | def _add_arguments_for_class(
function _create_argument_parser (line 255) | def _create_argument_parser() -> argparse.ArgumentParser:
function _instantiate_classes (line 263) | def _instantiate_classes(
function lightning_cli (line 306) | def lightning_cli(cls1: Type[_C1]) -> _C1: ...
function lightning_cli (line 308) | def lightning_cli(cls1: Type[_C1], cls2: Type[_C2]) -> Tuple[_C1, _C2]: ...
function lightning_cli (line 310) | def lightning_cli(cls1: Type[_C1], cls2: Type[_C2], cls3: Type[_C3]) -> ...
function lightning_cli (line 312) | def lightning_cli(cls1: Type[_C1], cls2: Type[_C2], cls3: Type[_C3], cls...
function lightning_cli (line 314) | def lightning_cli(*classes: Type[CliConfigurable]) -> Tuple[CliConfigura...
function lightning_cli (line 320) | def lightning_cli(*classes: Type[CliConfigurable]) -> CliConfigurable | ...
FILE: agentlightning/emitter/annotation.py
function emit_annotation (line 35) | def emit_annotation(annotation: Dict[str, Any], propagate: bool = True) ...
class OperationContext (line 70) | class OperationContext:
method __init__ (line 88) | def __init__(self, name: str, attributes: Dict[str, Any], propagate: b...
method __enter__ (line 111) | def __enter__(self) -> "OperationContext":
method __exit__ (line 123) | def __exit__(
method span (line 137) | def span(self) -> SpanCoreFields:
method set_input (line 143) | def set_input(self, *args: Any, **kwargs: Any) -> None:
method set_output (line 173) | def set_output(self, output: Any) -> None:
method __call__ (line 187) | def __call__(self, fn: _FnType) -> _FnType:
function operation (line 281) | def operation(
function operation (line 287) | def operation(
function operation (line 293) | def operation(fn: _FnType, *, name: Optional[str] = None, **additional_a...
function operation (line 297) | def operation(*, name: Optional[str] = None, **additional_attributes: An...
function operation (line 301) | def operation(fn: _FnType, **additional_attributes: Any) -> _FnType: ...
function operation (line 305) | def operation(**additional_attributes: Any) -> OperationContext: ...
function operation (line 308) | def operation(
FILE: agentlightning/emitter/exception.py
function emit_exception (line 15) | def emit_exception(
FILE: agentlightning/emitter/message.py
function emit_message (line 15) | def emit_message(message: str, attributes: Optional[Dict[str, Any]] = No...
function get_message_value (line 49) | def get_message_value(span: SpanLike) -> Optional[str]:
FILE: agentlightning/emitter/object.py
function emit_object (line 17) | def emit_object(object: Any, attributes: Optional[Dict[str, Any]] = None...
function encode_object (line 55) | def encode_object(object: Any) -> Dict[str, Any]:
function get_object_value (line 87) | def get_object_value(span: SpanLike) -> Any:
FILE: agentlightning/emitter/reward.py
class RewardDimension (line 44) | class RewardDimension(TypedDict):
class _RewardSpanData (line 51) | class _RewardSpanData(TypedDict):
function _agentops_initialized (line 59) | def _agentops_initialized() -> bool:
function reward (line 66) | def reward(fn: _FnType) -> _FnType:
function emit_reward (line 148) | def emit_reward(
function get_reward_value (line 213) | def get_reward_value(span: SpanLike) -> Optional[float]:
function get_rewards_from_span (line 270) | def get_rewards_from_span(span: SpanLike) -> List[RewardPydanticModel]:
function is_reward_span (line 289) | def is_reward_span(span: SpanLike) -> bool:
function find_reward_spans (line 295) | def find_reward_spans(spans: Sequence[SpanLike]) -> List[SpanLike]:
function find_final_reward (line 307) | def find_final_reward(spans: Sequence[SpanLike]) -> Optional[float]:
FILE: agentlightning/env_var.py
class LightningEnvVar (line 19) | class LightningEnvVar(Enum):
function resolve_bool_env_var (line 48) | def resolve_bool_env_var(env_var: LightningEnvVar, override: bool, fallb...
function resolve_bool_env_var (line 52) | def resolve_bool_env_var(env_var: LightningEnvVar, *, fallback: bool) ->...
function resolve_bool_env_var (line 56) | def resolve_bool_env_var(
function resolve_bool_env_var (line 61) | def resolve_bool_env_var(
function resolve_int_env_var (line 89) | def resolve_int_env_var(env_var: LightningEnvVar, override: int, fallbac...
function resolve_int_env_var (line 93) | def resolve_int_env_var(env_var: LightningEnvVar, *, fallback: int) -> i...
function resolve_int_env_var (line 97) | def resolve_int_env_var(
function resolve_int_env_var (line 102) | def resolve_int_env_var(
function resolve_str_env_var (line 126) | def resolve_str_env_var(env_var: LightningEnvVar, override: str, fallbac...
function resolve_str_env_var (line 130) | def resolve_str_env_var(env_var: LightningEnvVar, *, fallback: str) -> s...
function resolve_str_env_var (line 134) | def resolve_str_env_var(
function resolve_str_env_var (line 139) | def resolve_str_env_var(
FILE: agentlightning/execution/base.py
class AlgorithmBundle (line 15) | class AlgorithmBundle(Protocol):
method __call__ (line 23) | async def __call__(self, store: LightningStore, event: ExecutionEvent)...
class RunnerBundle (line 27) | class RunnerBundle(Protocol):
method __call__ (line 31) | async def __call__(self, store: LightningStore, worker_id: int, event:...
class ExecutionStrategy (line 35) | class ExecutionStrategy:
method execute (line 50) | def execute(self, algorithm: AlgorithmBundle, runner: RunnerBundle, st...
FILE: agentlightning/execution/client_server.py
class ClientServerExecutionStrategy (line 22) | class ClientServerExecutionStrategy(ExecutionStrategy):
method __init__ (line 65) | def __init__(
method _execute_algorithm (line 127) | async def _execute_algorithm(
method _execute_runner (line 167) | async def _execute_runner(
method _spawn_runners (line 207) | def _spawn_runners(
method _spawn_algorithm_process (line 240) | def _spawn_algorithm_process(
method _join_until_deadline (line 267) | def _join_until_deadline(
method _signal_processes (line 285) | def _signal_processes(
method _shutdown_processes (line 297) | def _shutdown_processes(
method _check_process_exitcodes (line 349) | def _check_process_exitcodes(self, processes: Iterable[multiprocessing...
method execute (line 356) | def execute(self, algorithm: AlgorithmBundle, runner: RunnerBundle, st...
FILE: agentlightning/execution/events.py
class ExecutionEvent (line 9) | class ExecutionEvent(Protocol):
method set (line 24) | def set(self) -> None: ...
method clear (line 25) | def clear(self) -> None: ...
method is_set (line 26) | def is_set(self) -> bool: ...
method wait (line 27) | def wait(self, timeout: Optional[float] = None) -> bool: ...
class ThreadingEvent (line 30) | class ThreadingEvent:
method __init__ (line 35) | def __init__(self) -> None:
method set (line 38) | def set(self) -> None:
method clear (line 41) | def clear(self) -> None:
method is_set (line 44) | def is_set(self) -> bool:
method wait (line 47) | def wait(self, timeout: Optional[float] = None) -> bool:
class MultiprocessingEvent (line 51) | class MultiprocessingEvent:
method __init__ (line 56) | def __init__(self, *, ctx: Optional[BaseContext] = None) -> None:
method set (line 59) | def set(self) -> None:
method clear (line 62) | def clear(self) -> None:
method is_set (line 65) | def is_set(self) -> bool:
method wait (line 68) | def wait(self, timeout: Optional[float] = None) -> bool:
FILE: agentlightning/execution/inter_process.py
class InterProcessExecutionStrategy (line 6) | class InterProcessExecutionStrategy(ExecutionStrategy):
FILE: agentlightning/execution/shared_memory.py
class SharedMemoryExecutionStrategy (line 20) | class SharedMemoryExecutionStrategy(ExecutionStrategy):
method __init__ (line 45) | def __init__(
method _run_until_completed_or_canceled (line 70) | async def _run_until_completed_or_canceled(self, coro: Awaitable[Any],...
method _run_algorithm (line 163) | def _run_algorithm(
method _run_runner (line 181) | def _run_runner(
method execute (line 200) | def execute(self, algorithm: AlgorithmBundle, runner: RunnerBundle, st...
FILE: agentlightning/instrumentation/__init__.py
function instrument_all (line 43) | def instrument_all():
function uninstrument_all (line 74) | def uninstrument_all():
FILE: agentlightning/instrumentation/agentops.py
function enable_agentops_service (line 32) | def enable_agentops_service(enabled: bool = True) -> None:
function _patch_exporters (line 49) | def _patch_exporters():
function _unpatch_exporters (line 61) | def _unpatch_exporters():
function _unwrap_legacy_response (line 73) | def _unwrap_legacy_response(response: Any) -> Any:
function _patch_new_agentops (line 79) | def _patch_new_agentops():
function _unpatch_new_agentops (line 155) | def _unpatch_new_agentops():
function _patch_old_agentops (line 171) | def _patch_old_agentops():
function _unpatch_old_agentops (line 200) | def _unpatch_old_agentops():
function instrument_agentops (line 210) | def instrument_agentops():
function uninstrument_agentops (line 234) | def uninstrument_agentops():
class BypassableAuthenticatedOTLPExporter (line 248) | class BypassableAuthenticatedOTLPExporter(LightningStoreOTLPExporter, Au...
method should_bypass (line 255) | def should_bypass(self) -> bool:
class BypassableOTLPMetricExporter (line 259) | class BypassableOTLPMetricExporter(OTLPMetricExporter):
method export (line 265) | def export(self, *args: Any, **kwargs: Any) -> MetricExportResult:
class BypassableOTLPSpanExporter (line 273) | class BypassableOTLPSpanExporter(LightningStoreOTLPExporter):
method should_bypass (line 281) | def should_bypass(self) -> bool:
class BypassableV3Client (line 285) | class BypassableV3Client(V3Client):
method fetch_auth_token (line 292) | def fetch_auth_token(self, *args: Any, **kwargs: Any) -> AuthTokenResp...
class BypassableV4Client (line 300) | class BypassableV4Client(V4Client):
method post (line 306) | def post(self, *args: Any, **kwargs: Any) -> requests.Response:
FILE: agentlightning/instrumentation/agentops_langchain.py
function on_chain_start (line 17) | def on_chain_start(self: Any, serialized: Dict[str, Any], inputs: Dict[s...
function instrument_agentops_langchain (line 32) | def instrument_agentops_langchain():
function uninstrument_agentops_langchain (line 39) | def uninstrument_agentops_langchain():
FILE: agentlightning/instrumentation/litellm.py
function patched_set_attributes (line 23) | def patched_set_attributes(self: Any, span: Any, kwargs: Any, response_o...
function instrument_litellm (line 32) | def instrument_litellm():
function uninstrument_litellm (line 37) | def uninstrument_litellm():
FILE: agentlightning/instrumentation/vllm.py
class ChatCompletionResponsePatched (line 18) | class ChatCompletionResponsePatched(ChatCompletionResponse):
function chat_completion_full_generator (line 26) | async def chat_completion_full_generator(
function instrument_vllm (line 66) | def instrument_vllm():
function uninstrument_vllm (line 79) | def uninstrument_vllm():
FILE: agentlightning/instrumentation/weave.py
class InMemoryWeaveTraceServer (line 27) | class InMemoryWeaveTraceServer(TraceServerClientInterface):
method __init__ (line 34) | def __init__(self):
method from_env (line 45) | def from_env(cls, *args: Any, **kwargs: Any) -> InMemoryWeaveTraceServer:
method server_info (line 48) | def server_info(self) -> ServerInfoRes:
method ensure_project_exists (line 51) | def ensure_project_exists(self, entity: str, project: str) -> tsi.Ensu...
method call_start (line 57) | def call_start(self, req: tsi.CallStartReq) -> tsi.CallStartRes:
method call_end (line 80) | def call_end(self, req: tsi.CallEndReq) -> tsi.CallEndRes:
method call_start_batch (line 95) | def call_start_batch(self, req: tsi.CallCreateBatchReq) -> tsi.CallCre...
method call_read (line 104) | def call_read(self, req: tsi.CallReadReq) -> tsi.CallReadRes:
method calls_query (line 109) | def calls_query(self, req: tsi.CallsQueryReq) -> tsi.CallsQueryRes:
method calls_query_stream (line 113) | def calls_query_stream(self, req: tsi.CallsQueryReq) -> Iterator[tsi.C...
method calls_delete (line 117) | def calls_delete(self, req: tsi.CallsDeleteReq) -> tsi.CallsDeleteRes:
method call_update (line 126) | def call_update(self, req: tsi.CallUpdateReq) -> tsi.CallUpdateRes:
method calls_query_stats (line 130) | def calls_query_stats(self, req: tsi.CallsQueryStatsReq) -> tsi.CallsQ...
method cost_create (line 136) | def cost_create(self, req: tsi.CostCreateReq) -> tsi.CostCreateRes:
method cost_query (line 140) | def cost_query(self, req: tsi.CostQueryReq) -> tsi.CostQueryRes:
method cost_purge (line 144) | def cost_purge(self, req: tsi.CostPurgeReq) -> tsi.CostPurgeRes:
method obj_create (line 150) | def obj_create(self, req: tsi.ObjCreateReq) -> tsi.ObjCreateRes:
method obj_read (line 156) | def obj_read(self, req: tsi.ObjReadReq) -> tsi.ObjReadRes:
method objs_query (line 160) | def objs_query(self, req: tsi.ObjQueryReq) -> tsi.ObjQueryRes:
method obj_delete (line 164) | def obj_delete(self, req: tsi.ObjDeleteReq) -> tsi.ObjDeleteRes:
method table_create (line 170) | def table_create(self, req: tsi.TableCreateReq) -> tsi.TableCreateRes:
method table_create_from_digests (line 174) | def table_create_from_digests(self, req: tsi.TableCreateFromDigestsReq...
method table_update (line 178) | def table_update(self, req: tsi.TableUpdateReq) -> tsi.TableUpdateRes:
method table_query (line 182) | def table_query(self, req: tsi.TableQueryReq) -> tsi.TableQueryRes:
method table_query_stream (line 186) | def table_query_stream(self, req: tsi.TableQueryReq) -> Iterator[tsi.T...
method table_query_stats (line 190) | def table_query_stats(self, req: tsi.TableQueryStatsReq) -> tsi.TableQ...
method table_query_stats_batch (line 194) | def table_query_stats_batch(self, req: tsi.TableQueryStatsBatchReq) ->...
method refs_read_batch (line 200) | def refs_read_batch(self, req: tsi.RefsReadBatchReq) -> tsi.RefsReadBa...
method file_create (line 205) | def file_create(self, req: tsi.FileCreateReq) -> tsi.FileCreateRes:
method file_content_read (line 209) | def file_content_read(self, req: tsi.FileContentReadReq) -> tsi.FileCo...
method files_stats (line 212) | def files_stats(self, req: tsi.FilesStatsReq) -> tsi.FilesStatsRes:
method feedback_create (line 219) | def feedback_create(self, req: tsi.FeedbackCreateReq) -> tsi.FeedbackC...
method feedback_create_batch (line 229) | def feedback_create_batch(self, req: tsi.FeedbackCreateBatchReq) -> ts...
method feedback_query (line 237) | def feedback_query(self, req: tsi.FeedbackQueryReq) -> tsi.FeedbackQue...
method feedback_purge (line 241) | def feedback_purge(self, req: tsi.FeedbackPurgeReq) -> tsi.FeedbackPur...
method feedback_replace (line 246) | def feedback_replace(self, req: tsi.FeedbackReplaceReq) -> tsi.Feedbac...
method actions_execute_batch (line 257) | def actions_execute_batch(self, req: tsi.ActionsExecuteBatchReq) -> ts...
method completions_create (line 263) | def completions_create(self, req: tsi.CompletionsCreateReq) -> tsi.Com...
method completions_create_stream (line 267) | def completions_create_stream(self, req: tsi.CompletionsCreateReq) -> ...
method image_create (line 274) | def image_create(self, req: tsi.ImageGenerationCreateReq) -> tsi.Image...
method project_stats (line 280) | def project_stats(self, req: tsi.ProjectStatsReq) -> tsi.ProjectStatsRes:
method threads_query_stream (line 291) | def threads_query_stream(self, req: tsi.ThreadsQueryReq) -> Iterator[t...
method evaluate_model (line 297) | def evaluate_model(self, req: tsi.EvaluateModelReq) -> tsi.EvaluateMod...
method evaluation_status (line 301) | def evaluation_status(self, req: tsi.EvaluationStatusReq) -> tsi.Evalu...
method otel_export (line 306) | def otel_export(self, req: tsi.OtelExportReq) -> tsi.OtelExportRes:
method op_create (line 314) | def op_create(self, req: tsi.OpCreateReq) -> tsi.OpCreateRes:
method op_read (line 317) | def op_read(self, req: tsi.OpReadReq) -> tsi.OpReadRes:
method op_list (line 320) | def op_list(self, req: tsi.OpListReq) -> Iterator[tsi.OpReadRes]:
method op_delete (line 323) | def op_delete(self, req: tsi.OpDeleteReq) -> tsi.OpDeleteRes:
method dataset_create (line 327) | def dataset_create(self, req: tsi.DatasetCreateReq) -> tsi.DatasetCrea...
method dataset_read (line 330) | def dataset_read(self, req: tsi.DatasetReadReq) -> tsi.DatasetReadRes:
method dataset_list (line 333) | def dataset_list(self, req: tsi.DatasetListReq) -> Iterator[tsi.Datase...
method dataset_delete (line 336) | def dataset_delete(self, req: tsi.DatasetDeleteReq) -> tsi.DatasetDele...
method scorer_create (line 340) | def scorer_create(self, req: tsi.ScorerCreateReq) -> tsi.ScorerCreateRes:
method scorer_read (line 343) | def scorer_read(self, req: tsi.ScorerReadReq) -> tsi.ScorerReadRes:
method scorer_list (line 346) | def scorer_list(self, req: tsi.ScorerListReq) -> Iterator[tsi.ScorerRe...
method scorer_delete (line 349) | def scorer_delete(self, req: tsi.ScorerDeleteReq) -> tsi.ScorerDeleteRes:
method evaluation_create (line 353) | def evaluation_create(self, req: tsi.EvaluationCreateReq) -> tsi.Evalu...
method evaluation_read (line 358) | def evaluation_read(self, req: tsi.EvaluationReadReq) -> tsi.Evaluatio...
method evaluation_list (line 361) | def evaluation_list(self, req: tsi.EvaluationListReq) -> Iterator[tsi....
method evaluation_delete (line 364) | def evaluation_delete(self, req: tsi.EvaluationDeleteReq) -> tsi.Evalu...
method model_create (line 368) | def model_create(self, req: tsi.ModelCreateReq) -> tsi.ModelCreateRes:
method model_read (line 373) | def model_read(self, req: tsi.ModelReadReq) -> tsi.ModelReadRes:
method model_list (line 376) | def model_list(self, req: tsi.ModelListReq) -> Iterator[tsi.ModelReadR...
method model_delete (line 379) | def model_delete(self, req: tsi.ModelDeleteReq) -> tsi.ModelDeleteRes:
method evaluation_run_create (line 383) | def evaluation_run_create(self, req: tsi.EvaluationRunCreateReq) -> ts...
method evaluation_run_read (line 386) | def evaluation_run_read(self, req: tsi.EvaluationRunReadReq) -> tsi.Ev...
method evaluation_run_list (line 389) | def evaluation_run_list(self, req: tsi.EvaluationRunListReq) -> Iterat...
method evaluation_run_delete (line 392) | def evaluation_run_delete(self, req: tsi.EvaluationRunDeleteReq) -> ts...
method evaluation_run_finish (line 395) | def evaluation_run_finish(self, req: tsi.EvaluationRunFinishReq) -> ts...
method prediction_create (line 399) | def prediction_create(self, req: tsi.PredictionCreateReq) -> tsi.Predi...
method prediction_read (line 402) | def prediction_read(self, req: tsi.PredictionReadReq) -> tsi.Predictio...
method prediction_list (line 405) | def prediction_list(self, req: tsi.PredictionListReq) -> Iterator[tsi....
method prediction_delete (line 408) | def prediction_delete(self, req: tsi.PredictionDeleteReq) -> tsi.Predi...
method prediction_finish (line 411) | def prediction_finish(self, req: tsi.PredictionFinishReq) -> tsi.Predi...
method score_create (line 415) | def score_create(self, req: tsi.ScoreCreateReq) -> tsi.ScoreCreateRes:
method score_read (line 418) | def score_read(self, req: tsi.ScoreReadReq) -> tsi.ScoreReadRes:
method score_list (line 421) | def score_list(self, req: tsi.ScoreListReq) -> Iterator[tsi.ScoreReadR...
method score_delete (line 424) | def score_delete(self, req: tsi.ScoreDeleteReq) -> tsi.ScoreDeleteRes:
method annotation_queue_create (line 429) | def annotation_queue_create(self, *args: Any, **kwargs: Any) -> Any:
method annotation_queues_query_stream (line 432) | def annotation_queues_query_stream(self, *args: Any, **kwargs: Any) ->...
method annotation_queue_read (line 435) | def annotation_queue_read(self, *args: Any, **kwargs: Any) -> Any:
method annotation_queue_add_calls (line 438) | def annotation_queue_add_calls(self, *args: Any, **kwargs: Any) -> Any:
method annotation_queues_stats (line 441) | def annotation_queues_stats(self, *args: Any, **kwargs: Any) -> Any:
method annotation_queue_items_query (line 444) | def annotation_queue_items_query(self, *args: Any, **kwargs: Any) -> Any:
method annotator_queue_items_progress_update (line 447) | def annotator_queue_items_progress_update(self, *args: Any, **kwargs: ...
method calls_complete (line 450) | def calls_complete(self, *args: Any, **kwargs: Any) -> Any:
method call_start_v2 (line 453) | def call_start_v2(self, *args: Any, **kwargs: Any) -> Any:
method call_end_v2 (line 456) | def call_end_v2(self, *args: Any, **kwargs: Any) -> Any:
method call_stats (line 459) | def call_stats(self, *args: Any, **kwargs: Any) -> Any:
method trace_usage (line 462) | def trace_usage(self, *args: Any, **kwargs: Any) -> Any:
method calls_usage (line 465) | def calls_usage(self, *args: Any, **kwargs: Any) -> Any:
function init_weave_get_server_factory (line 475) | def init_weave_get_server_factory(server: InMemoryWeaveTraceServer) -> C...
function get_entity_project_from_project_name_factory (line 483) | def get_entity_project_from_project_name_factory(entity_name: str) -> tu...
function get_username (line 497) | def get_username() -> str:
function instrument_weave (line 509) | def instrument_weave(server: InMemoryWeaveTraceServer):
function uninstrument_weave (line 521) | def uninstrument_weave():
FILE: agentlightning/litagent/decorator.py
class LlmRolloutFuncSync2 (line 38) | class LlmRolloutFuncSync2(Protocol[T_contra]):
method __call__ (line 39) | def __call__(self, task: T_contra, llm: LLM) -> RolloutRawResult: ...
class LlmRolloutFuncSync3 (line 42) | class LlmRolloutFuncSync3(Protocol[T_contra]):
method __call__ (line 43) | def __call__(self, task: T_contra, llm: LLM, rollout: Rollout) -> Roll...
class LlmRolloutFuncAsync2 (line 46) | class LlmRolloutFuncAsync2(Protocol[T_contra]):
method __call__ (line 47) | def __call__(self, task: T_contra, llm: LLM) -> Awaitable[RolloutRawRe...
class LlmRolloutFuncAsync3 (line 50) | class LlmRolloutFuncAsync3(Protocol[T_contra]):
method __call__ (line 51) | def __call__(self, task: T_contra, llm: LLM, rollout: Rollout) -> Awai...
class PromptRolloutFuncSync2 (line 62) | class PromptRolloutFuncSync2(Protocol[T_contra]):
method __call__ (line 63) | def __call__(self, task: T_contra, prompt_template: PromptTemplate) ->...
class PromptRolloutFuncAsync2 (line 66) | class PromptRolloutFuncAsync2(Protocol[T_contra]):
method __call__ (line 67) | def __call__(self, task: T_contra, prompt_template: PromptTemplate) ->...
class PromptRolloutFuncSync3 (line 70) | class PromptRolloutFuncSync3(Protocol[T_contra]):
method __call__ (line 71) | def __call__(self, task: T_contra, prompt_template: PromptTemplate, ro...
class PromptRolloutFuncAsync3 (line 74) | class PromptRolloutFuncAsync3(Protocol[T_contra]):
method __call__ (line 75) | def __call__(
class FunctionalLitAgentFunc (line 88) | class FunctionalLitAgentFunc(Protocol[T_contra]):
method __call__ (line 89) | def __call__(
class FunctionalLitAgent (line 94) | class FunctionalLitAgent(LitAgent[T]):
method __init__ (line 102) | def __init__(self, rollout_func: FunctionalLitAgentFunc[T], *, strip_p...
method _accepts_rollout (line 124) | def _accepts_rollout(self) -> bool:
method _accepts_llm (line 127) | def _accepts_llm(self) -> bool:
method _accepts_prompt_template (line 130) | def _accepts_prompt_template(self) -> bool:
method __call__ (line 133) | def __call__(self, *args: Any, **kwargs: Any) -> Any:
method is_async (line 137) | def is_async(self) -> bool:
method rollout (line 140) | def rollout(self, task: T, resources: NamedResources, rollout: Rollout...
method rollout_async (line 160) | async def rollout_async(self, task: T, resources: NamedResources, roll...
method _get_kwargs (line 180) | def _get_kwargs(self, resources: NamedResources, rollout: Rollout) -> ...
method _get_llm_resource (line 206) | def _get_llm_resource(self, resources: NamedResources, rollout: Rollou...
method _get_prompt_template_resource (line 237) | def _get_prompt_template_resource(self, resources: NamedResources, rol...
method _strip_proxy_helper (line 265) | def _strip_proxy_helper(self, proxy_llm: LLM, rollout: Rollout) -> LLM:
function llm_rollout (line 297) | def llm_rollout(func: LlmRolloutFunc[T]) -> FunctionalLitAgent[T]: ...
function llm_rollout (line 301) | def llm_rollout(*, strip_proxy: bool = True) -> Callable[[LlmRolloutFunc...
function llm_rollout (line 304) | def llm_rollout(
function _validate_llm_rollout_func (line 352) | def _validate_llm_rollout_func(func: Any) -> TypeGuard[LlmRolloutFunc[An...
function prompt_rollout (line 384) | def prompt_rollout(func: PromptRolloutFunc[T]) -> FunctionalLitAgent[T]:...
function prompt_rollout (line 388) | def prompt_rollout() -> Callable[[PromptRolloutFunc[T]], FunctionalLitAg...
function prompt_rollout (line 391) | def prompt_rollout(
function _validate_prompt_rollout_func (line 434) | def _validate_prompt_rollout_func(func: Any) -> TypeGuard[PromptRolloutF...
function rollout (line 465) | def rollout(func: Union[LlmRolloutFunc[T], PromptRolloutFunc[T], Callabl...
FILE: agentlightning/litagent/litagent.py
function is_v0_1_rollout_api (line 30) | def is_v0_1_rollout_api(func: Callable[..., Any]) -> bool:
class LitAgent (line 45) | class LitAgent(Generic[T]):
method __init__ (line 52) | def __init__(self, *, trained_agents: Optional[str] = None) -> None: ...
method is_async (line 75) | def is_async(self) -> bool:
method set_trainer (line 92) | def set_trainer(self, trainer: Trainer) -> None:
method get_trainer (line 100) | def get_trainer(self) -> Trainer:
method trainer (line 110) | def trainer(self) -> Trainer:
method get_tracer (line 114) | def get_tracer(self) -> Tracer:
method tracer (line 122) | def tracer(self) -> Tracer:
method set_runner (line 126) | def set_runner(self, runner: Runner[T]) -> None:
method get_runner (line 134) | def get_runner(self) -> Runner[T]:
method runner (line 144) | def runner(self) -> Runner[T]:
method on_rollout_start (line 148) | def on_rollout_start(self, task: Task, runner: Runner[T], tracer: Trac...
method on_rollout_end (line 164) | def on_rollout_end(self, task: Task, rollout: Rollout, runner: Runner[...
method rollout (line 181) | def rollout(self, task: T, resources: NamedResources, rollout: Rollout...
method rollout_async (line 205) | async def rollout_async(self, task: T, resources: NamedResources, roll...
method training_rollout (line 220) | def training_rollout(self, task: T, resources: NamedResources, rollout...
method validation_rollout (line 228) | def validation_rollout(self, task: T, resources: NamedResources, rollo...
method training_rollout_async (line 237) | async def training_rollout_async(self, task: T, resources: NamedResour...
method validation_rollout_async (line 245) | async def validation_rollout_async(self, task: T, resources: NamedReso...
FILE: agentlightning/llm_proxy.py
class ModelConfig (line 68) | class ModelConfig(TypedDict):
function _get_pre_call_data (line 83) | def _get_pre_call_data(args: Any, kwargs: Any) -> Dict[str, Any]:
function _reset_litellm_logging_worker (line 110) | def _reset_litellm_logging_worker() -> None:
function _reset_litellm_logging_callback_manager (line 134) | def _reset_litellm_logging_callback_manager() -> None:
class AddReturnTokenIds (line 149) | class AddReturnTokenIds(CustomLogger):
method async_pre_call_hook (line 159) | async def async_pre_call_hook(self, *args: Any, **kwargs: Any) -> Opti...
class AddLogprobs (line 178) | class AddLogprobs(CustomLogger):
method async_pre_call_hook (line 185) | async def async_pre_call_hook(self, *args: Any, **kwargs: Any) -> Opti...
class LightningSpanExporter (line 196) | class LightningSpanExporter(SpanExporter):
method __init__ (line 213) | def __init__(self, _store: Optional[LightningStore] = None):
method _ensure_loop (line 227) | def _ensure_loop(self) -> asyncio.AbstractEventLoop:
method _ensure_lock (line 240) | def _ensure_lock(self) -> threading.Lock:
method _clear_loop_and_lock (line 251) | def _clear_loop_and_lock(self) -> None:
method _run_loop (line 266) | def _run_loop(self) -> None:
method shutdown (line 272) | def shutdown(self) -> None:
method export (line 294) | def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
method _maybe_flush (line 321) | def _maybe_flush(self):
method _get_root_span_ids (line 441) | def _get_root_span_ids(self) -> Iterable[int]:
method _get_subtrees (line 455) | def _get_subtrees(self, root_span_id: int) -> Iterable[int]:
method _pop_subtrees (line 476) | def _pop_subtrees(self, root_span_id: int) -> List[ReadableSpan]:
class LightningOpenTelemetry (line 499) | class LightningOpenTelemetry(OpenTelemetry):
method __init__ (line 509) | def __init__(self):
method async_pre_call_deployment_hook (line 518) | async def async_pre_call_deployment_hook(
class RolloutAttemptMiddleware (line 536) | class RolloutAttemptMiddleware(BaseHTTPMiddleware):
method dispatch (line 544) | async def dispatch(self, request: Request, call_next: Callable[[Reques...
class MessageInspectionMiddleware (line 580) | class MessageInspectionMiddleware(BaseHTTPMiddleware):
method dispatch (line 586) | async def dispatch(self, request: Request, call_next: Callable[[Reques...
class StreamConversionMiddleware (line 598) | class StreamConversionMiddleware(BaseHTTPMiddleware):
method dispatch (line 607) | async def dispatch(self, request: Request, call_next: Callable[[Reques...
method _handle_stream_case (line 642) | async def _handle_stream_case(
method anthropic_stream_generator (line 722) | async def anthropic_stream_generator(self, original_response: Dict[str...
method openai_stream_generator (line 840) | async def openai_stream_generator(self, response_json: Dict[str, Any])...
class LLMProxy (line 1007) | class LLMProxy:
method __init__ (line 1064) | def __init__(
method get_store (line 1136) | def get_store(self) -> Optional[LightningStore]:
method set_store (line 1144) | def set_store(self, store: LightningStore) -> None:
method update_model_list (line 1152) | def update_model_list(self, model_list: List[ModelConfig]) -> None:
method initialize (line 1162) | def initialize(self):
method _serve_context (line 1206) | async def _serve_context(self) -> AsyncGenerator[None, None]:
method start (line 1249) | async def start(self):
method stop (line 1283) | async def stop(self):
method restart (line 1294) | async def restart(self, *, _port: int | None = None) -> None:
method is_running (line 1306) | def is_running(self) -> bool:
method as_resource (line 1314) | def as_resource(
function get_active_llm_proxy (line 1373) | def get_active_llm_proxy() -> LLMProxy:
function set_active_llm_proxy (line 1384) | def set_active_llm_proxy(proxy: LLMProxy) -> None:
function initialize_llm_callbacks (line 1394) | def initialize_llm_callbacks(callback_classes: List[Type[CustomLogger]])...
function _check_tracer_provider (line 1441) | def _check_tracer_provider() -> bool:
FILE: agentlightning/logging.py
function configure_logger (line 18) | def configure_logger(level: int = logging.INFO, name: str = "agentlightn...
function _to_level_value (line 56) | def _to_level_value(lvl: int | str) -> int:
function _ensure_file_handler (line 65) | def _ensure_file_handler(
function setup (line 95) | def setup(
function setup_module (line 286) | def setup_module(
function _has_width (line 368) | def _has_width() -> bool:
FILE: agentlightning/runner/agent.py
class LitAgentRunner (line 60) | class LitAgentRunner(Runner[T_task]):
method __init__ (line 71) | def __init__(
method init (line 114) | def init(self, agent: LitAgent[T_task], *, hooks: Optional[Sequence[Ho...
method init_worker (line 132) | def init_worker(self, worker_id: int, store: LightningStore, **kwargs:...
method teardown (line 149) | def teardown(self, *args: Any, **kwargs: Any) -> None:
method teardown_worker (line 166) | def teardown_worker(self, worker_id: int, *args: Any, **kwargs: Any) -...
method tracer (line 181) | def tracer(self) -> Tracer:
method get_agent (line 189) | def get_agent(self) -> LitAgent[T_task]:
method get_store (line 202) | def get_store(self) -> LightningStore:
method get_worker_id (line 215) | def get_worker_id(self) -> str:
method _log_prefix (line 224) | def _log_prefix(self, rollout_id: Optional[str] = None) -> str:
method _trigger_hooks (line 246) | async def _trigger_hooks(
method _post_process_rollout_result (line 270) | async def _post_process_rollout_result(
method _emit_heartbeat (line 388) | async def _emit_heartbeat(self, store: LightningStore) -> None:
method _start_heartbeat_loop (line 432) | def _start_heartbeat_loop(self, store: LightningStore) -> Optional[Cal...
method _start_heartbeat_asyncio_loop (line 448) | def _start_heartbeat_asyncio_loop(self, store: LightningStore) -> Opti...
method _start_heartbeat_thread_loop (line 484) | def _start_heartbeat_thread_loop(self, store: LightningStore) -> Optio...
method _sleep_until_next_poll (line 599) | async def _sleep_until_next_poll(self, event: Optional[ExecutionEvent]...
method _step_impl (line 621) | async def _step_impl(self, next_rollout: AttemptedRollout, raise_on_ex...
method iter (line 737) | async def iter(self, *, event: Optional[ExecutionEvent] = None) -> None:
method step (line 794) | async def step(
FILE: agentlightning/runner/base.py
class Runner (line 25) | class Runner(ParallelWorkerBase, Generic[T_task]):
method init (line 35) | def init(self, agent: LitAgent[T_task], **kwargs: Any) -> None:
method init_worker (line 50) | def init_worker(self, worker_id: int, store: LightningStore, **kwargs:...
method run (line 66) | def run(self, *args: Any, **kwargs: Any) -> None:
method teardown (line 78) | def teardown(self, *args: Any, **kwargs: Any) -> None:
method teardown_worker (line 86) | def teardown_worker(self, worker_id: int, *args: Any, **kwargs: Any) -...
method run_context (line 98) | def run_context(
method iter (line 142) | async def iter(self, *, event: Optional[ExecutionEvent] = None) -> None:
method step (line 157) | async def step(
FILE: agentlightning/runner/legacy.py
class LegacyAgentRunner (line 26) | class LegacyAgentRunner(Runner[Any]):
method __init__ (line 42) | def __init__(
method init (line 62) | def init(self, *args: Any, **kwargs: Any) -> None:
method init_worker (line 65) | def init_worker(self, worker_id: int, *args: Any, **kwargs: Any) -> None:
method teardown_worker (line 68) | def teardown_worker(self, worker_id: int, *args: Any, **kwargs: Any) -...
method teardown (line 71) | def teardown(self, *args: Any, **kwargs: Any) -> None:
method _log_prefix (line 74) | def _log_prefix(self, rollout_id: Optional[str] = None) -> str:
method _to_rollout_object (line 85) | def _to_rollout_object(
method run (line 157) | def run(self) -> bool: # type: ignore
method iter (line 219) | def iter(self) -> int: # type: ignore
method run_async (line 234) | async def run_async(self) -> bool:
method iter_async (line 297) | async def iter_async(self) -> int:
FILE: agentlightning/semconv.py
class LightningResourceAttributes (line 47) | class LightningResourceAttributes(Enum):
class LightningSpanAttributes (line 63) | class LightningSpanAttributes(Enum):
class RewardAttributes (line 108) | class RewardAttributes(Enum):
class RewardPydanticModel (line 126) | class RewardPydanticModel(BaseModel):
class LinkAttributes (line 136) | class LinkAttributes(Enum):
class LinkPydanticModel (line 157) | class LinkPydanticModel(BaseModel):
FILE: agentlightning/server.py
class ServerDataStore (line 36) | class ServerDataStore:
method __init__ (line 48) | def __init__(self):
method add_task (line 61) | async def add_task(
method get_next_task (line 95) | async def get_next_task(self) -> Optional[Task]:
method update_resources (line 120) | async def update_resources(self, update: ResourcesUpdate):
method get_resources_by_id (line 132) | async def get_resources_by_id(self, resources_id: str) -> Optional[Res...
method get_latest_resources (line 154) | async def get_latest_resources(self) -> Optional[ResourcesUpdate]:
method store_rollout (line 160) | async def store_rollout(self, rollout: RolloutLegacy):
method retrieve_rollout (line 171) | async def retrieve_rollout(self, rollout_id: str) -> Optional[RolloutL...
method retrieve_completed_rollouts (line 184) | async def retrieve_completed_rollouts(self) -> List[RolloutLegacy]:
method get_processing_tasks (line 191) | def get_processing_tasks(self) -> Dict[str, Task]:
method requeue_task (line 195) | async def requeue_task(self, task: Task):
class AgentLightningServer (line 204) | class AgentLightningServer:
method __init__ (line 217) | def __init__(self, host: str = "127.0.0.1", port: int = 8000, task_tim...
method _lifespan (line 248) | async def _lifespan(self, app: FastAPI):
method _check_and_requeue_stale_tasks (line 262) | async def _check_and_requeue_stale_tasks(self):
method _setup_routes (line 277) | def _setup_routes(self):
method start (line 331) | async def start(self):
method stop (line 337) | async def stop(self):
method run_forever (line 345) | async def run_forever(self):
method queue_task (line 349) | async def queue_task(
method update_resources (line 361) | async def update_resources(self, resources: NamedResources) -> str:
method get_completed_rollout (line 372) | async def get_completed_rollout(self, rollout_id: str) -> Optional[Rol...
method poll_completed_rollout (line 378) | async def poll_completed_rollout(self, rollout_id: str, timeout: Optio...
method retrieve_completed_rollouts (line 397) | async def retrieve_completed_rollouts(self) -> List[RolloutLegacy]:
FILE: agentlightning/store/base.py
function is_queuing (line 27) | def is_queuing(rollout: Rollout) -> bool:
function is_running (line 31) | def is_running(rollout: Rollout) -> bool:
function is_finished (line 35) | def is_finished(rollout: Rollout) -> bool:
class _UnsetType (line 39) | class _UnsetType:
method __repr__ (line 44) | def __repr__(self) -> str:
method __reduce__ (line 47) | def __reduce__(self):
function _get_unset (line 51) | def _get_unset() -> _UnsetType:
class LightningStoreCapabilities (line 59) | class LightningStoreCapabilities(TypedDict, total=False):
class LightningStoreStatistics (line 75) | class LightningStoreStatistics(TypedDict, total=False):
class LightningStore (line 104) | class LightningStore:
method capabilities (line 127) | def capabilities(self) -> LightningStoreCapabilities:
method statistics (line 136) | async def statistics(self) -> LightningStoreStatistics:
method otlp_traces_endpoint (line 142) | def otlp_traces_endpoint(self) -> str:
method start_rollout (line 158) | async def start_rollout(
method enqueue_rollout (line 200) | async def enqueue_rollout(
method enqueue_many_rollouts (line 234) | async def enqueue_many_rollouts(self, rollouts: Sequence[EnqueueRollou...
method dequeue_rollout (line 250) | async def dequeue_rollout(self, worker_id: Optional[str] = None) -> Op...
method dequeue_many_rollouts (line 277) | async def dequeue_many_rollouts(
method start_attempt (line 300) | async def start_attempt(self, rollout_id: str, worker_id: Optional[str...
method add_many_spans (line 322) | async def add_many_spans(self, spans: Sequence[Span]) -> Sequence[Span]:
method add_span (line 330) | async def add_span(self, span: Span) -> Optional[Span]:
method add_otel_span (line 355) | async def add_otel_span(
method query_rollouts (line 386) | async def query_rollouts(
method query_attempts (line 433) | async def query_attempts(
method get_rollout_by_id (line 465) | async def get_rollout_by_id(self, rollout_id: str) -> Optional[Rollout]:
method get_latest_attempt (line 479) | async def get_latest_attempt(self, rollout_id: str) -> Optional[Attempt]:
method query_resources (line 494) | async def query_resources(
method get_resources_by_id (line 529) | async def get_resources_by_id(self, resources_id: str) -> Optional[Res...
method get_latest_resources (line 543) | async def get_latest_resources(self) -> Optional[ResourcesUpdate]:
method get_next_span_sequence_id (line 555) | async def get_next_span_sequence_id(self, rollout_id: str, attempt_id:...
method get_many_span_sequence_ids (line 579) | async def get_many_span_sequence_ids(self, rollout_attempt_ids: Sequen...
method wait_for_rollouts (line 593) | async def wait_for_rollouts(self, *, rollout_ids: List[str], timeout: ...
method query_spans (line 619) | async def query_spans(
method add_resources (line 681) | async def add_resources(self, resources: NamedResources) -> ResourcesU...
method update_resources (line 699) | async def update_resources(self, resources_id: str, resources: NamedRe...
method update_rollout (line 718) | async def update_rollout(
method update_attempt (line 756) | async def update_attempt(
method query_workers (line 799) | async def query_workers(
method get_worker_by_id (line 827) | async def get_worker_by_id(self, worker_id: str) -> Optional[Worker]:
method update_worker (line 841) | async def update_worker(
FILE: agentlightning/store/client_server.py
class RolloutRequest (line 81) | class RolloutRequest(BaseModel):
class DequeueRolloutRequest (line 90) | class DequeueRolloutRequest(BaseModel):
class StartAttemptRequest (line 94) | class StartAttemptRequest(BaseModel):
class EnqueueManyRolloutsRequest (line 98) | class EnqueueManyRolloutsRequest(BaseModel):
class DequeueManyRolloutsRequest (line 102) | class DequeueManyRolloutsRequest(BaseModel):
class QueryRolloutsRequest (line 107) | class QueryRolloutsRequest(BaseModel):
class WaitForRolloutsRequest (line 121) | class WaitForRolloutsRequest(BaseModel):
class NextSequenceIdRequest (line 126) | class NextSequenceIdRequest(BaseModel):
class NextSequenceIdResponse (line 131) | class NextSequenceIdResponse(BaseModel):
class UpdateRolloutRequest (line 135) | class UpdateRolloutRequest(BaseModel):
class UpdateAttemptRequest (line 144) | class UpdateAttemptRequest(BaseModel):
class UpdateWorkerRequest (line 151) | class UpdateWorkerRequest(BaseModel):
class QueryAttemptsRequest (line 155) | class QueryAttemptsRequest(BaseModel):
class QueryResourcesRequest (line 164) | class QueryResourcesRequest(BaseModel):
class QuerySpansRequest (line 176) | class QuerySpansRequest(BaseModel):
class QueryWorkersRequest (line 197) | class QueryWorkersRequest(BaseModel):
class CachedStaticFiles (line 210) | class CachedStaticFiles(StaticFiles):
method file_response (line 211) | def file_response(self, *args: Any, **kwargs: Any) -> Response:
class LightningStoreServer (line 218) | class LightningStoreServer(LightningStore):
method __init__ (line 246) | def __init__(
method capabilities (line 311) | def capabilities(self) -> LightningStoreCapabilities:
method otlp_traces_endpoint (line 320) | def otlp_traces_endpoint(self) -> str:
method __getstate__ (line 324) | def __getstate__(self):
method __setstate__ (line 341) | def __setstate__(self, state: Dict[str, Any]):
method _normalize_cors_origins (line 365) | def _normalize_cors_origins(
method _apply_cors (line 387) | def _apply_cors(self) -> None:
method endpoint (line 401) | def endpoint(self) -> str:
method start (line 405) | async def start(self):
method run_forever (line 419) | async def run_forever(self):
method stop (line 426) | async def stop(self):
method _setup_routes (line 435) | def _setup_routes(self):
method _setup_metrics (line 850) | def _setup_metrics(self, api: APIRouter, app: FastAPI):
method _setup_otlp (line 940) | def _setup_otlp(self, api: APIRouter):
method _setup_dashboard (line 970) | def _setup_dashboard(self):
method _call_store_method (line 1010) | async def _call_store_method(self, method_name: str, *args: Any, **kwa...
method statistics (line 1049) | async def statistics(self) -> LightningStoreStatistics:
method start_rollout (line 1052) | async def start_rollout(
method enqueue_rollout (line 1071) | async def enqueue_rollout(
method enqueue_many_rollouts (line 1088) | async def enqueue_many_rollouts(self, rollouts: Sequence[EnqueueRollou...
method dequeue_rollout (line 1091) | async def dequeue_rollout(self, worker_id: Optional[str] = None) -> Op...
method dequeue_many_rollouts (line 1094) | async def dequeue_many_rollouts(
method start_attempt (line 1102) | async def start_attempt(self, rollout_id: str, worker_id: Optional[str...
method query_rollouts (line 1105) | async def query_rollouts(
method query_attempts (line 1133) | async def query_attempts(
method get_latest_attempt (line 1151) | async def get_latest_attempt(self, rollout_id: str) -> Optional[Attempt]:
method query_resources (line 1154) | async def query_resources(
method get_rollout_by_id (line 1174) | async def get_rollout_by_id(self, rollout_id: str) -> Optional[Rollout]:
method add_resources (line 1177) | async def add_resources(self, resources: NamedResources) -> ResourcesU...
method update_resources (line 1180) | async def update_resources(self, resources_id: str, resources: NamedRe...
method get_resources_by_id (line 1183) | async def get_resources_by_id(self, resources_id: str) -> Optional[Res...
method get_latest_resources (line 1186) | async def get_latest_resources(self) -> Optional[ResourcesUpdate]:
method add_span (line 1189) | async def add_span(self, span: Span) -> Optional[Span]:
method add_many_spans (line 1192) | async def add_many_spans(self, spans: Sequence[Span]) -> Sequence[Span]:
method get_next_span_sequence_id (line 1195) | async def get_next_span_sequence_id(self, rollout_id: str, attempt_id:...
method get_many_span_sequence_ids (line 1198) | async def get_many_span_sequence_ids(self, rollout_attempt_ids: Sequen...
method add_otel_span (line 1201) | async def add_otel_span(
method wait_for_rollouts (line 1216) | async def wait_for_rollouts(self, *, rollout_ids: List[str], timeout: ...
method query_spans (line 1219) | async def query_spans(
method update_rollout (line 1257) | async def update_rollout(
method update_attempt (line 1278) | async def update_attempt(
method query_workers (line 1297) | async def query_workers(
method get_worker_by_id (line 1319) | async def get_worker_by_id(self, worker_id: str) -> Optional[Worker]:
method update_worker (line 1322) | async def update_worker(
class LightningStoreClient (line 1334) | class LightningStoreClient(LightningStore):
method __init__ (line 1350) | def __init__(
method capabilities (line 1377) | def capabilities(self) -> LightningStoreCapabilities:
method otlp_traces_endpoint (line 1386) | def otlp_traces_endpoint(self) -> str:
method statistics (line 1390) | async def statistics(self) -> LightningStoreStatistics:
method __getstate__ (line 1394) | def __getstate__(self):
method __setstate__ (line 1409) | def __setstate__(self, state: Dict[str, Any]):
method _get_session (line 1426) | async def _get_session(self) -> aiohttp.ClientSession:
method _wait_until_healthy (line 1458) | async def _wait_until_healthy(self, session: aiohttp.ClientSession) ->...
method _request_json (line 1485) | async def _request_json(
method close (line 1549) | async def close(self):
method start_rollout (line 1570) | async def start_rollout(
method enqueue_rollout (line 1593) | async def enqueue_rollout(
method enqueue_many_rollouts (line 1621) | async def enqueue_many_rollouts(self, rollouts: Sequence[EnqueueRollou...
method _dequeue_batch (line 1632) | async def _dequeue_batch(
method dequeue_rollout (line 1660) | async def dequeue_rollout(self, worker_id: Optional[str] = None) -> Op...
method dequeue_many_rollouts (line 1674) | async def dequeue_many_rollouts(
method start_attempt (line 1682) | async def start_attempt(self, rollout_id: str, worker_id: Optional[str...
method query_rollouts (line 1691) | async def query_rollouts(
method query_attempts (line 1734) | async def query_attempts(
method get_latest_attempt (line 1754) | async def get_latest_attempt(self, rollout_id: str) -> Optional[Attempt]:
method get_rollout_by_id (line 1777) | async def get_rollout_by_id(self, rollout_id: str) -> Optional[Rollout]:
method query_resources (line 1805) | async def query_resources(
method add_resources (line 1834) | async def add_resources(self, resources: NamedResources) -> ResourcesU...
method update_resources (line 1838) | async def update_resources(self, resources_id: str, resources: NamedRe...
method get_resources_by_id (line 1844) | async def get_resources_by_id(self, resources_id: str) -> Optional[Res...
method get_latest_resources (line 1867) | async def get_latest_resources(self) -> Optional[ResourcesUpdate]:
method add_span (line 1885) | async def add_span(self, span: Span) -> Optional[Span]:
method add_many_spans (line 1889) | async def add_many_spans(self, spans: Sequence[Span]) -> Sequence[Span]:
method get_next_span_sequence_id (line 1897) | async def get_next_span_sequence_id(self, rollout_id: str, attempt_id:...
method get_many_span_sequence_ids (line 1906) | async def get_many_span_sequence_ids(self, rollout_attempt_ids: Sequen...
method add_otel_span (line 1912) | async def add_otel_span(
method wait_for_rollouts (line 1930) | async def wait_for_rollouts(self, *, rollout_ids: List[str], timeout: ...
method query_spans (line 1951) | async def query_spans(
method update_rollout (line 1997) | async def update_rollout(
method update_attempt (line 2024) | async def update_attempt(
method query_workers (line 2050) | async def query_workers(
method get_worker_by_id (line 2075) | async def get_worker_by_id(self, worker_id: str) -> Optional[Worker]:
method update_worker (line 2081) | async def update_worker(
FILE: agentlightning/store/collection/base.py
function resolve_error_type (line 67) | def resolve_error_type(exc: BaseException | None) -> str:
function tracked (line 84) | def tracked(operation: str):
function ensure_numeric (line 99) | def ensure_numeric(value: Any, *, description: str) -> TypeGuard[Real]:
class DuplicatedPrimaryKeyError (line 112) | class DuplicatedPrimaryKeyError(ValueError):
class TrackedCollection (line 118) | class TrackedCollection:
method __init__ (line 121) | def __init__(self, tracker: MetricsBackend | None = None):
method tracker (line 125) | def tracker(self) -> MetricsBackend | None:
method collection_name (line 129) | def collection_name(self) -> str:
method extra_tracking_labels (line 134) | def extra_tracking_labels(self) -> Mapping[str, Any]:
method tracking_context (line 139) | async def tracking_context(self, operation: str, collection: str):
class Collection (line 189) | class Collection(TrackedCollection, Generic[T]):
method primary_keys (line 192) | def primary_keys(self) -> Sequence[str]:
method __repr__ (line 196) | def __repr__(self) -> str:
method item_type (line 199) | def item_type(self) -> Type[T]:
method size (line 203) | async def size(self) -> int:
method query (line 207) | async def query(
method get (line 236) | async def get(
method insert (line 253) | async def insert(self, items: Sequence[T]) -> None:
method update (line 261) | async def update(self, items: Sequence[T], update_fields: Sequence[str...
method upsert (line 277) | async def upsert(self, items: Sequence[T], update_fields: Sequence[str...
method delete (line 300) | async def delete(self, items: Sequence[T]) -> None:
class Queue (line 312) | class Queue(TrackedCollection, Generic[T]):
method __repr__ (line 315) | def __repr__(self) -> str:
method item_type (line 318) | def item_type(self) -> Type[T]:
method has (line 322) | async def has(self, item: T) -> bool:
method enqueue (line 326) | async def enqueue(self, items: Sequence[T]) -> Sequence[T]:
method dequeue (line 337) | async def dequeue(self, limit: int = 1) -> Sequence[T]:
method peek (line 349) | async def peek(self, limit: int = 1) -> Sequence[T]:
method size (line 361) | async def size(self) -> int:
class KeyValue (line 366) | class KeyValue(TrackedCollection, Generic[K, V]):
method __repr__ (line 369) | def __repr__(self) -> str:
method has (line 372) | async def has(self, key: K) -> bool:
method get (line 376) | async def get(self, key: K, default: V | None = None) -> V | None:
method set (line 380) | async def set(self, key: K, value: V) -> None:
method inc (line 384) | async def inc(self, key: K, amount: V) -> V:
method chmax (line 392) | async def chmax(self, key: K, value: V) -> V:
method pop (line 400) | async def pop(self, key: K, default: V | None = None) -> V | None:
method size (line 404) | async def size(self) -> int:
class LightningCollections (line 409) | class LightningCollections(TrackedCollection):
method __init__ (line 416) | def __init__(self, tracker: MetricsBackend | None = None, extra_labels...
method register_collection_metrics (line 420) | def register_collection_metrics(self, extra_labels: Optional[Sequence[...
method tracker (line 435) | def tracker(self) -> MetricsBackend | None:
method rollouts (line 439) | def rollouts(self) -> Collection[Rollout]:
method attempts (line 444) | def attempts(self) -> Collection[Attempt]:
method spans (line 449) | def spans(self) -> Collection[Span]:
method resources (line 454) | def resources(self) -> Collection[ResourcesUpdate]:
method workers (line 459) | def workers(self) -> Collection[Worker]:
method rollout_queue (line 464) | def rollout_queue(self) -> Queue[str]:
method span_sequence_ids (line 469) | def span_sequence_ids(self) -> KeyValue[str, int]:
method atomic (line 473) | def atomic(
method execute (line 498) | async def execute(
function merge_must_filters (line 519) | def merge_must_filters(target: MutableMapping[str, FilterField], definit...
function normalize_filter_options (line 549) | def normalize_filter_options(
function resolve_sort_options (line 574) | def resolve_sort_options(sort: Optional[SortOptions]) -> Tuple[Optional[...
FILE: agentlightning/store/collection/memory.py
function _item_matches_filters (line 76) | def _item_matches_filters(
function _get_sort_value (line 143) | def _get_sort_value(item: object, sort_by: str) -> Any:
class ListBasedCollection (line 175) | class ListBasedCollection(Collection[T]):
method __init__ (line 200) | def __init__(
method collection_name (line 225) | def collection_name(self) -> str:
method primary_keys (line 228) | def primary_keys(self) -> Sequence[str]:
method item_type (line 232) | def item_type(self) -> Type[T]:
method size (line 236) | async def size(self) -> int:
method __repr__ (line 240) | def __repr__(self) -> str:
method _ensure_item_type (line 247) | def _ensure_item_type(self, item: T) -> None:
method _extract_primary_key_values (line 252) | def _extract_primary_key_values(self, item: T) -> Tuple[Any, ...]:
method _render_key_values (line 265) | def _render_key_values(self, key_values: Sequence[Any]) -> str:
method _locate_node (line 268) | def _locate_node(
method _mutate_single (line 309) | def _mutate_single(self, item: T, mode: MutationMode, update_fields: S...
method _iter_items (line 393) | def _iter_items(
method _iter_matching_items (line 421) | def _iter_matching_items(
method query (line 507) | async def query(
method get (line 571) | async def get(
method insert (line 608) | async def insert(self, items: Sequence[T]) -> None:
method update (line 630) | async def update(self, items: Sequence[T], update_fields: Sequence[str...
method upsert (line 645) | async def upsert(self, items: Sequence[T], update_fields: Sequence[str...
method delete (line 656) | async def delete(self, items: Sequence[T]) -> None:
class DequeBasedQueue (line 669) | class DequeBasedQueue(Queue[T]):
method __init__ (line 675) | def __init__(
method item_type (line 689) | def item_type(self) -> Type[T]:
method collection_name (line 693) | def collection_name(self) -> str:
method __repr__ (line 696) | def __repr__(self) -> str:
method has (line 700) | async def has(self, item: T) -> bool:
method enqueue (line 706) | async def enqueue(self, items: Sequence[T]) -> Sequence[T]:
method dequeue (line 714) | async def dequeue(self, limit: int = 1) -> Sequence[T]:
method peek (line 723) | async def peek(self, limit: int = 1) -> Sequence[T]:
method size (line 735) | async def size(self) -> int:
class DictBasedKeyValue (line 739) | class DictBasedKeyValue(KeyValue[K, V]):
method __init__ (line 742) | def __init__(
method collection_name (line 750) | def collection_name(self) -> str:
method has (line 754) | async def has(self, key: K) -> bool:
method get (line 758) | async def get(self, key: K, default: V | None = None) -> V | None:
method set (line 762) | async def set(self, key: K, value: V) -> None:
method inc (line 766) | async def inc(self, key: K, amount: V) -> V:
method chmax (line 779) | async def chmax(self, key: K, value: V) -> V:
method pop (line 793) | async def pop(self, key: K, default: V | None = None) -> V | None:
method size (line 797) | async def size(self) -> int:
class InMemoryLightningCollections (line 801) | class InMemoryLightningCollections(LightningCollections):
method __init__ (line 807) | def __init__(self, lock_type: Literal["thread", "asyncio"], tracker: M...
method collection_name (line 840) | def collection_name(self) -> str:
method rollouts (line 844) | def rollouts(self) -> ListBasedCollection[Rollout]:
method attempts (line 848) | def attempts(self) -> ListBasedCollection[Attempt]:
method spans (line 852) | def spans(self) -> ListBasedCollection[Span]:
method resources (line 856) | def resources(self) -> ListBasedCollection[ResourcesUpdate]:
method workers (line 860) | def workers(self) -> ListBasedCollection[Worker]:
method rollout_queue (line 864) | def rollout_queue(self) -> DequeBasedQueue[str]:
method span_sequence_ids (line 868) | def span_sequence_ids(self) -> DictBasedKeyValue[str, int]:
method atomic (line 872) | async def atomic(
method evict_spans_for_rollout (line 907) | async def evict_spans_for_rollout(self, rollout_id: str) -> None:
class _LoopAwareAsyncLock (line 915) | class _LoopAwareAsyncLock:
method __init__ (line 923) | def __init__(self) -> None:
method __getstate__ (line 928) | def __getstate__(self) -> dict[str, Any]:
method __setstate__ (line 931) | def __setstate__(self, state: dict[str, Any]) -> None:
method _get_lock_for_current_loop (line 934) | def _get_lock_for_current_loop(self) -> asyncio.Lock:
method __aenter__ (line 942) | async def __aenter__(self) -> asyncio.Lock:
method __aexit__ (line 947) | async def __aexit__(self, exc_type: type[BaseException] | None, exc: B...
class _ThreadSafeAsyncLock (line 955) | class _ThreadSafeAsyncLock:
method __init__ (line 961) | def __init__(self):
method __aenter__ (line 964) | async def __aenter__(self):
method __aexit__ (line 968) | async def __aexit__(self, *args: Any, **kwargs: Any):
FILE: agentlightning/store/collection/mongo.py
function resolve_mongo_error_type (line 90) | def resolve_mongo_error_type(exc: BaseException | None) -> str | None:
function _field_ops_to_conditions (line 112) | def _field_ops_to_conditions(field: str, ops: Mapping[str, Any]) -> List...
function _build_mongo_filter (line 144) | def _build_mongo_filter(filter_options: Optional[FilterOptions]) -> Dict...
function _ensure_collection (line 196) | async def _ensure_collection(
class MongoClientPool (line 250) | class MongoClientPool(Generic[T_mapping]):
method __init__ (line 257) | def __init__(self, *, mongo_uri: str, mongo_client_kwargs: Mapping[str...
method __aenter__ (line 265) | async def __aenter__(self) -> Self:
method __aexit__ (line 268) | async def __aexit__(self, exc_type: type[BaseException] | None, exc: B...
method close (line 271) | async def close(self) -> None:
method get_client (line 285) | async def get_client(self) -> AsyncMongoClient[T_mapping]:
method get_collection (line 307) | async def get_collection(self, database_name: str, collection_name: st...
class MongoBasedCollection (line 325) | class MongoBasedCollection(Collection[T_model]):
method __init__ (line 339) | def __init__(
method collection_name (line 368) | def collection_name(self) -> str:
method extra_tracking_labels (line 372) | def extra_tracking_labels(self) -> Mapping[str, str]:
method ensure_collection (line 378) | async def ensure_collection(self) -> AsyncCollection[Mapping[str, Any]]:
method with_session (line 393) | def with_session(self, session: AsyncClientSession) -> MongoBasedColle...
method primary_keys (line 409) | def primary_keys(self) -> Sequence[str]:
method item_type (line 413) | def item_type(self) -> Type[T_model]:
method size (line 417) | async def size(self) -> int:
method _pk_filter (line 421) | def _pk_filter(self, item: T_model) -> Dict[str, Any]:
method _render_pk_values (line 431) | def _render_pk_values(self, values: Sequence[Any]) -> str:
method _ensure_item_type (line 434) | def _ensure_item_type(self, item: T_model) -> None:
method _inject_partition_filter (line 438) | def _inject_partition_filter(self, filter: Optional[FilterOptions]) ->...
method _model_validate_item (line 461) | def _model_validate_item(self, raw: Mapping[str, Any]) -> T_model:
method query (line 470) | async def query(
method get (line 516) | async def get(
method insert (line 545) | async def insert(self, items: Sequence[T_model]) -> None:
method update (line 579) | async def update(self, items: Sequence[T_model], update_fields: Sequen...
method upsert (line 626) | async def upsert(self, items: Sequence[T_model], update_fields: Sequen...
method delete (line 676) | async def delete(self, items: Sequence[T_model]) -> None:
class MongoBasedQueue (line 690) | class MongoBasedQueue(Queue[T_generic], Generic[T_generic]):
method __init__ (line 696) | def __init__(
method item_type (line 724) | def item_type(self) -> Type[T_generic]:
method extra_tracking_labels (line 728) | def extra_tracking_labels(self) -> Mapping[str, str]:
method collection_name (line 734) | def collection_name(self) -> str:
method ensure_collection (line 738) | async def ensure_collection(self) -> AsyncCollection[Mapping[str, Any]]:
method with_session (line 750) | def with_session(self, session: AsyncClientSession) -> MongoBasedQueue...
method has (line 764) | async def has(self, item: T_generic) -> bool:
method enqueue (line 778) | async def enqueue(self, items: Sequence[T_generic]) -> Sequence[T_gene...
method dequeue (line 801) | async def dequeue(self, limit: int = 1) -> Sequence[T_generic]:
method peek (line 832) | async def peek(self, limit: int = 1) -> Sequence[T_generic]:
method size (line 858) | async def size(self) -> int:
class MongoBasedKeyValue (line 869) | class MongoBasedKeyValue(KeyValue[K, V], Generic[K, V]):
method __init__ (line 872) | def __init__(
method extra_tracking_labels (line 906) | def extra_tracking_labels(self) -> Mapping[str, str]:
method collection_name (line 912) | def collection_name(self) -> str:
method ensure_collection (line 916) | async def ensure_collection(self, *, create_indexes: bool = True) -> A...
method with_session (line 925) | def with_session(self, session: AsyncClientSession) -> MongoBasedKeyVa...
method has (line 941) | async def has(self, key: K) -> bool:
method get (line 954) | async def get(self, key: K, default: V | None = None) -> V | None:
method set (line 971) | async def set(self, key: K, value: V) -> None:
method inc (line 995) | async def inc(self, key: K, amount: V) -> V:
method chmax (line 1024) | async def chmax(self, key: K, value: V) -> V:
method pop (line 1053) | async def pop(self, key: K, default: V | None = None) -> V | None:
method size (line 1070) | async def size(self) -> int:
class MongoLightningCollections (line 1080) | class MongoLightningCollections(LightningCollections):
method __init__ (line 1086) | def __init__(
method collection_name (line 1203) | def collection_name(self) -> str:
method extra_tracking_labels (line 1207) | def extra_tracking_labels(self) -> Mapping[str, str]:
method with_session (line 1212) | def with_session(self, session: AsyncClientSession) -> Self:
method rollouts (line 1230) | def rollouts(self) -> MongoBasedCollection[Rollout]:
method attempts (line 1234) | def attempts(self) -> MongoBasedCollection[Attempt]:
method spans (line 1238) | def spans(self) -> MongoBasedCollection[Span]:
method resources (line 1242) | def resources(self) -> MongoBasedCollection[ResourcesUpdate]:
method workers (line 1246) | def workers(self) -> MongoBasedCollection[Worker]:
method rollout_queue (line 1250) | def rollout_queue(self) -> MongoBasedQueue[str]:
method span_sequence_ids (line 1254) | def span_sequence_ids(self) -> MongoBasedKeyValue[str, int]:
method _ensure_collections (line 1258) | async def _ensure_collections(self) -> None:
method _lock_manager (line 1272) | async def _lock_manager(self, labels: Optional[Sequence[AtomicLabels]]):
method atomic (line 1286) | async def atomic(
method execute (line 1307) | async def execute(
method with_transaction (line 1342) | async def with_transaction(
FILE: agentlightning/store/collection_based.py
function _with_collections_execute (line 97) | def _with_collections_execute(labels: Sequence[AtomicLabels]):
function tracked (line 126) | def tracked(name: str):
function healthcheck_before (line 180) | def healthcheck_before(func: T_callable) -> T_callable:
function _generate_resources_id (line 211) | def _generate_resources_id() -> str:
function _generate_rollout_id (line 215) | def _generate_rollout_id() -> str:
function _generate_attempt_id (line 219) | def _generate_attempt_id() -> str:
class CollectionBasedLightningStore (line 224) | class CollectionBasedLightningStore(LightningStore, Generic[T_collection...
method __init__ (line 245) | def __init__(
method statistics (line 291) | async def statistics(self) -> LightningStoreStatistics:
method _get_latest_resources (line 305) | async def _get_latest_resources(self) -> Optional[ResourcesUpdate]:
method _update_or_insert_worker (line 311) | async def _update_or_insert_worker(self, worker: Worker, update_fields...
method _unlocked_sync_worker_with_attempt (line 318) | async def _unlocked_sync_worker_with_attempt(
method capabilities (line 361) | def capabilities(self) -> LightningStoreCapabilities:
method _sync_workers_with_attempts (line 369) | async def _sync_workers_with_attempts(self, attempts: Sequence[Attempt...
method _dequeue_mark_worker_idle (line 379) | async def _dequeue_mark_worker_idle(self, worker_id: str) -> None:
method start_rollout (line 395) | async def start_rollout(
method _enqueue_many_rollouts (line 463) | async def _enqueue_many_rollouts(self, collections: T_collections, rol...
method _prepare_single_rollout (line 470) | async def _prepare_single_rollout(
method enqueue_rollout (line 501) | async def enqueue_rollout(
method enqueue_many_rollouts (line 536) | async def enqueue_many_rollouts(self, rollouts: Sequence[EnqueueRollou...
method _unlocked_query_rollouts_by_rollout_ids (line 563) | async def _unlocked_query_rollouts_by_rollout_ids(
method _post_dequeue_rollouts (line 581) | async def _post_dequeue_rollouts(
method dequeue_rollout (line 632) | async def dequeue_rollout(self, worker_id: Optional[str] = None) -> Op...
method dequeue_many_rollouts (line 671) | async def dequeue_many_rollouts(
method start_attempt (line 708) | async def start_attempt(self, rollout_id: str, worker_id: Optional[str...
method query_rollouts (line 762) | async def query_rollouts(
method _unlocked_query_attempts_for_rollout (line 826) | async def _unlocked_query_attempts_for_rollout(self, collections: T_co...
method get_rollout_by_id (line 836) | async def get_rollout_by_id(self, rollout_id: str) -> Optional[Union[R...
method _unlocked_rollout_to_attempted_rollout (line 852) | async def _unlocked_rollout_to_attempted_rollout(
method _unlocked_many_rollouts_to_attempted_rollouts (line 866) | async def _unlocked_many_rollouts_to_attempted_rollouts(
method _unlocked_get_latest_attempt (line 874) | async def _unlocked_get_latest_attempt(self, collections: T_collection...
method query_attempts (line 883) | async def query_attempts(
method get_latest_attempt (line 903) | async def get_latest_attempt(self, rollout_id: str) -> Optional[Attempt]:
method query_resources (line 912) | async def query_resources(
method add_resources (line 940) | async def add_resources(self, resources: NamedResources) -> ResourcesU...
method update_resources (line 961) | async def update_resources(
method get_resources_by_id (line 992) | async def get_resources_by_id(self, resources_id: str) -> Optional[Res...
method get_latest_resources (line 1001) | async def get_latest_resources(self) -> Optional[ResourcesUpdate]:
method _issue_many_span_sequence_ids (line 1009) | async def _issue_many_span_sequence_ids(self, rollout_ids: List[str]) ...
method _sync_span_sequence_id (line 1035) | async def _sync_span_sequence_id(self, rollout_id: str, sequence_id: i...
method get_next_span_sequence_id (line 1041) | async def get_next_span_sequence_id(self, rollout_id: str, attempt_id:...
method get_many_span_sequence_ids (line 1052) | async def get_many_span_sequence_ids(self, rollout_attempt_ids: Sequen...
method add_span (line 1057) | async def add_span(self, span: Span) -> Optional[Span]:
method add_many_spans (line 1068) | async def add_many_spans(self, spans: Sequence[Span]) -> Sequence[Span]:
method add_otel_span (line 1087) | async def add_otel_span(
method _insert_spans_with_fallback (line 1113) | async def _insert_spans_with_fallback(self, spans: Sequence[Span]) -> ...
method _add_many_spans_helper (line 1150) | async def _add_many_spans_helper(self, rollout_id: str, attempt_id: st...
method _post_add_spans (line 1182) | async def _post_add_spans(self, spans: Sequence[Span], rollout_id: str...
method _on_attempt_heartbeat (line 1203) | async def _on_attempt_heartbeat(
method wait_for_rollouts (line 1239) | async def wait_for_rollouts(self, *, rollout_ids: List[str], timeout: ...
method wait_for_rollout (line 1270) | async def wait_for_rollout(self, rollout_id: str, timeout: Optional[fl...
method query_spans (line 1313) | async def query_spans(
method update_rollout (line 1386) | async def update_rollout(
method update_attempt (line 1417) | async def update_attempt(
method _unlocked_update_rollout_only (line 1452) | async def _unlocked_update_rollout_only(
method _post_update_rollout (line 1500) | async def _post_update_rollout(
method _unlocked_update_attempt_and_rollout (line 1555) | async def _unlocked_update_attempt_and_rollout(
method query_workers (line 1629) | async def query_workers(
method get_worker_by_id (line 1657) | async def get_worker_by_id(self, worker_id: str) -> Optional[Worker]:
method update_worker (line 1662) | async def update_worker(
method _unlocked_get_running_rollouts (line 1676) | async def _unlocked_get_running_rollouts(self, collections: T_collecti...
method _scan_for_unhealthy_rollouts (line 1696) | async def _scan_for_unhealthy_rollouts(self) -> None:
method _should_scan_for_unhealthy_rollouts (line 1711) | async def _should_scan_for_unhealthy_rollouts(self) -> bool:
method _find_and_update_unhealthy_rollouts (line 1731) | async def _find_and_update_unhealthy_rollouts(
function get_current_store_methods (line 1767) | def get_current_store_methods() -> Tuple[str, str]:
FILE: agentlightning/store/memory.py
function estimate_model_size (line 42) | def estimate_model_size(obj: Any) -> int:
function _detect_total_memory_bytes (line 57) | def _detect_total_memory_bytes() -> int:
class InMemoryLightningStore (line 70) | class InMemoryLightningStore(CollectionBasedLightningStore[InMemoryLight...
method __init__ (line 88) | def __init__(
method capabilities (line 147) | def capabilities(self) -> LightningStoreCapabilities:
method statistics (line 156) | async def statistics(self) -> LightningStoreStatistics:
method wait_for_rollout (line 167) | async def wait_for_rollout(self, rollout_id: str, timeout: Optional[fl...
method add_resources (line 207) | async def add_resources(self, resources: NamedResources) -> ResourcesU...
method update_resources (line 214) | async def update_resources(self, resources_id: str, resources: NamedRe...
method _post_update_rollout (line 221) | async def _post_update_rollout(
method _unlocked_query_rollouts_by_rollout_ids (line 245) | async def _unlocked_query_rollouts_by_rollout_ids(
method _unlocked_get_running_rollouts (line 256) | async def _unlocked_get_running_rollouts(self, collections: InMemoryLi...
method query_spans (line 276) | async def query_spans(
method _post_add_spans (line 287) | async def _post_add_spans(self, spans: Sequence[Span], rollout_id: str...
method _get_latest_resources (line 299) | async def _get_latest_resources(self) -> Optional[ResourcesUpdate]:
method _resolve_memory_threshold (line 310) | def _resolve_memory_threshold(
method _account_span_size (line 340) | async def _account_span_size(self, span: Span) -> int:
method _maybe_evict_spans (line 351) | async def _maybe_evict_spans(self, collections: InMemoryLightningColle...
method _evict_spans_for_rollout (line 374) | async def _evict_spans_for_rollout(self, collections: InMemoryLightnin...
FILE: agentlightning/store/mongo.py
function _generate_partition_id (line 24) | def _generate_partition_id() -> str:
class MongoLightningStore (line 28) | class MongoLightningStore(CollectionBasedLightningStore[MongoLightningCo...
method __init__ (line 43) | def __init__(
method capabilities (line 81) | def capabilities(self) -> LightningStoreCapabilities:
method close (line 90) | async def close(self) -> None:
method wait_for_rollouts (line 96) | async def wait_for_rollouts(self, *, rollout_ids: List[str], timeout: ...
method _unlocked_many_rollouts_to_attempted_rollouts (line 143) | async def _unlocked_many_rollouts_to_attempted_rollouts(
FILE: agentlightning/store/threading.py
class LightningStoreThreaded (line 29) | class LightningStoreThreaded(LightningStore):
method __init__ (line 36) | def __init__(self, store: LightningStore) -> None:
method capabilities (line 42) | def capabilities(self) -> LightningStoreCapabilities:
method statistics (line 51) | async def statistics(self) -> LightningStoreStatistics:
method start_rollout (line 56) | async def start_rollout(
method enqueue_rollout (line 75) | async def enqueue_rollout(
method enqueue_many_rollouts (line 86) | async def enqueue_many_rollouts(self, rollouts: Sequence[EnqueueRollou...
method dequeue_rollout (line 90) | async def dequeue_rollout(self, worker_id: Optional[str] = None) -> Op...
method dequeue_many_rollouts (line 94) | async def dequeue_many_rollouts(
method start_attempt (line 103) | async def start_attempt(self, rollout_id: str, worker_id: Optional[str...
method query_rollouts (line 107) | async def query_rollouts(
method query_attempts (line 135) | async def query_attempts(
method get_rollout_by_id (line 153) | async def get_rollout_by_id(self, rollout_id: str) -> Optional[Rollout]:
method get_latest_attempt (line 157) | async def get_latest_attempt(self, rollout_id: str) -> Optional[Attempt]:
method query_resources (line 161) | async def query_resources(
method add_resources (line 181) | async def add_resources(self, resources: NamedResources) -> ResourcesU...
method update_resources (line 185) | async def update_resources(self, resources_id: str, resources: NamedRe...
method get_resources_by_id (line 189) | async def get_resources_by_id(self, resources_id: str) -> Optional[Res...
method get_latest_resources (line 193) | async def get_latest_resources(self) -> Optional[ResourcesUpdate]:
method add_many_spans (line 197) | async def add_many_spans(self, spans: Sequence[Span]) -> Sequence[Span]:
method add_span (line 201) | async def add_span(self, span: Span) -> Optional[Span]:
method add_otel_span (line 205) | async def add_otel_span(
method wait_for_rollouts (line 215) | async def wait_for_rollouts(self, *, rollout_ids: List[str], timeout: ...
method get_next_span_sequence_id (line 219) | async def get_next_span_sequence_id(self, rollout_id: str, attempt_id:...
method get_many_span_sequence_ids (line 223) | async def get_many_span_sequence_ids(self, rollout_attempt_ids: Sequen...
method query_spans (line 227) | async def query_spans(
method update_rollout (line 265) | async def update_rollout(
method update_attempt (line 286) | async def update_attempt(
method query_workers (line 305) | async def query_workers(
method get_worker_by_id (line 326) | async def get_worker_by_id(self, worker_id: str) -> Optional[Worker]:
method update_worker (line 330) | async def update_worker(
FILE: agentlightning/store/utils.py
function rollout_status_from_attempt (line 60) | async def rollout_status_from_attempt(
function scan_unhealthy_rollouts (line 87) | async def scan_unhealthy_rollouts(
FILE: agentlightning/tracer/agentops.py
class AgentOpsTracer (line 32) | class AgentOpsTracer(OtelTracer):
method __init__ (line 52) | def __init__(self, *, agentops_managed: bool = True, instrument_manage...
method instrument (line 64) | def instrument(self, worker_id: int):
method uninstrument (line 67) | def uninstrument(self, worker_id: int):
method _initialize_tracer_provider (line 70) | def _initialize_tracer_provider(self, worker_id: int):
method teardown_worker (line 98) | def teardown_worker(self, worker_id: int) -> None:
method trace_context (line 110) | async def trace_context(
method _trace_context_sync (line 142) | def _trace_context_sync(
method _agentops_trace_context (line 181) | def _agentops_trace_context(self, rollout_id: Optional[str], attempt_i...
method get_langchain_handler (line 194) | def get_langchain_handler(self, tags: List[str] | None = None) -> Lang...
method _get_tracer_provider (line 220) | def _get_tracer_provider(self) -> TracerProviderImpl:
FILE: agentlightning/tracer/base.py
class Tracer (line 27) | class Tracer(ParallelWorkerBase):
method init_worker (line 64) | def init_worker(self, worker_id: int, store: Optional[LightningStore] ...
method trace_context (line 74) | def trace_context(
method _trace_context_sync (line 98) | def _trace_context_sync(
method get_last_trace (line 108) | def get_last_trace(self) -> List[Span]:
method trace_run (line 117) | def trace_run(self, func: Callable[..., Any], *args: Any, **kwargs: An...
method create_span (line 134) | def create_span(
method operation_context (line 156) | def operation_context(
method trace_run_async (line 176) | async def trace_run_async(self, func: Callable[..., Awaitable[Any]], *...
method get_langchain_handler (line 193) | def get_langchain_handler(self) -> Optional[BaseCallbackHandler]: # t...
method lifespan (line 202) | def lifespan(self, store: Optional[LightningStore] = None):
function set_active_tracer (line 229) | def set_active_tracer(tracer: Tracer):
function clear_active_tracer (line 241) | def clear_active_tracer():
function get_active_tracer (line 247) | def get_active_tracer() -> Optional[Tracer]:
class _ActiveTracerAsyncCM (line 257) | class _ActiveTracerAsyncCM(AsyncContextManager[T]):
method __init__ (line 258) | def __init__(self, tracer: Tracer, inner: AsyncContextManager[T]):
method __aenter__ (line 262) | async def __aenter__(self) -> T:
method __aexit__ (line 270) | async def __aexit__(self, *args: Any, **kwargs: Any) -> Optional[bool]:
function with_active_tracer_context (line 277) | def with_active_tracer_context(
FILE: agentlightning/tracer/dummy.py
class DummySpanRecordingContext (line 27) | class DummySpanRecordingContext(SpanRecordingContext):
method __init__ (line 30) | def __init__(self, name: str, attributes: Optional[Attributes] = None,...
method record_exception (line 37) | def record_exception(self, exception: BaseException) -> None:
method record_attributes (line 41) | def record_attributes(self, attributes: Attributes) -> None:
method record_status (line 44) | def record_status(self, status_code: StatusCode, description: Optional...
method finalize (line 47) | def finalize(self, end_time: Optional[float] = None) -> None:
method get_recorded_span (line 50) | def get_recorded_span(self) -> SpanCoreFields:
class DummyTracer (line 62) | class DummyTracer(Tracer):
method create_span (line 68) | def create_span(
method operation_context (line 90) | def operation_context(
FILE: agentlightning/tracer/otel.py
function to_otel_status_code (line 33) | def to_otel_status_code(status_code: StatusCode) -> trace_api.StatusCode:
class OtelSpanRecordingContext (line 42) | class OtelSpanRecordingContext(SpanRecordingContext):
method __init__ (line 43) | def __init__(self, span: trace_api.Span) -> None:
method record_exception (line 46) | def record_exception(self, exception: BaseException) -> None:
method record_attributes (line 50) | def record_attributes(self, attributes: Attributes) -> None:
method record_status (line 53) | def record_status(self, status_code: StatusCode, description: Optional...
method get_otel_span (line 57) | def get_otel_span(self) -> trace_api.Span:
method get_recorded_span (line 60) | def get_recorded_span(self) -> SpanCoreFields:
class OtelTracer (line 73) | class OtelTracer(Tracer):
method __init__ (line 80) | def __init__(self):
method init_worker (line 89) | def init_worker(self, worker_id: int, store: Optional[LightningStore] ...
method _initialize_tracer_provider (line 93) | def _initialize_tracer_provider(self, worker_id: int):
method teardown_worker (line 119) | def teardown_worker(self, worker_id: int):
method trace_context (line 125) | async def trace_context(
method create_span (line 175) | def create_span(
method operation_context (line 206) | def operation_context(
method get_last_trace (line 232) | def get_last_trace(self) -> List[Span]:
method _get_tracer_provider (line 243) | def _get_tracer_provider(self) -> TracerProviderImpl:
method _enable_native_otlp_exporter (line 250) | def _enable_native_otlp_exporter(self, store: LightningStore, rollout_...
method _disable_native_otlp_exporter (line 290) | def _disable_native_otlp_exporter(self):
class LightningSpanProcessor (line 308) | class LightningSpanProcessor(SpanProcessor):
method __init__ (line 318) | def __init__(self, disable_store_submission: bool = False):
method __repr__ (line 335) | def __repr__(self) -> str:
method store (line 345) | def store(self) -> Optional[LightningStore]:
method rollout_id (line 350) | def rollout_id(self) -> Optional[str]:
method attempt_id (line 355) | def attempt_id(self) -> Optional[str]:
method disable_store_submission (line 360) | def disable_store_submission(self) -> bool:
method disable_store_submission (line 365) | def disable_store_submission(self, value: bool) -> None:
method _ensure_loop (line 368) | def _ensure_loop(self) -> None:
method _loop_runner (line 383) | def _loop_runner(self):
method __enter__ (line 391) | def __enter__(self):
method __exit__ (line 396) | def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any):
method _await_in_loop (line 401) | def _await_in_loop(self, coro: Awaitable[Any], timeout: Optional[float...
method shutdown (line 435) | def shutdown(self) -> None:
method force_flush (line 442) | def force_flush(self, timeout_millis: int = 30000) -> bool:
method spans (line 445) | def spans(self) -> List[Span]:
method with_context (line 455) | def with_context(self, store: LightningStore, rollout_id: str, attempt...
method on_end (line 472) | def on_end(self, span: ReadableSpan) -> None:
FILE: agentlightning/tracer/weave.py
function op_name_to_func_name (line 58) | def op_name_to_func_name(op_name: str) -> str:
function random_project_name (line 70) | def random_project_name() -> str:
function get_timestamp_or_throw (line 74) | def get_timestamp_or_throw(date: Optional[datetime], field_name: str) ->...
class WeaveSpanRecordingContext (line 80) | class WeaveSpanRecordingContext(SpanRecordingContext):
method __init__ (line 83) | def __init__(self, call: Call) -> None:
method record_exception (line 86) | def record_exception(self, exception: BaseException) -> None:
method _get_input_from_attributes (line 91) | def _get_input_from_attributes(self, attributes: Attributes) -> Dict[s...
method _get_output_from_attributes (line 104) | def _get_output_from_attributes(self, attributes: Attributes) -> Any:
method record_attributes (line 110) | def record_attributes(self, attributes: Attributes) -> None:
method record_status (line 139) | def record_status(self, status_code: StatusCode, description: Optional...
method finalize (line 148) | def finalize(self) -> None:
method get_recorded_span (line 152) | def get_recorded_span(self) -> SpanCoreFields:
class WeaveTracerManagedTraceServer (line 164) | class WeaveTracerManagedTraceServer(InMemoryWeaveTraceServer):
method __init__ (line 167) | def __init__(
method trigger_callbacks (line 177) | def trigger_callbacks(self, call_id: str) -> None:
method call_start (line 190) | def call_start(self, req: tsi.CallStartReq) -> tsi.CallStartRes:
method call_end (line 199) | def call_end(self, req: tsi.CallEndReq) -> tsi.CallEndRes:
method clear (line 208) | def clear(self) -> None:
class WeaveTracer (line 212) | class WeaveTracer(Tracer):
method __init__ (line 224) | def __init__(
method instrument (line 257) | def instrument(self, worker_id: int):
method uninstrument (line 260) | def uninstrument(self, worker_id: int):
method init_worker (line 263) | def init_worker(self, worker_id: int, store: Optional[LightningStore] ...
method teardown_worker (line 304) | def teardown_worker(self, worker_id: int):
method trace_context (line 319) | async def trace_context(
method create_span (line 393) | def create_span(
method operation_context (line 427) | def operation_context(
method _init_trace_context (line 453) | async def _init_trace_context(self) -> None:
method _get_weave_client (line 461) | def _get_weave_client(self) -> WeaveClient:
method _ensure_loop (line 468) | def _ensure_loop(self) -> tuple[asyncio.AbstractEventLoop, bool]:
method get_last_trace (line 492) | def get_last_trace(self) -> List[Span]:
method partial_call_callback (line 495) | def partial_call_callback(self, request_content: Dict[str, Any]) -> None:
method complete_call_callback (line 516) | def complete_call_callback(self, call: tsi.CallSchema) -> None:
method _get_next_sequence_id (line 528) | async def _get_next_sequence_id(self) -> int:
method partial_call_handler (line 539) | async def partial_call_handler(self, request_content: Dict[str, Any]) ...
method complete_call_handler (line 551) | async def complete_call_handler(self, call: tsi.CallSchema) -> None:
method convert_call_to_span (line 580) | async def convert_call_to_span(
FILE: agentlightning/trainer/init_utils.py
function load_class (line 15) | def load_class(path: str) -> type[Any]:
function instantiate_component (line 22) | def instantiate_component(
function instantiate_from_spec (line 38) | def instantiate_from_spec(
function _ensure_expected_type (line 73) | def _ensure_expected_type(
function build_component (line 88) | def build_component(
function build_component (line 105) | def build_component(
function build_component (line 122) | def build_component(
function build_component (line 138) | def build_component(
FILE: agentlightning/trainer/legacy.py
class TrainerLegacy (line 24) | class TrainerLegacy(ParallelWorkerBase):
method __init__ (line 27) | def __init__(self, *args: Any, **kwargs: Any):
method _extract_client_from_data (line 41) | def _extract_client_from_data(
method _extract_dataset_from_data (line 53) | def _extract_dataset_from_data(
method _determine_backend (line 61) | def _determine_backend(
method init (line 91) | def init(self, backend: Union[str, AgentLightningClient]) -> None:
method teardown (line 100) | def teardown(self) -> None:
method client (line 107) | def client(self) -> AgentLightningClient:
method _init_client (line 113) | def _init_client(self, backend: Union[str, AgentLightningClient]) -> A...
method _worker_main_loop (line 130) | def _worker_main_loop(self, agent: LitAgent[Any], worker_id: int, is_a...
method _initialize_worker_env (line 185) | def _initialize_worker_env(self, worker_id: int):
method _teardown_worker_env (line 189) | def _teardown_worker_env(self, worker_id: int):
method kill_orphaned_processes (line 195) | def kill_orphaned_processes() -> None:
method _terminate_processes (line 207) | def _terminate_processes(self, processes: List[multiprocessing.Process...
method fit_v0 (line 225) | def fit_v0(
FILE: agentlightning/trainer/trainer.py
class Trainer (line 36) | class Trainer(TrainerLegacy):
method __init__ (line 120) | def __init__(
method _make_tracer (line 252) | def _make_tracer(self, tracer: ComponentSpec[Tracer]) -> Tracer:
method _make_algorithm (line 269) | def _make_algorithm(self, algorithm: ComponentSpec[Algorithm]) -> Opti...
method _make_adapter (line 280) | def _make_adapter(self, adapter: ComponentSpec[TraceAdapter[Any]]) -> ...
method _make_store (line 293) | def _make_store(self, store: ComponentSpec[LightningStore], strategy: ...
method _make_strategy (line 310) | def _make_strategy(
method _make_llm_proxy (line 342) | def _make_llm_proxy(
method _make_runner (line 367) | def _make_runner(self, runner: ComponentSpec[Runner[Any]]) -> Runner[A...
method _normalize_hooks (line 386) | def _normalize_hooks(self, hooks: Optional[Union[Hook, Sequence[Hook]]...
method fit (line 394) | def fit(
method dev (line 440) | def dev(
method _algorithm_bundle (line 487) | async def _algorithm_bundle(
method _runner_bundle (line 535) | async def _runner_bundle(
FILE: agentlightning/types/core.py
class Triplet (line 69) | class Triplet(BaseModel):
class RolloutLegacy (line 78) | class RolloutLegacy(BaseModel):
class Attempt (line 136) | class Attempt(BaseModel):
class RolloutConfig (line 161) | class RolloutConfig(BaseModel):
class Rollout (line 174) | class Rollout(BaseModel):
class AttemptedRollout (line 202) | class AttemptedRollout(Rollout):
method check_consistency (line 209) | def check_consistency(self) -> AttemptedRollout:
class EnqueueRolloutRequest (line 215) | class EnqueueRolloutRequest(BaseModel):
class Worker (line 236) | class Worker(BaseModel):
class Task (line 263) | class Task(BaseModel):
class TaskIfAny (line 286) | class TaskIfAny(BaseModel):
class GenericResponse (line 318) | class GenericResponse(BaseModel):
class ParallelWorkerBase (line 336) | class ParallelWorkerBase:
method __init__ (line 351) | def __init__(self) -> None:
method init (line 355) | def init(self, *args: Any, **kwargs: Any) -> None:
method init_worker (line 359) | def init_worker(self, worker_id: int, *args: Any, **kwargs: Any) -> None:
method run (line 363) | def run(self, *args: Any, **kwargs: Any) -> Any:
method teardown_worker (line 367) | def teardown_worker(self, worker_id: int, *args: Any, **kwargs: Any) -...
method teardown (line 371) | def teardown(self, *args: Any, **kwargs: Any) -> None:
class Dataset (line 376) | class Dataset(Protocol, Generic[T_co]):
method __getitem__ (line 383) | def __getitem__(self, index: SupportsIndex, /) -> T_co: ...
method __len__ (line 385) | def __len__(self) -> int: ...
class Hook (line 388) | class Hook(ParallelWorkerBase):
method on_trace_start (line 391) | async def on_trace_start(
method on_trace_end (line 406) | async def on_trace_end(
method on_rollout_start (line 421) | async def on_rollout_start(self, *, agent: LitAgent[Any], runner: Runn...
method on_rollout_end (line 434) | async def on_rollout_end(
class FilterField (line 455) | class FilterField(TypedDict, total=False):
class SortOptions (line 504) | class SortOptions(TypedDict):
class PaginatedResult (line 516) | class PaginatedResult(BaseModel, Sequence[T_item]):
method __len__ (line 531) | def __len__(self) -> int:
method __getitem__ (line 535) | def __getitem__(self, index: int) -> T_item: ...
method __getitem__ (line 538) | def __getitem__(self, index: slice) -> Sequence[T_item]: ...
method __getitem__ (line 540) | def __getitem__(self, index: Union[int, slice]) -> Union[T_item, Seque...
method __iter__ (line 546) | def __iter__(self) -> Iterator[T_item]: # type: ignore
method __repr__ (line 549) | def __repr__(self) -> str:
FILE: agentlightning/types/resources.py
class Resource (line 36) | class Resource(BaseModel):
class LLM (line 43) | class LLM(Resource):
method get_base_url (line 56) | def get_base_url(self, *args: Any, **kwargs: Any) -> str:
class ProxyLLM (line 65) | class ProxyLLM(LLM):
method model_post_init (line 75) | def model_post_init(self, __context: Any) -> None:
method __getattribute__ (line 80) | def __getattribute__(self, name: str) -> Any:
method with_attempted_rollout (line 101) | def with_attempted_rollout(self, rollout: AttemptedRollout) -> LLM:
method get_base_url (line 110) | def get_base_url(self, rollout_id: Optional[str], attempt_id: Optional...
class PromptTemplate (line 146) | class PromptTemplate(Resource):
method format (line 155) | def format(self, **kwargs: Any) -> str:
class ResourcesUpdate (line 192) | class ResourcesUpdate(BaseModel):
FILE: agentlightning/types/tracer.py
function convert_timestamp (line 42) | def convert_timestamp(timestamp: Optional[int]) -> Optional[float]:
function extract_extra_fields (line 56) | def extract_extra_fields(src: Any, excluded_fields: List[str]) -> Dict[s...
class SpanContext (line 95) | class SpanContext(BaseModel):
method from_opentelemetry (line 110) | def from_opentelemetry(cls, src: trace_api.SpanContext) -> "SpanContext":
class TraceStatus (line 122) | class TraceStatus(BaseModel):
method from_opentelemetry (line 133) | def from_opentelemetry(cls, src: OtelStatus) -> "TraceStatus":
class Event (line 143) | class Event(BaseModel):
method from_opentelemetry (line 156) | def from_opentelemetry(cls, src: OtelEvent) -> "Event":
class Link (line 167) | class Link(BaseModel):
method from_opentelemetry (line 178) | def from_opentelemetry(cls, src: trace_api.Link) -> "Link":
class OtelResource (line 188) | class OtelResource(BaseModel):
method from_opentelemetry (line 203) | def from_opentelemetry(cls, src: Resource) -> "OtelResource":
class SpanCoreFields (line 213) | class SpanCoreFields(BaseModel):
class SpanRecordingContext (line 231) | class SpanRecordingContext(Protocol):
method record_exception (line 234) | def record_exception(self, exception: BaseException) -> None:
method record_attributes (line 238) | def record_attributes(self, attributes: Attributes) -> None:
method record_status (line 242) | def record_status(self, status_code: StatusCode, description: Optional...
method get_recorded_span (line 246) | def get_recorded_span(self) -> SpanCoreFields:
class Span (line 251) | class Span(BaseModel):
method from_opentelemetry (line 309) | def from_opentelemetry(
method from_attributes (line 374) | def from_attributes(
method from_core_fields (line 450) | def from_core_fields(
class SpanNames (line 481) | class SpanNames(str, Enum):
class SpanAttributeNames (line 502) | class SpanAttributeNames(str, Enum):
FILE: agentlightning/utils/id.py
function generate_id (line 9) | def generate_id(length: int) -> str:
FILE: agentlightning/utils/metrics.py
function _validate_labels (line 35) | def _validate_labels(
function _normalize_label_names (line 65) | def _normalize_label_names(label_names: Optional[Sequence[str]]) -> Tupl...
function _normalize_prometheus_metric_name (line 79) | def _normalize_prometheus_metric_name(metric_name: str) -> str:
class _CounterDef (line 86) | class _CounterDef:
class _HistogramDef (line 95) | class _HistogramDef:
class _CounterState (line 105) | class _CounterState:
class _HistogramState (line 113) | class _HistogramState:
class MetricsBackend (line 120) | class MetricsBackend:
method has_prometheus (line 123) | def has_prometheus(self) -> bool:
method register_counter (line 127) | def register_counter(
method register_histogram (line 149) | def register_histogram(
method inc_counter (line 174) | async def inc_counter(
method observe_histogram (line 193) | async def observe_histogram(
class ConsoleMetricsBackend (line 213) | class ConsoleMetricsBackend(MetricsBackend):
method __init__ (line 248) | def __init__(
method register_counter (line 284) | def register_counter(
method register_histogram (line 311) | def register_histogram(
method inc_counter (line 350) | async def inc_counter(
method observe_histogram (line 392) | async def observe_histogram(
method _prune_events (line 435) | def _prune_events(
method _should_log_locked (line 462) | def _should_log_locked(self, now: float) -> bool:
method _snapshot_locked (line 480) | def _snapshot_locked(
method _truncate_labels_for_logging (line 533) | def _truncate_labels_for_logging(self, labels: LabelDict, group_level:...
method _log (line 550) | def _log(self, message: str) -> None:
method _log_snapshot (line 554) | def _log_snapshot(
method _effective_group_level (line 581) | def _effective_group_level(self, metric_name: str, *, is_histogram: bo...
method _group_counter_snapshots (line 593) | def _group_counter_snapshots(
method _group_histogram_snapshots (line 629) | def _group_histogram_snapshots(
method _log_counter (line 662) | def _log_counter(
method _log_histogram (line 685) | def _log_histogram(
function _format_label_string (line 720) | def _format_label_string(labels: LabelDict) -> str:
function _format_duration (line 727) | def _format_duration(value: float) -> str:
class PrometheusMetricsBackend (line 738) | class PrometheusMetricsBackend(MetricsBackend):
method __init__ (line 751) | def __init__(self) -> None:
method has_prometheus (line 770) | def has_prometheus(self) -> bool:
method register_counter (line 774) | def register_counter(
method register_histogram (line 806) | def register_histogram(
method inc_counter (line 856) | async def inc_counter(
method observe_histogram (line 875) | async def observe_histogram(
method _register_prometheus_metric_name (line 894) | def _register_prometheus_metric_name(self, name: str) -> str:
class MultiMetricsBackend (line 908) | class MultiMetricsBackend(MetricsBackend):
method __init__ (line 911) | def __init__(self, backends: Sequence[MetricsBackend]) -> None:
method has_prometheus (line 924) | def has_prometheus(self) -> bool:
method register_counter (line 928) | def register_counter(
method register_histogram (line 938) | def register_histogram(
method inc_counter (line 954) | async def inc_counter(
method observe_histogram (line 964) | async def observe_histogram(
function setup_multiprocess_prometheus (line 979) | def setup_multiprocess_prometheus():
function get_prometheus_registry (line 997) | def get_prometheus_registry() -> CollectorRegistry:
function shutdown_metrics (line 1010) | def shutdown_metrics(server: Any = None, worker: Any = None, *args: Any,...
FILE: agentlightning/utils/otel.py
function full_qualified_name (line 52) | def full_qualified_name(obj: type) -> str:
function get_tracer_provider (line 58) | def get_tracer_provider(inspect: bool = True) -> TracerProviderImpl:
function get_span_processors (line 126) | def get_span_processors(
function get_tracer (line 145) | def get_tracer(use_active_span_processor: bool = True) -> trace_api.Tracer:
function make_tag_attributes (line 190) | def make_tag_attributes(tags: List[str]) -> Dict[str, Any]:
function extract_tags_from_attributes (line 202) | def extract_tags_from_attributes(attributes: Dict[str, Any]) -> List[str]:
function make_link_attributes (line 212) | def make_link_attributes(links: Dict[str, str]) -> Dict[str, Any]:
function query_linked_spans (line 232) | def query_linked_spans(spans: Sequence[T_SpanLike], links: List[LinkPyda...
function extract_links_from_attributes (line 280) | def extract_links_from_attributes(attributes: Dict[str, Any]) -> List[Li...
function filter_attributes (line 290) | def filter_attributes(attributes: Dict[str, Any], prefix: str) -> Dict[s...
function filter_and_unflatten_attributes (line 305) | def filter_and_unflatten_attributes(attributes: Dict[str, Any], prefix: ...
function flatten_attributes (line 327) | def flatten_attributes(
function unflatten_attributes (line 397) | def unflatten_attributes(flat_data: Dict[str, Any]) -> Union[Dict[str, A...
function sanitize_attribute_value (line 462) | def sanitize_attribute_value(object: Any, force: bool = True) -> Attribu...
function sanitize_attributes (line 481) | def sanitize_attributes(attributes: Dict[str, Any], force: bool = True) ...
function sanitize_list_attribute_sanity (line 497) | def sanitize_list_attribute_sanity(maybe_list: List[Any]) -> AttributeVa...
function check_attributes_sanity (line 515) | def check_attributes_sanity(attributes: Dict[Any, Any]) -> None:
function format_exception_attributes (line 531) | def format_exception_attributes(exception: BaseException) -> Attributes:
FILE: agentlightning/utils/otlp.py
function handle_otlp_export (line 56) | async def handle_otlp_export(
function spans_from_proto (line 113) | async def spans_from_proto(
class LightningStoreOTLPExporter (line 229) | class LightningStoreOTLPExporter(OTLPSpanExporter):
method __repr__ (line 246) | def __repr__(self) -> str:
method endpoint (line 256) | def endpoint(self) -> Optional[str]:
method rollout_id (line 263) | def rollout_id(self) -> Optional[str]:
method attempt_id (line 270) | def attempt_id(self) -> Optional[str]:
method enable_store_otlp (line 276) | def enable_store_otlp(self, endpoint: str, rollout_id: str, attempt_id...
method disable_store_otlp (line 284) | def disable_store_otlp(self) -> None:
method should_bypass (line 291) | def should_bypass(self) -> bool:
method export (line 295) | def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
function _read_body_maybe_gzip (line 318) | def _read_body_maybe_gzip(request: Request, raw_body: bytes) -> bytes:
function _maybe_gzip_response (line 328) | def _maybe_gzip_response(request: Request, payload: bytes) -> Tuple[byte...
function _bad_request_response (line 341) | def _bad_request_response(request: Request, message: str, content_type: ...
function _normalize_rollout_attempt_id (line 364) | def _normalize_rollout_attempt_id(
function _normalize_sequence_id (line 373) | def _normalize_sequence_id(sequence_id: Optional[AttributeValue]) -> Opt...
function _any_value_to_python (line 388) | def _any_value_to_python(value: AnyValue) -> Any:
function _kv_list_to_dict (line 412) | def _kv_list_to_dict(kvs: Sequence[KeyValue]) -> Attributes:
function _bytes_to_trace_id_hex (line 424) | def _bytes_to_trace_id_hex(b: bytes) -> str:
function _bytes_to_span_id_hex (line 431) | def _bytes_to_span_id_hex(b: bytes) -> str:
function _events_from_proto (line 438) | def _events_from_proto(span: ProtoSpan) -> List[Event]:
function _links_from_proto (line 450) | def _links_from_proto(span: ProtoSpan) -> List[Link]:
function _resource_from_proto (line 471) | def _resource_from_proto(resource: ProtoResource, schema_url: str = "") ...
FILE: agentlightning/utils/server_launcher.py
class PythonServerLauncherArgs (line 37) | class PythonServerLauncherArgs:
class ChildEvent (line 74) | class ChildEvent:
class GunicornApp (line 90) | class GunicornApp(BaseApplication):
method __init__ (line 98) | def __init__(self, app: FastAPI, options: Dict[str, Any]):
method load_config (line 103) | def load_config(self):
method load (line 110) | def load(self):
function shutdown_uvicorn_server (line 114) | async def shutdown_uvicorn_server(server: uvicorn.Server, task: asyncio....
function noop_context (line 133) | async def noop_context() -> AsyncIterator[None]:
function run_uvicorn_asyncio (line 138) | async def run_uvicorn_asyncio(
function run_uvicorn_thread (line 239) | def run_uvicorn_thread(
function run_uvicorn_subprocess (line 318) | def run_uvicorn_subprocess(
function run_gunicorn (line 402) | def run_gunicorn(
function _get_default_ipv4_address (line 576) | def _get_default_ipv4_address() -> str:
class PythonServerLauncher (line 597) | class PythonServerLauncher:
method __init__ (line 608) | def __init__(
method initialize (line 620) | def initialize(self):
method __getstate__ (line 643) | def __getstate__(self):
method __setstate__ (line 654) | def __setstate__(self, state: Dict[str, Any]):
method endpoint (line 664) | def endpoint(self) -> str:
method access_endpoint (line 669) | def access_endpoint(self) -> str:
method health_url (line 674) | def health_url(self) -> Optional[str]:
method start (line 683) | async def start(self):
method stop (line 697) | async def stop(self):
method reload (line 711) | async def reload(self):
method run_forever (line 717) | async def run_forever(self):
method is_running (line 757) | def is_running(self) -> bool:
method _normalize_app_ref (line 762) | def _normalize_app_ref(app: FastAPI) -> str:
method _ensure_host (line 768) | def _ensure_host(self) -> str:
method _ensure_port (line 774) | def _ensure_port(self) -> int:
method _ensure_access_host (line 780) | def _ensure_access_host(self) -> str:
method _create_uvicorn_server (line 794) | def _create_uvicorn_server(self) -> uvicorn.Server:
method _ctx (line 806) | def _ctx(self) -> AsyncContextManager[Any]:
method _start_uvicorn_asyncio (line 815) | async def _start_uvicorn_asyncio(self):
method _stop_uvicorn_asyncio (line 833) | async def _stop_uvicorn_asyncio(self):
method _start_uvicorn_thread (line 845) | async def _start_uvicorn_thread(self):
method _stop_uvicorn_thread (line 891) | async def _stop_uvicorn_thread(self):
method _start_serving_process (line 911) | async def _start_serving_process(self):
method _stop_serving_process (line 1009) | async def _stop_serving_process(self):
FILE: agentlightning/utils/system_snapshot.py
function system_snapshot (line 15) | def system_snapshot(include_gpu: bool = False) -> Dict[str, Any]:
FILE: agentlightning/verl/async_server.py
function _unwrap_ray_remote (line 16) | def _unwrap_ray_remote(cls):
class PatchedvLLMServer (line 23) | class PatchedvLLMServer(_unwrap_ray_remote(AsyncvLLMServer)):
method __init__ (line 25) | def __init__(self, *args, **kwargs):
method chat_completion (line 32) | async def chat_completion(self, raw_request: Request):
FILE: agentlightning/verl/daemon.py
function ids_startswith (line 35) | def ids_startswith(
function log_mismatch_detail (line 75) | def log_mismatch_detail(
function get_left_padded_ids_and_attention_mask (line 114) | def get_left_padded_ids_and_attention_mask(
function get_right_padded_ids_and_attention_mask (line 145) | def get_right_padded_ids_and_attention_mask(
function _find_available_port (line 176) | def _find_available_port() -> int:
function _to_native (line 182) | def _to_native(obj: Any) -> Any:
class AgentModeDaemon (line 204) | class AgentModeDaemon:
method __init__ (line 213) | def __init__(
method _internal_loop_runner (line 286) | def _internal_loop_runner(self):
method _is_mrope_model (line 296) | def _is_mrope_model(self) -> bool:
method _resolve_image_path (line 303) | def _resolve_image_path(self, path: str) -> str:
method _get_image_grid_thw (line 313) | def _get_image_grid_thw(self, image_urls: List[str]) -> Optional[torch...
method _compute_mrope_position_ids (line 338) | def _compute_mrope_position_ids(
method _start_proxy_server_v0 (line 363) | def _start_proxy_server_v0(self):
method _update_proxy_server_v1 (line 453) | async def _update_proxy_server_v1(self):
method start (line 474) | def start(self):
method _async_set_up (line 500) | async def _async_set_up(self, data: Dict[str, Any], server_addresses: ...
method set_up_data_and_server (line 590) | def set_up_data_and_server(self, data: Dict[str, Any], server_addresse...
method _validate_data (line 610) | def _validate_data(self, rollout: RolloutLegacy):
method _validate_data_v1 (line 624) | async def _validate_data_v1(self, rollout: Rollout) -> RolloutLegacy:
method _async_run_until_finished (line 673) | async def _async_run_until_finished(self, verbose: bool = True):
method run_until_all_finished (line 700) | def run_until_all_finished(self, verbose: bool = True):
method get_test_metrics (line 722) | def get_test_metrics(self):
method get_train_data_batch (line 807) | def get_train_data_batch(
method clear_data_and_server (line 1136) | def clear_data_and_server(self):
method _fillna_reward (line 1146) | def _fillna_reward(self, rollout: RolloutLegacy):
FILE: agentlightning/verl/dataset.py
class AgentDataset (line 18) | class AgentDataset(RLHFDataset):
method __init__ (line 20) | def __init__(self, *args, **kwargs):
method __getitem__ (line 25) | def __getitem__(self, item):
class LoadedDataset (line 36) | class LoadedDataset(AgentDataset):
method __init__ (line 38) | def __init__(self, dataset: Dataset):
method _read_files_and_tokenize (line 43) | def _read_files_and_tokenize(self):
FILE: agentlightning/verl/entrypoint.py
function main (line 36) | def main(config: Any):
function run_ppo (line 52) | def run_ppo(
class TaskRunner (line 93) | class TaskRunner:
method run (line 94) | def run(
FILE: agentlightning/verl/trainer.py
function _timer (line 49) | def _timer(name: str, timing_raw: Dict[str, float]):
function compute_data_metrics (line 65) | def compute_data_metrics(batch: DataProto, use_critic: bool = True, suff...
class AgentLightningTrainer (line 159) | class AgentLightningTrainer(RayPPOTrainer):
method __init__ (line 176) | def __init__(
method _validate (line 190) | def _validate(self):
method _compute_reference_log_prob (line 208) | def _compute_reference_log_prob(self, batch: DataProto) -> DataProto:
method _train_step (line 239) | def _train_step(self, batch_dict: dict) -> dict:
method fit (line 438) | def fit(self):
FILE: contrib/agentlightning/contrib/adapter/agentos.py
class FlightRecorderAdapter (line 19) | class FlightRecorderAdapter:
method __init__ (line 33) | def __init__(
method _convert_entry (line 50) | def _convert_entry(self, entry: Any, index: int) -> Dict[str, Any]:
method get_spans (line 84) | def get_spans(self) -> List[Dict[str, Any]]:
method import_to_store (line 94) | def import_to_store(self, store: Any) -> int:
method get_violation_summary (line 119) | def get_violation_summary(self) -> Dict[str, Any]:
FILE: contrib/agentlightning/contrib/adapter/triplet_group.py
class TracerTraceToTripletGroup (line 11) | class TracerTraceToTripletGroup(TracerTraceToTriplet):
method __init__ (line 26) | def __init__(self, *args, **kwargs):
method _extract_span_groups (line 29) | def _extract_span_groups(self, spans):
method adapt_group (line 89) | def adapt_group(self, source: Sequence[Span], /) -> List[Triplet]:
FILE: contrib/agentlightning/contrib/agent/env_agent.py
class EnvAgent (line 23) | class EnvAgent(LitAgent):
method __init__ (line 24) | def __init__(self, config, trained_agents: str | None = None) -> None:
method _build_agent (line 29) | def _build_agent(self, llm: LLM, temperature: float):
method _get_instructed_prompt (line 49) | def _get_instructed_prompt(self, prompt, sep="\n\n"):
method rollout_async (line 68) | async def rollout_async(
FILE: contrib/agentlightning/contrib/algorithm/env_verl/daemon.py
function get_left_padded_ids_and_attention_mask (line 36) | def get_left_padded_ids_and_attention_mask(
function get_right_padded_ids_and_attention_mask (line 67) | def get_right_padded_ids_and_attention_mask(
function _find_available_port (line 98) | def _find_available_port() -> int:
function _to_native (line 104) | def _to_native(obj: Any) -> Any:
class EnvAgentModeDaemon (line 126) | class EnvAgentModeDaemon:
method __init__ (line 135) | def __init__(
method _internal_loop_runner (line 202) | def _internal_loop_runner(self):
method _start_proxy_server_v0 (line 210) | def _start_proxy_server_v0(self):
method _update_proxy_server_v1 (line 300) | async def _update_proxy_server_v1(self):
method start (line 321) | def start(self):
method _async_set_up (line 347) | async def _async_set_up(self, data: Dict[str, Any], server_addresses: ...
method set_up_data_and_server (line 437) | def set_up_data_and_server(self, data: Dict[str, Any], server_addresse...
method _validate_data (line 457) | def _validate_data(self, rollout: RolloutLegacy):
method _validate_data_v1 (line 471) | async def _validate_data_v1(self, rollout: Rollout) -> RolloutLegacy:
method _async_run_until_finished (line 522) | async def _async_run_until_finished(self, verbose: bool = True):
method run_until_all_finished (line 549) | def run_until_all_finished(self, verbose: bool = True):
method get_test_metrics (line 571) | def get_test_metrics(self):
method get_train_data_batch (line 656) | def get_train_data_batch(
method clear_data_and_server (line 854) | def clear_data_and_server(self):
method _fillna_reward (line 864) | def _fillna_reward(self, rollout: RolloutLegacy):
FILE: contrib/agentlightning/contrib/algorithm/env_verl/trainer.py
function _timer (line 49) | def _timer(name: str, timing_raw: Dict[str, float]):
function compute_data_metrics (line 65) | def compute_data_metrics(batch: DataProto, use_critic: bool = True, suff...
class EnvAgentLightningTrainer (line 159) | class EnvAgentLightningTrainer(RayPPOTrainer):
method __init__ (line 176) | def __init__(
method _validate (line 190) | def _validate(self):
method _compute_reference_log_prob (line 208) | def _compute_reference_log_prob(self, batch: DataProto) -> DataProto:
method _train_step (line 239) | def _train_step(self, batch_dict: dict) -> dict:
method fit (line 435) | def fit(self):
FILE: contrib/agentlightning/contrib/reward/agentos.py
class PolicyReward (line 18) | class PolicyReward:
method __init__ (line 31) | def __init__(
method _default_reward (line 67) | def _default_reward(self, rollout: Any) -> float:
method __call__ (line 71) | def __call__(self, rollout: Any, *, emit: bool = True) -> float:
method _emit_reward (line 99) | def _emit_reward(
method get_stats (line 121) | def get_stats(self) -> Dict[str, float]:
FILE: contrib/agentlightning/contrib/runner/agentos.py
class PolicyViolation (line 23) | class PolicyViolation:
method penalty (line 33) | def penalty(self) -> float:
class GovernedRollout (line 50) | class GovernedRollout:
method total_penalty (line 65) | def total_penalty(self) -> float:
class AgentOSRunner (line 69) | class AgentOSRunner(Generic[T_task]):
method __init__ (line 87) | def __init__(
method _setup_hooks (line 116) | def _setup_hooks(self) -> None:
method _handle_violation (line 139) | def _handle_violation(
method _emit_violation_span (line 162) | def _emit_violation_span(self, violation: PolicyViolation) -> None:
method agent (line 182) | def agent(self) -> Any:
method agent (line 194) | def agent(self, value: Any) -> None:
method init (line 198) | def init(self, agent: Any, **kwargs: Any) -> None:
method init_worker (line 202) | def init_worker(self, worker_id: int, store: Any, **kwargs: Any) -> None:
method teardown (line 207) | def teardown(self) -> None:
method teardown_worker (line 211) | def teardown_worker(self, worker_id: int) -> None:
method step (line 215) | async def step(
method get_stats (line 268) | def get_stats(self) -> dict:
class PolicyViolationError (line 277) | class PolicyViolationError(Exception):
method __init__ (line 280) | def __init__(self, violation: PolicyViolation):
FILE: contrib/recipes/agentos/demo_governed_training.py
function build_kernel (line 31) | def build_kernel():
function build_runner (line 51) | def build_runner(kernel):
function build_reward (line 68) | def build_reward(kernel, base_reward_fn=None):
function accuracy_reward (line 89) | def accuracy_reward(completions: list[str], references: list[str]) -> li...
function demo_violation_detection (line 94) | def demo_violation_detection(kernel):
function demo_training_loop (line 119) | def demo_training_loop(runner, reward_fn):
function demo_audit_trail (line 142) | def demo_audit_trail(kernel):
function main (line 159) | def main():
class _StubKernel (line 187) | class _StubKernel:
method check_action (line 190) | def check_action(self, action_type, params):
FILE: contrib/recipes/envs/add_instruction.py
function _get_instruction (line 24) | def _get_instruction(type: str, env_name: str = None):
function add_chat_instruction (line 45) | def add_chat_instruction(prompt, type: str, sep: str = "\n\n", env_name:...
function add_single_instruction (line 70) | def add_single_instruction(prompt, type: str, sep: str = "\n\n", env_nam...
FILE: contrib/recipes/envs/prompt_builder.py
class HistoryPromptBuilder (line 8) | class HistoryPromptBuilder:
method __init__ (line 17) | def __init__(self, max_history: int = -1, prompt_type: str = "chat"):
method update_step_count (line 32) | def update_step_count(self):
method update_instruction_prompt (line 36) | def update_instruction_prompt(self, instruction: str):
method update_single_obs_template (line 40) | def update_single_obs_template(self, single_obs_template_wo_his: str, ...
method update_observation (line 51) | def update_observation(self, obs: dict):
method update_action (line 60) | def update_action(self, action: str):
method update_admissible_actions (line 69) | def update_admissible_actions(self, admissible_actions):
method init (line 73) | def init(self, env):
method get_chat_prompt (line 91) | def get_chat_prompt(self):
method get_single_prompt (line 125) | def get_single_prompt(self):
method get_prompt (line 174) | def get_prompt(self):
FILE: contrib/recipes/envs/train_env_agent.py
function run_cmd (line 15) | def run_cmd(cmd):
function kill_process_on_port (line 26) | def kill_process_on_port(port):
function train_val_dataset (line 35) | def train_val_dataset(cfg):
function get_config (line 44) | def get_config(path):
FILE: contrib/recipes/search_r1/qa_em.py
function normalize_answer (line 23) | def normalize_answer(s: str) -> str:
function em_check (line 42) | def em_check(prediction: str, golden_answers: Union[str, Sequence[str]])...
function subem_check (line 55) | def subem_check(prediction: str, golden_answers: Union[str, Sequence[str...
function extract_solution (line 68) | def extract_solution(solution_str: str) -> Optional[str]:
function compute_score_em (line 85) | def compute_score_em(
function compute_score_subem (line 111) | def compute_score_subem(
FILE: contrib/recipes/search_r1/retrieval_server.py
function load_corpus (line 37) | def load_corpus(corpus_path: str) -> Any:
function read_jsonl (line 42) | def read_jsonl(file_path: str) -> List[Dict[str, Any]]:
function load_docs (line 50) | def load_docs(corpus: Any, doc_idxs: Sequence[int]) -> Docs:
function load_model (line 55) | def load_model(model_path: str, use_fp16: bool = False) -> Tuple[torch.n...
function pooling (line 67) | def pooling(
class Encoder (line 85) | class Encoder:
method __init__ (line 86) | def __init__(
method encode (line 104) | def encode(self, query_list: Union[List[str], str], is_query: bool = T...
class Config (line 153) | class Config:
method __init__ (line 159) | def __init__(
class BaseRetriever (line 188) | class BaseRetriever:
method __init__ (line 189) | def __init__(self, config: Config) -> None:
method _search (line 197) | def _search(self, query: str, num: Optional[int], return_score: bool) ...
method _batch_search (line 200) | def _batch_search(
method search (line 205) | def search(
method batch_search (line 210) | def batch_search(
class BM25Retriever (line 216) | class BM25Retriever(BaseRetriever):
method __init__ (line 217) | def __init__(self, config: Config) -> None:
method _check_contain_doc (line 231) | def _check_contain_doc(self) -> bool:
method _search (line 239) | def _search(
method _batch_search (line 273) | def _batch_search(
class DenseRetriever (line 288) | class DenseRetriever(BaseRetriever):
method __init__ (line 289) | def __init__(self, config: Config) -> None:
method _search (line 311) | def _search(
method _batch_search (line 325) | def _batch_search(
function get_retriever (line 359) | def get_retriever(config: Config) -> BaseRetriever:
class QueryRequest (line 371) | class QueryRequest(BaseModel):
function retrieve_endpoint (line 385) | def retrieve_endpoint(request: QueryRequest) -> Dict[str, Any]:
FILE: contrib/recipes/search_r1/search_r1_agent.py
class Document (line 24) | class Document(TypedDict):
class RetrievalItem (line 28) | class RetrievalItem(TypedDict):
function eval (line 32) | def eval(prediction: str, ground_truth: List[str]) -> float:
function postprocess_response (line 38) | def postprocess_response(response: str) -> str:
function extract_action (line 47) | def extract_action(response: str) -> Tuple[Optional[str], str]:
function execute_response (line 60) | def execute_response(response: str, do_search: bool = True) -> str:
function retrieve_doc (line 77) | def retrieve_doc(query: str) -> str:
function passages2string (line 87) | def passages2string(retrieval_result: List[RetrievalItem]) -> str:
function call_llm (line 97) | def call_llm(
class SearchR1Agent (line 113) | class SearchR1Agent(LitAgent[Dict[str, Any]]):
method __init__ (line 115) | def __init__(
method rollout (line 125) | def rollout(
function debug_search_r1_agent (line 196) | def debug_search_r1_agent():
FILE: contrib/recipes/search_r1/train_search_r1_agent.py
function config_train_fast (line 87) | def config_train_fast() -> Dict[str, Any]:
function config_train_qwen (line 117) | def config_train_qwen() -> Dict[str, Any]:
function config_train_llama (line 124) | def config_train_llama() -> Dict[str, Any]:
function train (line 137) | def train(config: Dict[str, Any]) -> None:
function main (line 148) | def main() -> None:
FILE: contrib/recipes/webshop/agl/config.py
function _write_github_output (line 88) | def _write_github_output(project_name: str, experiment_name: str) -> None:
function _create_config (line 101) | def _create_config(
function config_fast (line 135) | def config_fast() -> Dict[str, Any]:
function config_qwen (line 154) | def config_qwen() -> Dict[str, Any]:
function config_qwen_1_5b (line 163) | def config_qwen_1_5b() -> Dict[str, Any]:
function config_qwen_7b (line 176) | def config_qwen_7b() -> Dict[str, Any]:
FILE: contrib/recipes/webshop/agl/generate_tasks.py
function load_human_instructions (line 46) | def load_human_instructions(filepath: Path) -> dict[str, list[dict[str, ...
function convert_to_training_task (line 62) | def convert_to_training_task(
function generate_tasks (line 92) | def generate_tasks(
function main (line 138) | def main() -> int:
FILE: contrib/recipes/webshop/agl/run_training.py
function find_human_instructions_path (line 68) | def find_human_instructions_path() -> Path | None:
function auto_generate_tasks (line 80) | def auto_generate_tasks(
class ExternalRunnerAgent (line 106) | class ExternalRunnerAgent(LitAgent[Dict[str, Any]]):
method rollout (line 118) | def rollout(self, task: Dict[str, Any], resources: NamedResources, rol...
function train (line 139) | def train(
function main (line 198) | def main() -> None:
FILE: contrib/recipes/webshop/agl/tasks.py
function load_sample_tasks (line 32) | def load_sample_tasks(path: Optional[Path] = None) -> List[Dict[str, Any]]:
function load_tasks_from_file (line 46) | def load_tasks_from_file(path: Path) -> List[Dict[str, Any]]:
FILE: contrib/recipes/webshop/scripts/headless-runner.ts
type RunnerOptions (line 39) | interface RunnerOptions {
type WebShopTask (line 46) | interface WebShopTask {
function parseAction (line 56) | function parseAction(text: string): string | null {
type ValidationResult (line 75) | interface ValidationResult {
function validateAction (line 84) | function validateAction(action: string): ValidationResult {
function runRollout (line 113) | async function runRollout(
function runLoop (line 324) | async function runLoop(options: RunnerOptions): Promise<void> {
function parseArgs (line 408) | function parseArgs(): RunnerOptions {
FILE: contrib/recipes/webshop/server/webshop_server.py
class Session (line 43) | class Session:
class SessionManager (line 53) | class SessionManager:
method __init__ (line 56) | def __init__(self, num_products: int = DEFAULT_NUM_PRODUCTS):
method _ensure_gym_registered (line 62) | def _ensure_gym_registered(self):
method _cleanup_expired (line 80) | def _cleanup_expired(self):
method create_session (line 88) | def create_session(self, session_id: Optional[str] = None, instruction...
method get_session (line 116) | def get_session(self, session_id: str) -> Optional[Session]:
method reset_session (line 124) | def reset_session(self, session_id: str, instruction: Optional[str] = ...
function get_session_manager (line 149) | def get_session_manager() -> SessionManager:
function reset (line 159) | def reset():
function step (line 212) | def step():
function health (line 268) | def health():
function index (line 274) | def index():
function main (line 289) | def main():
FILE: contrib/recipes/webshop/src/agent/prompts.ts
constant WEBSHOP_SYSTEM_PROMPT (line 13) | const WEBSHOP_SYSTEM_PROMPT = `You are a shopping assistant agent naviga...
FILE: contrib/recipes/webshop/src/agent/webshop-agent.ts
type WebShopAgentOptions (line 24) | interface WebShopAgentOptions {
function createWebShopAgent (line 48) | function createWebShopAgent(
type WebShopAgentUIMessage (line 75) | type WebShopAgentUIMessage = InferAgentUIMessage<
type WebShopUIToolInvocation (line 82) | type WebShopUIToolInvocation = NonNullable<
FILE: contrib/recipes/webshop/src/data/sample-tasks.ts
constant SAMPLE_TASKS (line 15) | const SAMPLE_TASKS: WebShopTask[] = [
function getRandomTasks (line 99) | function getRandomTasks(count: number): WebShopTask[] {
function getTaskById (line 107) | function getTaskById(taskId: string): WebShopTask | undefined {
FILE: contrib/recipes/webshop/src/environment/types.ts
type ProductAttributes (line 12) | interface ProductAttributes {
type WebShopTask (line 24) | interface WebShopTask {
type WebShopState (line 41) | interface WebShopState {
type ActionResult (line 54) | interface ActionResult {
type WebShopEnvironment (line 66) | interface WebShopEnvironment {
type SearchResultItem (line 98) | interface SearchResultItem {
type Product (line 109) | interface Product {
type SelectedOptions (line 123) | interface SelectedOptions {
FILE: contrib/recipes/webshop/src/environment/webshop-server.ts
type JsonRecord (line 19) | type JsonRecord = Record<string, unknown>;
type WebShopServerEnvOptions (line 21) | interface WebShopServerEnvOptions {
class WebShopServerEnv (line 31) | class WebShopServerEnv implements WebShopEnvironment {
method constructor (line 43) | constructor(options: WebShopServerEnvOptions) {
method getState (line 49) | getState(): WebShopState {
method reset (line 53) | async reset(options?: { task?: WebShopTask }): Promise<ActionResult> {
method step (line 94) | async step(action: string): Promise<ActionResult> {
method search (line 130) | async search(query: string): Promise<ActionResult> {
method click (line 134) | async click(element: string): Promise<ActionResult> {
method buy (line 138) | async buy(): Promise<ActionResult> {
method postJsonWithFallback (line 147) | private async postJsonWithFallback(
method pickString (line 208) | private pickString(obj: unknown, keys: string[]): string | undefined {
method pickBool (line 218) | private pickBool(obj: unknown, keys: string[]): boolean | undefined {
method pickNumber (line 228) | private pickNumber(obj: unknown, keys: string[]): number | undefined {
FILE: contrib/recipes/webshop/src/utils/agentlightning/otel.ts
type TracerConfig (line 29) | interface TracerConfig {
class RolloutSpanProcessor (line 40) | class RolloutSpanProcessor implements SpanProcessor {
method constructor (line 43) | constructor(
method onStart (line 49) | onStart(span: SdkSpan, parentContext: Context): void {
method onEnd (line 57) | onEnd(span: ReadableSpan): void {
method shutdown (line 61) | shutdown(): Promise<void> {
method forceFlush (line 65) | forceFlush(): Promise<void> {
function createRolloutTracer (line 74) | function createRolloutTracer(config: TracerConfig): {
function getOtlpEndpoint (line 116) | function getOtlpEndpoint(): string | null {
function emitReward (line 133) | function emitReward(tracer: Tracer, reward: number): void {
FILE: contrib/recipes/webshop/src/utils/agentlightning/proxy-llm.ts
function getProxyLLMBaseUrl (line 26) | function getProxyLLMBaseUrl(
function getMainLLM (line 63) | function getMainLLM(
function isProxyLLM (line 82) | function isProxyLLM(
FILE: contrib/recipes/webshop/src/utils/agentlightning/store-client.ts
constant API_V1_AGL_PREFIX (line 22) | const API_V1_AGL_PREFIX = '/v1/agl';
type StoreClientOptions (line 24) | interface StoreClientOptions {
class AgentLightningStoreClient (line 29) | class AgentLightningStoreClient {
method constructor (line 33) | constructor(options: StoreClientOptions) {
method isConfigured (line 38) | get isConfigured(): boolean {
method apiBase (line 42) | private get apiBase(): string {
method health (line 49) | async health(): Promise<boolean> {
method startRollout (line 62) | async startRollout(request: StartRolloutRequest): Promise<AttemptedRol...
method enqueueRollouts (line 70) | async enqueueRollouts(
method dequeueRollouts (line 84) | async dequeueRollouts(
method getRollout (line 97) | async getRollout(rolloutId: string): Promise<Rollout | AttemptedRollou...
method updateRollout (line 112) | async updateRollout(
method startAttempt (line 129) | async startAttempt(
method updateAttempt (line 144) | async updateAttempt(
method getAttempts (line 159) | async getAttempts(rolloutId: string): Promise<PaginatedResult<Attempt>> {
method getLatestAttempt (line 169) | async getLatestAttempt(rolloutId: string): Promise<Attempt | null> {
method completeAttempt (line 183) | async completeAttempt(
method updateWorker (line 207) | async updateWorker(
method getLatestResources (line 224) | async getLatestResources(): Promise<ResourcesUpdate | null> {
method getResourcesById (line 236) | async getResourcesById(resourcesId: string): Promise<ResourcesUpdate |...
method post (line 252) | private async post(path: string, body?: unknown): Promise<unknown> {
method get (line 280) | private async get(path: string): Promise<unknown> {
function getStoreClient (line 311) | function getStoreClient(): AgentLightningStoreClient | null {
FILE: contrib/recipes/webshop/src/utils/agentlightning/types.ts
type RolloutMode (line 13) | type RolloutMode = 'train' | 'val' | 'test';
type RolloutStatus (line 18) | type RolloutStatus =
type AttemptStatus (line 30) | type AttemptStatus =
type TaskInput (line 41) | type TaskInput = Record<string, unknown>;
type RolloutConfig (line 46) | interface RolloutConfig {
type Attempt (line 56) | interface Attempt {
type Rollout (line 71) | interface Rollout {
type AttemptedRollout (line 86) | interface AttemptedRollout extends Rollout {
type StartRolloutRequest (line 93) | interface StartRolloutRequest {
type EnqueueRolloutRequest (line 105) | interface EnqueueRolloutRequest {
type UpdateAttemptRequest (line 116) | interface UpdateAttemptRequest {
type DequeueRolloutsRequest (line 126) | interface DequeueRolloutsRequest {
type WorkerStatus (line 134) | type WorkerStatus = 'idle' | 'busy' | 'unknown';
type Worker (line 139) | interface Worker {
type PaginatedResult (line 154) | interface PaginatedResult<T> {
type WebShopTaskInput (line 164) | interface WebShopTaskInput {
type LLMResource (line 177) | interface LLMResource {
type ProxyLLMResource (line 190) | interface ProxyLLMResource {
type PromptTemplateResource (line 201) | interface PromptTemplateResource {
type ResourceUnion (line 210) | type ResourceUnion = LLMResource | ProxyLLMResource | PromptTemplateReso...
type NamedResources (line 215) | type NamedResources = Record<string, ResourceUnion>;
type ResourcesUpdate (line 220) | interface ResourcesUpdate {
FILE: contrib/recipes/webshop/tests/conftest.py
function adapter (line 22) | def adapter() -> TracerTraceToTriplet:
function make_span (line 28) | def make_span():
function make_vercel_ai_span (line 57) | def make_vercel_ai_span(make_span):
function make_reward_span (line 100) | def make_reward_span(make_span):
function make_session_span (line 125) | def make_session_span(make_span):
FILE: contrib/recipes/webshop/tests/test_span_adapter.py
class TestVercelAiSdkSpanMatching (line 25) | class TestVercelAiSdkSpanMatching:
method test_adapter_matches_vercel_ai_sdk_span_names (line 38) | def test_adapter_matches_vercel_ai_sdk_span_names(
method test_adapter_does_not_match_non_ai_spans (line 53) | def test_adapter_does_not_match_non_ai_spans(self, adapter: TracerTrac...
class TestTokenIdExtraction (line 65) | class TestTokenIdExtraction:
method test_extracts_token_ids_when_present (line 68) | def test_extracts_token_ids_when_present(self, adapter: TracerTraceToT...
method test_empty_token_ids_when_not_present (line 85) | def test_empty_token_ids_when_not_present(self, adapter: TracerTraceTo...
method test_raw_content_preserved_even_without_token_ids (line 104) | def test_raw_content_preserved_even_without_token_ids(self, adapter: T...
class TestRewardExtraction (line 124) | class TestRewardExtraction:
method test_extracts_reward_from_agentops_format (line 127) | def test_extracts_reward_from_agentops_format(
method test_reward_span_parsed_correctly (line 158) | def test_reward_span_parsed_correctly(self, make_reward_span):
class TestMultiTurnConversations (line 168) | class TestMultiTurnConversations:
method test_multiple_llm_calls_create_multiple_triplets (line 171) | def test_multiple_llm_calls_create_multiple_triplets(
class TestEdgeCases (line 200) | class TestEdgeCases:
method test_empty_span_list_raises_error (line 203) | def test_empty_span_list_raises_error(self, adapter: TracerTraceToTrip...
method test_only_non_llm_spans (line 211) | def test_only_non_llm_spans(self, adapter: TracerTraceToTriplet, make_...
method test_span_with_string_token_ids (line 222) | def test_span_with_string_token_ids(self, adapter: TracerTraceToTriple...
FILE: contrib/recipes/webshop/tests/test_store_integration.py
function store (line 26) | def store():
function integration_adapter (line 32) | def integration_adapter():
function test_full_flow_rollout_to_triplet (line 38) | async def test_full_flow_rollout_to_triplet(store, integration_adapter):
function test_span_ingestion_requires_valid_attempt (line 123) | async def test_span_ingestion_requires_valid_attempt(store):
function test_query_spans_by_explicit_attempt_id (line 171) | async def test_query_spans_by_explicit_attempt_id(store):
function test_empty_spans_query_returns_empty_list (line 206) | async def test_empty_spans_query_returns_empty_list(store):
function test_adapter_produces_empty_triplets_without_token_ids (line 219) | async def test_adapter_produces_empty_triplets_without_token_ids(store, ...
FILE: contrib/recipes/webshop/tsup.config.ts
method esbuildOptions (line 11) | esbuildOptions(options) {
FILE: dashboard/.storybook/constants.ts
constant STORY_DATE_NOW_MS (line 5) | const STORY_DATE_NOW_MS = 1762775145209;
constant STORY_DATE_NOW_SECONDS (line 6) | const STORY_DATE_NOW_SECONDS = Math.floor(STORY_DATE_NOW_MS / 1000);
constant STORY_BASE_URL (line 11) | const STORY_BASE_URL = 'https://storybook.agentlightning.invalid';
constant STORY_LOCATION_HREF (line 12) | const STORY_LOCATION_HREF = `${STORY_BASE_URL}/storybook`;
FILE: dashboard/.storybook/preview.tsx
type ColorSchemeValue (line 14) | type ColorSchemeValue = 'light' | 'dark';
FILE: dashboard/src/App.tsx
function App (line 16) | function App() {
FILE: dashboard/src/Router.tsx
function Router (line 44) | function Router() {
FILE: dashboard/src/components/AppAlertBanner.story.tsx
type Story (line 23) | type Story = StoryObj<typeof AppAlertBanner>;
function renderWithAlert (line 25) | function renderWithAlert(message: string, tone: AlertTone) {
FILE: dashboard/src/components/AppAlertBanner.tsx
constant ALERT_META (line 9) | const ALERT_META = {
function AppAlertBanner (line 24) | function AppAlertBanner() {
FILE: dashboard/src/components/AppDrawer.component.tsx
constant ATTEMPT_STATUS_COLORS (line 28) | const ATTEMPT_STATUS_COLORS: Record<AttemptStatus, string> = {
constant ROLLOUT_STATUS_COLORS (line 37) | const ROLLOUT_STATUS_COLORS: Record<RolloutStatus, string> = {
constant SPAN_STATUS_COLORS (line 47) | const SPAN_STATUS_COLORS: Record<Span['status']['status_code'], string> = {
constant WORKER_STATUS_COLORS (line 53) | const WORKER_STATUS_COLORS: Record<Worker['status'], string> = {
constant TRACES_SORT_FIELD_MAP (line 59) | const TRACES_SORT_FIELD_MAP: Record<string, string> = {
type SortDirection (line 69) | type SortDirection = 'asc' | 'desc';
type LocalSortState (line 71) | type LocalSortState = {
function resolveTracesSortField (line 76) | function resolveTracesSortField(column: string): string {
function getStatusBadgeColor (line 80) | function getStatusBadgeColor(status: RolloutStatus | AttemptStatus, isAt...
function formatJson (line 88) | function formatJson(value: unknown) {
type AppDrawerProps (line 96) | type AppDrawerProps = {
function AppDrawer (line 103) | function AppDrawer({ opened, onClose, title, body }: AppDrawerProps) {
type TraceDrawerTitleProps (line 136) | type TraceDrawerTitleProps = {
function TraceDrawerTitle (line 140) | function TraceDrawerTitle({ span }: TraceDrawerTitleProps) {
type RolloutAttemptDrawerTitleProps (line 199) | type RolloutAttemptDrawerTitleProps = {
function RolloutAttemptDrawerTitle (line 204) | function RolloutAttemptDrawerTitle({ rollout, attempt }: RolloutAttemptD...
type JsonEditorProps (line 271) | type JsonEditorProps = {
function JsonEditor (line 275) | function JsonEditor({ value }: JsonEditorProps) {
type RolloutTracesDrawerBodyProps (line 299) | type RolloutTracesDrawerBodyProps = {
function RolloutTracesDrawerBody (line 306) | function RolloutTracesDrawerBody({ rollout, attempt, onShowRollout, onSh...
type WorkerDrawerTitleProps (line 417) | type WorkerDrawerTitleProps = {
function WorkerDrawerTitle (line 421) | function WorkerDrawerTitle({ worker }: WorkerDrawerTitleProps) {
function AppDrawerContainer (line 471) | function AppDrawerContainer() {
type DrawerLocationWatcherProps (line 566) | type DrawerLocationWatcherProps = {
function DrawerLocationWatcher (line 570) | function DrawerLocationWatcher({ onNavigation }: DrawerLocationWatcherPr...
FILE: dashboard/src/components/AppDrawer.story.tsx
type Story (line 26) | type Story = StoryObj<typeof AppDrawerContainer>;
function renderWithDrawer (line 116) | function renderWithDrawer(content: DrawerContent, options?: { spans?: Sp...
FILE: dashboard/src/components/ResourcesTable.component.tsx
constant DEFAULT_RECORDS_PER_PAGE_OPTIONS (line 14) | const DEFAULT_RECORDS_PER_PAGE_OPTIONS = [50, 100, 200, 500];
constant COLUMN_VISIBILITY (line 16) | const COLUMN_VISIBILITY: Record<string, ColumnVisibilityConfig> = {
type ResourcesTableRecord (line 25) | type ResourcesTableRecord = Resources & {
function buildResourcesRecord (line 31) | function buildResourcesRecord(resources: Resources): ResourcesTableRecord {
type ResourcesColumnsOptions (line 48) | type ResourcesColumnsOptions = Record<string, never>;
function createResourcesColumns (line 50) | function createResourcesColumns(_options: ResourcesColumnsOptions): Data...
type RowExpansionRenderer (line 122) | type RowExpansionRenderer = (context: {
type ResourcesTableProps (line 127) | type ResourcesTableProps = {
function ResourcesTable (line 146) | function ResourcesTable({
FILE: dashboard/src/components/ResourcesTable.story.tsx
type Story (line 21) | type Story = StoryObj<typeof ResourcesTable>;
type WrapperProps (line 140) | type WrapperProps = {
function ResourcesTableStoryWrapper (line 148) | function ResourcesTableStoryWrapper({
FILE: dashboard/src/components/ResourcesTree.component.tsx
function convertToTreeData (line 9) | function convertToTreeData(obj: any, key: string = 'root', parentPath = ...
type ResourcesTreeProps (line 72) | type ResourcesTreeProps = {
function ResourcesTree (line 76) | function ResourcesTree({ resources }: ResourcesTreeProps) {
FILE: dashboard/src/components/ResourcesTree.story.tsx
type Story (line 18) | type Story = StoryObj<typeof ResourcesTree>;
type WrapperProps (line 155) | type WrapperProps = {
function ResourcesTreeStoryWrapper (line 160) | function ResourcesTreeStoryWrapper({ resources, maxWidth = 800 }: Wrappe...
FILE: dashboard/src/components/RolloutTable.component.tsx
constant ROLLOUT_STATUS_OPTIONS (line 48) | const ROLLOUT_STATUS_OPTIONS: RolloutStatus[] = [
constant ATTEMPT_STATUS_COLORS (line 58) | const ATTEMPT_STATUS_COLORS: Record<AttemptStatus, string> = {
constant ROLLOUT_STATUS_COLORS (line 67) | const ROLLOUT_STATUS_COLORS: Record<RolloutStatus, string> = {
constant ROLLOUT_MODE_OPTIONS (line 77) | const ROLLOUT_MODE_OPTIONS: RolloutMode[] = ['train', 'val', 'test'];
constant DEFAULT_RECORDS_PER_PAGE_OPTIONS (line 79) | const DEFAULT_RECORDS_PER_PAGE_OPTIONS = [50, 100, 200, 500];
constant COLUMN_VISIBILITY (line 81) | const COLUMN_VISIBILITY: Record<string, ColumnVisibilityConfig> = {
type RolloutTableRecord (line 95) | type RolloutTableRecord = Rollout & {
function selectHeartbeatTimestamp (line 110) | function selectHeartbeatTimestamp(attempt?: Attempt | null): number | nu...
function buildRolloutRecord (line 118) | function buildRolloutRecord(rollout: Rollout): RolloutTableRecord {
function buildAttemptRecord (line 152) | function buildAttemptRecord(rollout: Rollout, attempt: Attempt): Rollout...
function getStatusBadge (line 182) | function getStatusBadge(status: string, kind: 'rollout' | 'attempt') {
type RolloutColumnsOptions (line 195) | type RolloutColumnsOptions = {
function createRolloutColumns (line 206) | function createRolloutColumns({
type RowExpansionRenderer (line 484) | type RowExpansionRenderer = (context: {
type RolloutTableProps (line 489) | type RolloutTableProps = {
function RolloutTable (line 516) | function RolloutTable({
type RolloutAttemptsTableProps (line 721) | type RolloutAttemptsTableProps = {
function RolloutAttemptsTable (line 730) | function RolloutAttemptsTable({
FILE: dashboard/src/components/RolloutTable.story.tsx
type Story (line 23) | type Story = StoryObj<typeof RolloutTable>;
type WrapperProps (line 152) | type WrapperProps = {
function RolloutTableStoryWrapper (line 160) | function RolloutTableStoryWrapper({
FILE: dashboard/src/components/TracesTable.component.tsx
constant DEFAULT_RECORDS_PER_PAGE_OPTIONS (line 21) | const DEFAULT_RECORDS_PER_PAGE_OPTIONS = [50, 100, 200, 500];
constant COLUMN_VISIBILITY (line 23) | const COLUMN_VISIBILITY: Record<string, ColumnVisibilityConfig> = {
constant STATUS_COLORS (line 37) | const STATUS_COLORS: Record<string, string> = {
type TracesTableRecord (line 43) | type TracesTableRecord = Span & {
function buildTraceRecord (line 50) | function buildTraceRecord(span: Span): TracesTableRecord {
type TracesColumnsOptions (line 66) | type TracesColumnsOptions = {
function createTracesColumns (line 73) | function createTracesColumns({
type TracesTableProps (line 276) | type TracesTableProps = {
function TracesTable (line 298) | function TracesTable({
FILE: dashboard/src/components/TracesTable.story.tsx
type Story (line 23) | type Story = StoryObj<typeof TracesTable>;
type WrapperProps (line 199) | type WrapperProps = {
function TracesTableStoryWrapper (line 207) | function TracesTableStoryWrapper({
FILE: dashboard/src/components/WorkersTable.component.tsx
constant DEFAULT_RECORDS_PER_PAGE_OPTIONS (line 14) | const DEFAULT_RECORDS_PER_PAGE_OPTIONS = [50, 100, 200, 500];
constant COLUMN_VISIBILITY (line 16) | const COLUMN_VISIBILITY: Record<string, ColumnVisibilityConfig> = {
type WorkersTableRecord (line 28) | type WorkersTableRecord = Worker & {
function buildWorkerRecord (line 40) | function buildWorkerRecord(worker: Worker): WorkersTableRecord {
type WorkersColumnsOptions (line 52) | type WorkersColumnsOptions = {
constant STATUS_COLORS (line 56) | const STATUS_COLORS: Record<Worker['status'], string> = {
function createWorkersColumns (line 62) | function createWorkersColumns({ onShowDetails }: WorkersColumnsOptions):...
type WorkersTableProps (line 202) | type WorkersTableProps = {
function WorkersTable (line 221) | function WorkersTable({
FILE: dashboard/src/components/WorkersTable.story.tsx
type Story (line 20) | type Story = StoryObj<typeof WorkersTable>;
type WorkersTableStoryWrapperProps (line 82) | type WorkersTableStoryWrapperProps = {
function WorkersTableStoryWrapper (line 87) | function WorkersTableStoryWrapper({ maxWidth, initialSort }: WorkersTabl...
FILE: dashboard/src/features/config/slice.ts
method setBaseUrl (line 16) | setBaseUrl(state, action: PayloadAction<string>) {
method setAutoRefreshMs (line 19) | setAutoRefreshMs(state, action: PayloadAction<number>) {
method setTheme (line 22) | setTheme(state, action: PayloadAction<ThemePreference>) {
FILE: dashboard/src/features/resources/selectors.ts
constant RESOURCES_SORT_FIELD_MAP (line 8) | const RESOURCES_SORT_FIELD_MAP: Record<string, string> = {
FILE: dashboard/src/features/resources/slice.ts
type SortDirection (line 5) | type SortDirection = 'asc' | 'desc';
type ResourcesSortState (line 7) | type ResourcesSortState = {
type ResourcesUiState (line 12) | type ResourcesUiState = {
method setResourcesSearchTerm (line 33) | setResourcesSearchTerm(state, action: PayloadAction<string>) {
method setResourcesPage (line 37) | setResourcesPage(state, action: PayloadAction<number>) {
method setResourcesRecordsPerPage (line 40) | setResourcesRecordsPerPage(state, action: PayloadAction<number>) {
method setResourcesSort (line 44) | setResourcesSort(state, action: PayloadAction<ResourcesSortState>) {
method resetResourcesFilters (line 47) | resetResourcesFilters(state) {
FILE: dashboard/src/features/rollouts/api.ts
type GetRolloutsQueryArgs (line 185) | type GetRolloutsQueryArgs = {
type GetResourcesQueryArgs (line 195) | type GetResourcesQueryArgs = {
type GetWorkersQueryArgs (line 203) | type GetWorkersQueryArgs = {
type GetRolloutAttemptsQueryArgs (line 212) | type GetRolloutAttemptsQueryArgs = {
type GetSpansQueryArgs (line 220) | type GetSpansQueryArgs = {
FILE: dashboard/src/features/rollouts/selectors.ts
constant ROLLOUTS_SORT_FIELD_MAP (line 8) | const ROLLOUTS_SORT_FIELD_MAP: Record<string, string> = {
FILE: dashboard/src/features/rollouts/slice.ts
type SortDirection (line 6) | type SortDirection = 'asc' | 'desc';
type RolloutsSortState (line 8) | type RolloutsSortState = {
type RolloutsUiState (line 13) | type RolloutsUiState = {
method setRolloutsSearchTerm (line 38) | setRolloutsSearchTerm(state, action: PayloadAction<string>) {
method setRolloutsStatusFilters (line 42) | setRolloutsStatusFilters(state, action: PayloadAction<RolloutStatus[]>) {
method setRolloutsModeFilters (line 46) | setRolloutsModeFilters(state, action: PayloadAction<RolloutMode[]>) {
method setRolloutsPage (line 50) | setRolloutsPage(state, action: PayloadAction<number>) {
method setRolloutsRecordsPerPage (line 53) | setRolloutsRecordsPerPage(state, action: PayloadAction<number>) {
method setRolloutsSort (line 57) | setRolloutsSort(state, action: PayloadAction<RolloutsSortState>) {
method resetRolloutsFilters (line 60) | resetRolloutsFilters(state) {
FILE: dashboard/src/features/traces/selectors.ts
constant TRACES_SORT_FIELD_MAP (line 24) | const TRACES_SORT_FIELD_MAP: Record<string, string> = {
FILE: dashboard/src/features/traces/slice.ts
type SortDirection (line 5) | type SortDirection = 'asc' | 'desc';
type TracesSortState (line 7) | type TracesSortState = {
type TracesViewMode (line 12) | type TracesViewMode = 'table' | 'waterfall' | 'tree';
type TracesUiState (line 14) | type TracesUiState = {
method setTracesRolloutId (line 41) | setTracesRolloutId(state, action: PayloadAction<string | null>) {
method setTracesAttemptId (line 46) | setTracesAttemptId(state, action: PayloadAction<string | null>) {
method setTracesSearchTerm (line 50) | setTracesSearchTerm(state, action: PayloadAction<string>) {
method setTracesPage (line 54) | setTracesPage(state, action: PayloadAction<number>) {
method setTracesRecordsPerPage (line 57) | setTracesRecordsPerPage(state, action: PayloadAction<number>) {
method setTracesSort (line 61) | setTracesSort(state, action: PayloadAction<TracesSortState>) {
method setTracesViewMode (line 64) | setTracesViewMode(state, action: PayloadAction<TracesViewMode>) {
method resetTracesFilters (line 67) | resetTracesFilters(state) {
method hydrateTracesStateFromQuery (line 72) | hydrateTracesStateFromQuery(
FILE: dashboard/src/features/ui/alert/selectors.ts
constant ALERT_PRIORITY (line 7) | const ALERT_PRIORITY: Record<AlertTone, number> = {
FILE: dashboard/src/features/ui/alert/slice.ts
type AlertTone (line 5) | type AlertTone = 'info' | 'warning' | 'error';
type AppAlert (line 7) | type AppAlert = {
type AlertsState (line 15) | type AlertsState = {
type ShowAlertPayload (line 23) | type ShowAlertPayload = {
type HideAlertPayload (line 29) | type HideAlertPayload = {
method showAlert (line 37) | showAlert(state, action: PayloadAction<ShowAlertPayload>) {
method hideAlert (line 56) | hideAlert(state, action: PayloadAction<HideAlertPayload>) {
method dismissAlert (line 59) | dismissAlert(state, action: PayloadAction<HideAlertPayload>) {
method clearAlerts (line 65) | clearAlerts(state) {
FILE: dashboard/src/features/ui/drawer/slice.ts
type DrawerType (line 6) | type DrawerType = 'rollout-json' | 'rollout-traces' | 'trace-detail' | '...
type DrawerContent (line 8) | type DrawerContent =
type DrawerState (line 26) | type DrawerState = {
method openDrawer (line 40) | openDrawer(state, action: PayloadAction<DrawerContent>) {
method closeDrawer (line 44) | closeDrawer(state) {
FILE: dashboard/src/features/workers/selectors.ts
constant WORKERS_SORT_FIELD_MAP (line 8) | const WORKERS_SORT_FIELD_MAP: Record<string, string> = {
FILE: dashboard/src/features/workers/slice.ts
type SortDirection (line 5) | type SortDirection = 'asc' | 'desc';
type WorkersSortState (line 7) | type WorkersSortState = {
type WorkersUiState (line 12) | type WorkersUiState = {
method setWorkersSearchTerm (line 33) | setWorkersSearchTerm(state, action: PayloadAction<string>) {
method setWorkersPage (line 37) | setWorkersPage(state, action: PayloadAction<number>) {
method setWorkersRecordsPerPage (line 40) | setWorkersRecordsPerPage(state, action: PayloadAction<number>) {
method setWorkersSort (line 44) | setWorkersSort(state, action: PayloadAction<WorkersSortState>) {
method resetWorkersFilters (line 47) | resetWorkersFilters(state) {
FILE: dashboard/src/layouts/AppLayout.story.tsx
constant ROUTES (line 25) | const ROUTES = [
function createAlertState (line 56) | function createAlertState(message: string, tone: AlertTone): AlertsState {
function renderAppLayout (line 70) | function renderAppLayout(args: AppLayoutProps, initialEntry = '/rollouts...
type Story (line 110) | type Story = StoryObj<AppLayoutProps>;
FILE: dashboard/src/layouts/AppLayout.tsx
type ConnectionStatus (line 13) | type ConnectionStatus = 'online' | 'offline' | 'unknown';
type NavItem (line 15) | type NavItem = {
constant NAV_ITEMS (line 21) | const NAV_ITEMS: NavItem[] = [
constant CONNECTION_STATUS_META (line 29) | const CONNECTION_STATUS_META: Record<ConnectionStatus, { color: string; ...
constant DEFAULT_AUTO_REFRESH_MS (line 35) | const DEFAULT_AUTO_REFRESH_MS = 30_000;
type ConnectionOptions (line 37) | type ConnectionOptions = {
function getSameOriginUrl (line 42) | function getSameOriginUrl() {
function buildHealthUrl (line 46) | function buildHealthUrl(baseUrl: string) {
function useServerConnection (line 57) | function useServerConnection({ baseUrl, autoRefreshMs }: ConnectionOptio...
function ConnectionIndicator (line 120) | function ConnectionIndicator({
type AppLayoutProps (line 171) | type AppLayoutProps = {
function AppLayout (line 175) | function AppLayout({ config }: AppLayoutProps = {}) {
function AppLayoutWithState (line 236) | function AppLayoutWithState() {
FILE: dashboard/src/layouts/helper.ts
function parseCssNumber (line 3) | function parseCssNumber(value: string | null | undefined): number {
function getElementWidth (line 12) | function getElementWidth(selectors: string | string[]): number {
function getAppShellContentWidth (line 28) | function getAppShellContentWidth(): number {
function getAppShellOffsets (line 37) | function getAppShellOffsets(): number {
function getLayoutAwareWidth (line 74) | function getLayoutAwareWidth(containerWidth: number, viewportWidth: numb...
FILE: dashboard/src/pages/Resources.page.story.tsx
type Story (line 35) | type Story = StoryObj<typeof ResourcesPage>;
function createStoryStore (line 156) | function createStoryStore(configOverrides?: Partial<typeof initialConfig...
function renderWithStore (line 169) | function renderWithStore(configOverrides?: Partial<typeof initialConfigS...
function renderWithAppLayout (line 183) | function renderWithAppLayout(configOverrides?: Partial<typeof initialCon...
FILE: dashboard/src/pages/Resources.page.tsx
function ResourcesPage (line 28) | function ResourcesPage() {
FILE: dashboard/src/pages/Rollouts.page.story.tsx
type Story (line 35) | type Story = StoryObj<typeof RolloutsPage>;
function createStoryStore (line 660) | function createStoryStore(
function renderWithStore (line 679) | function renderWithStore(uiOverrides?: Partial<RolloutsUiState>, configO...
function renderWithAppLayout (line 693) | function renderWithAppLayout(
function openSampleTracesDrawer (line 936) | async function openSampleTracesDrawer(canvasElement: HTMLElement) {
function openRawJsonDrawer (line 954) | async function openRawJsonDrawer(canvasElement: HTMLElement, rolloutId =...
FILE: dashboard/src/pages/Rollouts.page.tsx
function RolloutAttemptsContent (line 34) | function RolloutAttemptsContent({
function toRolloutFromRecord (line 60) | function toRolloutFromRecord(record: RolloutTableRecord): Rollout {
function RolloutsPage (line 77) | function RolloutsPage() {
FILE: dashboard/src/pages/Settings.page.story.tsx
type Story (line 21) | type Story = StoryObj<typeof SettingsPage>;
function renderWithConfig (line 23) | function renderWithConfig(partial?: Partial<ConfigState>) {
FILE: dashboard/src/pages/Settings.page.tsx
constant AUTO_REFRESH_OPTIONS (line 9) | const AUTO_REFRESH_OPTIONS = [
constant THEME_OPTIONS (line 18) | const THEME_OPTIONS = [
function SettingsPage (line 24) | function SettingsPage() {
FILE: dashboard/src/pages/Traces.page.story.tsx
type Story (line 36) | type Story = StoryObj<typeof TracesPage>;
function createSyntheticRollouts (line 258) | function createSyntheticRollouts(prefix: string, count: number) {
function createHandlers (line 338) | function createHandlers(delayMs?: number) {
function createRequestTimeoutHandlers (line 342) | function createRequestTimeoutHandlers() {
function createStoryStore (line 364) | function createStoryStore(
function renderTracesPage (line 380) | function renderTracesPage(
function renderTracesPageWithAppLayout (line 397) | function renderTracesPageWithAppLayout(
FILE: dashboard/src/pages/Traces.page.tsx
constant VIEW_OPTIONS (line 44) | const VIEW_OPTIONS = [
type ViewOptionValue (line 50) | type ViewOptionValue = (typeof VIEW_OPTIONS)[number]['value'];
function getLatestAttempt (line 52) | function getLatestAttempt(attempts: Attempt[]): Attempt | null {
function mergeRolloutCache (line 59) | function mergeRolloutCache(cache: Record<string, Rollout>, items: Rollou...
function TracesPage (line 75) | function TracesPage() {
FILE: dashboard/src/pages/Workers.page.story.tsx
type Story (line 33) | type Story = StoryObj<typeof WorkersPage>;
function createStoryStore (line 119) | function createStoryStore(configOverrides?: Partial<typeof initialConfig...
function renderWithStore (line 131) | function renderWithStore(configOverrides?: Partial<typeof initialConfigS...
function renderWithinAppLayout (line 145) | function renderWithinAppLayout(configOverrides?: Partial<typeof initialC...
FILE: dashboard/src/pages/Workers.page.tsx
function WorkersPage (line 28) | function WorkersPage() {
FILE: dashboard/src/store/index.ts
type RootState (line 23) | type RootState = ReturnType<typeof rootReducer>;
type AppStore (line 34) | type AppStore = ReturnType<typeof createAppStore>;
type AppDispatch (line 35) | type AppDispatch = AppStore['dispatch'];
FILE: dashboard/src/theme.ts
constant CONTAINER_SIZES (line 35) | const CONTAINER_SIZES: Record<string, string> = {
constant FONT_FAMILY (line 45) | const FONT_FAMILY =
FILE: dashboard/src/types.ts
type RolloutStatus (line 5) | type RolloutStatus = 'queuing' | 'preparing' | 'running' | 'failed' | 's...
type AttemptStatus (line 7) | type AttemptStatus = 'preparing' | 'running' | 'failed' | 'succeeded' | ...
type RolloutMode (line 9) | type RolloutMode = 'train' | 'val' | 'test';
type TaskInput (line 11) | type TaskInput = any;
type Timestamp (line 13) | type Timestamp = number;
type Attempt (line 19) | type Attempt = {
type WorkerStatus (line 31) | type WorkerStatus = 'idle' | 'busy' | 'unknown';
type Worker (line 37) | type Worker = {
type Rollout (line 56) | type Rollout = {
type Resource (line 70) | type Resource = Record<string, any>;
type Resources (line 76) | type Resources = {
type PaginatedResponse (line 87) | type PaginatedResponse<T> = {
type Span (line 98) | type Span = {
type Config (line 120) | type Config = {
type ThemePreference (line 126) | type ThemePreference = 'light' | 'dark' | 'system';
type ConfigState (line 128) | type ConfigState = {
FILE: dashboard/src/utils/error.ts
function getErrorDescriptor (line 7) | function getErrorDescriptor(error: unknown): string | null {
FILE: dashboard/src/utils/format.ts
function toTimestamp (line 5) | function toTimestamp(value: unknown): number | null {
function clampToNow (line 12) | function clampToNow(start: number | null, end: number | null): number | ...
function formatDateTime (line 22) | function formatDateTime(timestamp: number | null): string {
function formatDateTimeWithMilliseconds (line 30) | function formatDateTimeWithMilliseconds(timestamp: number | null): string {
function formatDuration (line 38) | function formatDuration(seconds: number | null): string {
function formatRelativeTime (line 66) | function formatRelativeTime(timestamp: number | null): string {
function formatStatusLabel (line 81) | function formatStatusLabel(status: string): string {
function formatInputPreview (line 88) | function formatInputPreview(input: unknown, maxLength = 35): { preview: ...
function safeStringify (line 101) | function safeStringify(value: unknown): string {
FILE: dashboard/src/utils/mock.ts
function parseNumberParam (line 24) | function parseNumberParam(params: URLSearchParams, key: string, defaultV...
function filterRolloutsForParams (line 40) | function filterRolloutsForParams(rollouts: Rollout[], params: URLSearchP...
function getRolloutSortValue (line 67) | function getRolloutSortValue(rollout: Rollout, sortBy: string): string |...
function sortRolloutsForParams (line 85) | function sortRolloutsForParams(
function buildRolloutsResponse (line 120) | function buildRolloutsResponse(rollouts: Rollout[], request: Request): R...
function sortAttemptsForParams (line 145) | function sortAttemptsForParams(
function buildAttemptsResponse (line 168) | function buildAttemptsResponse(attempts: Attempt[], request: Request): R...
function filterSpansForParams (line 192) | function filterSpansForParams(spans: Span[], params: URLSearchParams): S...
function getSpanSortValue (line 219) | function getSpanSortValue(span: Span, sortBy: string): string | number |...
function sortSpansForParams (line 247) | function sortSpansForParams(spans: Span[], sortBy: string | null, sortOr...
function buildSpansResponse (line 276) | function buildSpansResponse(spansByAttempt: Record<string, Span[]>, requ...
function createRolloutsHandlers (line 319) | function createRolloutsHandlers(rollouts: Rollout[], attemptsByRollout: ...
function createSpansHandlers (line 341) | function createSpansHandlers(spansByAttempt: Record<string, Span[]>) {
function filterResourcesForParams (line 349) | function filterResourcesForParams(resources: Resources[], params: URLSea...
function getResourcesSortValue (line 363) | function getResourcesSortValue(resource: Resources, sortBy: string): str...
function sortResourcesForParams (line 381) | function sortResourcesForParams(
function buildResourcesResponse (line 416) | function buildResourcesResponse(resources: Resources[], request: Request...
function filterWorkersForParams (line 441) | function filterWorkersForParams(workers: Worker[], params: URLSearchPara...
function getWorkerSortValue (line 464) | function getWorkerSortValue(worker: Worker, sortBy: string): string | nu...
function sortWorkersForParams (line 490) | function sortWorkersForParams(workers: Worker[], sortBy: string | null, ...
function buildWorkersResponse (line 520) | function buildWorkersResponse(workers: Worker[], request: Request): Reco...
function createWorkersHandlers (line 544) | function createWorkersHandlers(workers: Worker[]) {
function createResourcesHandlers (line 559) | function createResourcesHandlers(resources: Resources[]) {
function createMockHandlers (line 586) | function createMockHandlers(
FILE: dashboard/src/utils/table.ts
type ColumnVisibilityConfig (line 8) | type ColumnVisibilityConfig =
function compareRecords (line 24) | function compareRecords<T, K extends keyof T>(a: T, b: T, key: K): number {
constant FALLBACK_EM_IN_PIXELS (line 51) | const FALLBACK_EM_IN_PIXELS = 16;
function getEmInPixels (line 53) | function getEmInPixels(): number {
function resolveWidth (line 67) | function resolveWidth(config: ColumnVisibilityConfig): { widthEm: number...
function createResponsiveColumns (line 74) | function createResponsiveColumns<T>(
FILE: dashboard/static/mockServiceWorker.js
constant PACKAGE_VERSION (line 12) | const PACKAGE_VERSION = '2.11.6';
constant INTEGRITY_CHECKSUM (line 13) | const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82';
constant IS_MOCKED_RESPONSE (line 14) | const IS_MOCKED_RESPONSE = Symbol('isMockedResponse');
function handleRequest (line 123) | async function handleRequest(event, requestId, requestInterceptedAt) {
function resolveMainClient (line 171) | async function resolveMainClient(event) {
function getResponse (line 205) | async function getResponse(event, client, requestId, requestInterceptedA...
function sendToClient (line 280) | function sendToClient(client, message, transferrables = []) {
function respondWithMock (line 300) | function respondWithMock(response) {
function serializeRequest (line 322) | async function serializeRequest(request) {
FILE: dashboard/test-utils/python-server.py
function inject_mock_data (line 40) | async def inject_mock_data(store: InMemoryLightningStore, now: float | N...
function main (line 684) | async def main():
FILE: dashboard/test-utils/render.tsx
function render (line 7) | function render(ui: React.ReactNode) {
FILE: dashboard/vitest.global-setup.mjs
function setup (line 207) | async function setup() {
FILE: dashboard/vitest.setup.mjs
class ResizeObserver (line 25) | class ResizeObserver {
method observe (line 26) | observe() {}
method unobserve (line 27) | unobserve() {}
method disconnect (line 28) | disconnect() {}
FILE: docs/javascripts/charts.js
function matVar (line 4) | function matVar(name) {
function toRGBA (line 7) | function toRGBA(color, a = 1) {
function applyThemeDefaults (line 23) | function applyThemeDefaults() {
function applyDatasetDefaults (line 56) | function applyDatasetDefaults(config) {
function deepMerge (line 71) | function deepMerge(target, src) {
function buildConfig (line 85) | function buildConfig(baseCfg) {
function renderAll (line 161) | function renderAll() {
function retheme (line 180) | function retheme() {
function boot (line 198) | function boot() {
FILE: docs/macros/source_links.py
function define_env (line 10) | def define_env(env: Any):
FILE: examples/apo/apo_custom_algorithm.py
function apo_algorithm (line 42) | async def apo_algorithm(*, store: agl.LightningStore):
function apo_rollout (line 103) | async def apo_rollout(task: str, prompt_template: agl.PromptTemplate) ->...
function log_llm_span (line 120) | async def log_llm_span(spans: Sequence[agl.Span]) -> None:
function llm_judge (line 127) | async def llm_judge(task: str, output: Optional[str]) -> float:
function apo_runner (line 154) | async def apo_runner(*, store: agl.LightningStore):
function main (line 164) | async def main():
FILE: examples/apo/apo_custom_algorithm_trainer.py
function apo_algorithm_usable_in_trainer (line 30) | async def apo_algorithm_usable_in_trainer(*, store: LightningStore):
FILE: examples/apo/apo_debug.py
function debug_with_runner (line 19) | async def debug_with_runner():
function debug_with_hooks (line 46) | async def debug_with_hooks():
function debug_with_trainer (line 82) | def debug_with_trainer():
FILE: examples/apo/legacy_apo_client.py
class SimpleAgent (line 20) | class SimpleAgent(LitAgent[Any]):
method training_rollout (line 22) | def training_rollout(self, task, rollout_id, resources): # type: ignore
FILE: examples/apo/legacy_apo_server.py
function example_apo (line 15) | async def example_apo():
FILE: examples/apo/room_selector.py
class JudgeResponse (line 30) | class JudgeResponse(BaseModel):
class Room (line 35) | class Room(TypedDict):
class RoomStatus (line 44) | class RoomStatus(Room):
class AvailableRooms (line 48) | class AvailableRooms(TypedDict):
class RoomRequirement (line 52) | class RoomRequirement(TypedDict):
class RoomSelectionTask (line 61) | class RoomSelectionTask(TypedDict):
function prompt_template_baseline (line 87) | def prompt_template_baseline() -> PromptTemplate:
function room_selection_grader (line 94) | def room_selection_grader(client: OpenAI, final_message: Optional[str], ...
function room_selector (line 123) | def room_selector(task: RoomSelectionTask, prompt_template: PromptTempla...
function overlaps (line 306) | def overlaps(start: str, dur: int, other_start: str, other_dur: int) -> ...
function get_rooms_and_availability (line 315) | def get_rooms_and_availability(date: str, time_str: str, duration_min: i...
function load_room_tasks (line 330) | def load_room_tasks() -> Dataset[RoomSelectionTask]:
function debug_room_selector (line 338) | async def debug_room_selector(limit: int = 1):
FILE: examples/apo/room_selector_apo.py
function load_train_val_dataset (line 17) | def load_train_val_dataset() -> Tuple[Dataset[RoomSelectionTask], Datase...
function setup_apo_logger (line 25) | def setup_apo_logger(file_path: str = "apo.log") -> None:
function main (line 35) | def main() -> None:
FILE: examples/azure/aoai_finetune.py
class AzureOpenAIFinetune (line 32) | class AzureOpenAIFinetune(Algorithm):
method __init__ (line 40) | def __init__(
method run (line 138) | async def run( # type: ignore
method batch_rollout_and_collect_data (line 196) | async def batch_rollout_and_collect_data(
method rollout_and_collect_data (line 231) | async def rollout_and_collect_data(self, task: TaskInput, mode: Rollou...
method prepare_data_for_training (line 294) | async def prepare_data_for_training(
method finetune (line 338) | def finetune(self, training_data: List[Dict[str, Any]], base_model: st...
method deploy_finetuned_model (line 414) | def deploy_finetuned_model(self, finetuned_model_id: str, iteration_id...
method cleanup_deployments (line 455) | def cleanup_deployments(self) -> None:
method _filter_training_data (line 462) | def _filter_training_data(self, data: List[Dict[str, Any]]) -> List[Di...
method _wait_for_file_processed (line 493) | def _wait_for_file_processed(self, file_id: str, interval: int = FILE_...
method _wait_for_finetuning (line 513) | def _wait_for_finetuning(self, job_id: str, interval: int = FINETUNE_J...
method _deploy_model (line 541) | def _deploy_model(self, model_name: str, deployment_name: str, version...
method _wait_for_deployment_ready (line 590) | def _wait_for_deployment_ready(self, deployment_name: str, version: st...
method _delete_deployment (line 655) | def _delete_deployment(self, deployment_name: str) -> None:
method _get_azure_token (line 693) | def _get_azure_token(self) -> str:
method _log_info (line 721) | def _log_info(self, message: str, *args: Any, **kwargs: Any) -> None:
method _log_debug (line 724) | def _log_debug(self, message: str, *args: Any, **kwargs: Any) -> None:
method _log_warning (line 727) | def _log_warning(self, message: str, *args: Any, **kwargs: Any) -> None:
method _log_error (line 730) | def _log_error(self, message: str, *args: Any, **kwargs: Any) -> None:
FILE: examples/azure/capital_agent.py
function country_capital_lookup (line 49) | def country_capital_lookup(country: str) -> str:
class CapitalTask (line 53) | class CapitalTask(TypedDict):
function capital_agent (line 77) | def capital_agent(task: CapitalTask, llm: LLM) -> float:
function main (line 158) | async def main():
FILE: examples/azure/tests/test_deployment.py
function test_deployment (line 18) | def test_deployment():
function test_wait_for_deployment_ready (line 26) | def test_wait_for_deployment_ready():
function test_delete_deployment (line 30) | def test_delete_deployment():
FILE: examples/azure/train_capital_agent.py
function parse_args (line 15) | def parse_args() -> argparse.Namespace:
function main (line 22) | def main():
FILE: examples/calc_x/calc_agent.py
class MathProblem (line 20) | class MathProblem(TypedDict):
function autogen_assistant_agent (line 39) | def autogen_assistant_agent(
function calc_agent (line 66) | async def calc_agent(task: MathProblem, llm: agl.LLM) -> None:
function debug (line 108) | async def debug():
FILE: examples/calc_x/eval_utils.py
function normalize_option (line 14) | def normalize_option(option: str) -> str:
function is_option_result (line 22) | def is_option_result(result: str) -> bool:
function float_eval (line 32) | def float_eval(input_str: str) -> float:
function scalar_are_results_same (line 39) | def scalar_are_results_same(pred_result: str, true_result: str, rel_tol:...
function evaluate (line 63) | async def evaluate(prediction: str, ground_truth: str) -> float:
function evaluate_v0_1 (line 68) | async def evaluate_v0_1(prediction: str, ground_truth: str) -> float:
FILE: examples/calc_x/legacy_calc_agent.py
function autogen_assistant_agent (line 29) | def autogen_assistant_agent(
class LegacyCalcAgent (line 55) | class LegacyCalcAgent(LitAgent[Any]):
method training_rollout_async (line 58) | async def training_rollout_async(self, task: Any, rollout_id: str, res...
method validation_rollout_async (line 85) | async def validation_rollout_async(self, task: Any, rollout_id: str, r...
FILE: examples/calc_x/legacy_calc_agent_debug.py
function dev_task_loader (line 12) | def dev_task_loader() -> DevTaskLoader:
FILE: examples/calc_x/tests/test_agentops.py
function process_data (line 10) | def process_data(data: str) -> float:
function process_data2 (line 18) | def process_data2(data: str) -> str:
FILE: examples/calc_x/tests/test_mcp_calculator.py
function main (line 12) | async def main():
FILE: examples/calc_x/train_calc_agent.py
function verl_default_config (line 44) | def verl_default_config() -> Dict[str, Any]:
function train (line 110) | def train(
function main (line 246) | def main():
FILE: examples/chartqa/chartqa_agent.py
class ChartState (line 44) | class ChartState(MessagesState):
class ChartQAAgent (line 56) | class ChartQAAgent(agl.LitAgent[Dict[str, Any]]):
method __init__ (line 63) | def __init__(
method _create_llm (line 82) | def _create_llm(self) -> BaseChatModel:
method update_llm_config (line 96) | def update_llm_config(self, model_name: str, endpoint: str | None, tem...
method _ensure_llm (line 111) | def _ensure_llm(self) -> BaseChatModel:
method invoke_prompt (line 117) | def invoke_prompt(self, prompt: Any) -> AnyMessage:
method invoke_prompt_with_image (line 134) | def invoke_prompt_with_image(self, prompt_text: str, image_path: str) ...
method extract_content (line 175) | def extract_content(self, text: str, tag: str) -> str:
method analyze_chart (line 180) | def analyze_chart(self, state: ChartState) -> ChartState:
method extract_data (line 198) | def extract_data(self, state: ChartState) -> ChartState:
method calculate_answer (line 218) | def calculate_answer(self, state: ChartState) -> ChartState:
method check_answer (line 240) | def check_answer(self, state: ChartState) -> ChartState:
method refine_answer (line 262) | def refine_answer(self, state: ChartState) -> ChartState:
method should_continue (line 295) | def should_continue(self, state: ChartState) -> Literal[END, "refine_a...
method graph (line 315) | def graph(self) -> CompiledStateGraph[ChartState]:
method rollout (line 341) | def rollout(self, task: Dict[str, Any], resources: agl.NamedResources,...
function evaluate_answer (line 382) | def evaluate_answer(predicted: str, ground_truth: str, raise_on_error: b...
FILE: examples/chartqa/debug_chartqa_agent.py
function create_llm_proxy_for_chartqa (line 41) | def create_llm_proxy_for_chartqa(vllm_endpoint: str, port: int = 8081) -...
function debug_chartqa_agent (line 72) | def debug_chartqa_agent(use_llm_proxy: bool = False) -> None:
FILE: examples/chartqa/multimodal_utils.py
function encode_image_to_base64 (line 27) | def encode_image_to_base64(image: Union[str, Path, PILImage], max_size: ...
function create_image_message (line 86) | def create_image_message(text: str, image: Union[str, Path, PILImage], u...
FILE: examples/chartqa/prepare_data.py
function prepare_chartqa (line 12) | def prepare_chartqa():
FILE: examples/chartqa/train_chartqa_agent.py
function config_ci (line 85) | def config_ci() -> Dict[str, Any]:
function config_debug (line 110) | def config_debug() -> Dict[str, Any]:
function config_qwen (line 119) | def config_qwen() -> Dict[str, Any]:
function train (line 129) | def train(
function main (line 165) | def main():
FILE: examples/claude_code/claude_code_agent.py
function _load_dataset (line 87) | def _load_dataset(path: str, epoch: int = 0, limit: Optional[int] = None...
function _flatten_messages (line 100) | def _flatten_messages(messages: List[Any]) -> List[Dict[str, str]]:
class ClaudeCodeAgent (line 121) | class ClaudeCodeAgent(LitAgent[SWEbenchInstance]):
method __init__ (line 128) | def __init__(
method rollout_async (line 161) | async def rollout_async(
function sanity_check_spans (line 224) | def sanity_check_spans(spans: Sequence[Span]) -> None:
function run_instance_async (line 230) | async def run_instance_async(
function dry_run_claude_code (line 312) | async def dry_run_claude_code(
FILE: examples/claude_code/claude_code_controller.py
class RunInstanceResult (line 40) | class RunInstanceResult(TypedDict):
class ClaudeController (line 46) | class ClaudeController:
method __init__ (line 57) | def __init__(self, image: str, instance: SWEbenchInstance, run_id: str...
method init_container (line 74) | def init_container(self, image: str, instance: SWEbenchInstance) -> Ru...
method _run_cli (line 104) | def _run_cli(self, instance: SWEbenchInstance, max_turns: int, time_li...
method _run_python_sdk (line 135) | def _run_python_sdk(self, instance: SWEbenchInstance, max_turns: int, ...
method run_instance (line 179) | def run_instance(
method __del__ (line 224) | def __del__(self) -> None:
FILE: examples/claude_code/extended_adapter.py
class ExtendedLlmProxyTraceToTriplet (line 20) | class ExtendedLlmProxyTraceToTriplet(LlmProxyTraceToTriplet):
method _extract_tokens_from_raw (line 30) | def _extract_tokens_from_raw(self, attrs: Dict[str, Any]) -> Tuple[Lis...
method adapt (line 63) | def adapt(self, source: List[Span], /) -> List[Triplet]: # type: ignore
FILE: examples/claude_code/swebench_utils/docker_runtime.py
class CmdOutputMetadata (line 55) | class CmdOutputMetadata:
method matches_ps1_metadata (line 70) | def matches_ps1_metadata(cls, output: str) -> List[re.Match[str]]:
method best_effort_match (line 84) | def best_effort_match(cls, scope: str) -> Dict[str, Any]:
method from_ps1_match (line 95) | def from_ps1_match(cls, match: re.Match[str]) -> Self:
class CommandResult (line 121) | class CommandResult:
method to_observation (line 133) | def to_observation(self, strip: bool = True) -> str:
class Runtime (line 160) | class Runtime:
method __init__ (line 168) | def __init__(self, container: Container, log_function: Callable[..., N...
method _stream_output (line 197) | def _stream_output(self):
method _start_output_thread (line 211) | def _start_output_thread(self):
method _clear_initial_prompt (line 216) | def _clear_initial_prompt(self):
method _read_raw_output (line 221) | def _read_raw_output(self, timeout: float = 30) -> tuple[str, Optional...
method _combine_outputs_between_matches (line 245) | def _combine_outputs_between_matches(self, pane_content: str, ps1_matc...
method _recv_bytes (line 256) | def _recv_bytes(self, n: int = 4096) -> bytes:
method _send_bytes (line 268) | def _send_bytes(self, data: bytes) -> None:
method _log_command_result (line 281) | def _log_command_result(self, result: CommandResult) -> None:
method send_command (line 293) | def send_command(self, command: str, timeout: float = 20 * 60) -> Comm...
method cleanup (line 336) | def cleanup(self) -> None:
method __del__ (line 349) | def __del__(self):
method pull_image (line 353) | def pull_image(image_name: str) -> bool:
method start_session (line 371) | def start_session(
FILE: examples/claude_code/swebench_utils/evaluation.py
function run_instance (line 60) | def run_instance(
function evaluate (line 229) | def evaluate(
FILE: examples/claude_code/swebench_utils/logging.py
function log_for_evaluation (line 13) | def log_for_evaluation(run_id: str, instance_id: str, text: str) -> None:
FILE: examples/minimal/llm_proxy.py
function serve_llm_proxy_with_vllm (line 39) | async def serve_llm_proxy_with_vllm(model_name: str, store_port: int = 4...
function serve_llm_proxy_with_openai (line 78) | async def serve_llm_proxy_with_openai(model_name: str, store_port: int =...
function test_llm_proxy (line 114) | async def test_llm_proxy(model_name: str, store_port: int = 43887):
function _verify_response_body (line 150) | def _verify_response_body(response_body: dict, model_name: str):
function _verify_span (line 192) | def _verify_span(spans:
Condensed preview — 546 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (9,689K chars).
[
{
"path": ".dockerignore",
"chars": 130,
"preview": ".venv\n**/.venv\n__pycache__\n.git\n.gitignore\n**/node_modules\ndist\nbuild\n.env\ndocker\n.pytest_cache\n.vscode\n**/*.log\nexample"
},
{
"path": ".github/workflows/backport.yml",
"chars": 973,
"preview": "name: Backport Merged Pull Request\non:\n pull_request_target:\n types: [closed]\npermissions:\n contents: write\n issue"
},
{
"path": ".github/workflows/badge-apo.yml",
"chars": 831,
"preview": "name: Badge - APO\n\non:\n workflow_run:\n workflows:\n - Examples - APO\n types: [completed]\n\n workflow_dispatch"
},
{
"path": ".github/workflows/badge-azure.yml",
"chars": 829,
"preview": "name: Badge - Azure\n\non:\n workflow_run:\n workflows:\n - Examples - Azure\n types: [completed]\n\n workflow_disp"
},
{
"path": ".github/workflows/badge-calc-x.yml",
"chars": 843,
"preview": "name: Badge - Calc-X\n\non:\n workflow_run:\n workflows:\n - Examples - Calc-X\n types: [completed]\n\n workflow_di"
},
{
"path": ".github/workflows/badge-chartqa.yml",
"chars": 837,
"preview": "name: Badge - ChartQA\n\non:\n workflow_run:\n workflows:\n - Examples - ChartQA\n types: [completed]\n\n workflow_"
},
{
"path": ".github/workflows/badge-claude-code.yml",
"chars": 853,
"preview": "name: Badge - Claude Code\n\non:\n workflow_run:\n workflows:\n - Examples - Claude Code\n types: [completed]\n\n w"
},
{
"path": ".github/workflows/badge-compat.yml",
"chars": 875,
"preview": "name: Badge - Compatibility\n\non:\n workflow_run:\n workflows:\n - Examples - Backward Compatibility\n types: [co"
},
{
"path": ".github/workflows/badge-examples.yml",
"chars": 1907,
"preview": "name: Badge - Examples\n\non:\n workflow_run:\n workflows:\n - Examples - Calc-X\n - Examples - Spider\n - E"
},
{
"path": ".github/workflows/badge-latest.yml",
"chars": 1568,
"preview": "name: Badge - Latest\n\non:\n workflow_run:\n workflows:\n - Examples - Calc-X\n - Examples - Spider\n - Exa"
},
{
"path": ".github/workflows/badge-rag.yml",
"chars": 831,
"preview": "name: Badge - RAG\n\non:\n workflow_run:\n workflows:\n - Examples - RAG\n types: [completed]\n\n workflow_dispatch"
},
{
"path": ".github/workflows/badge-spider.yml",
"chars": 833,
"preview": "name: Badge - Spider\n\non:\n workflow_run:\n workflows:\n - Examples - Spider\n types: [completed]\n\n workflow_di"
},
{
"path": ".github/workflows/badge-tinker.yml",
"chars": 833,
"preview": "name: Badge - Tinker\n\non:\n workflow_run:\n workflows:\n - Examples - Tinker\n types: [completed]\n\n workflow_di"
},
{
"path": ".github/workflows/badge-unit.yml",
"chars": 981,
"preview": "name: Badge - Unit Test\n\non:\n workflow_run:\n workflows:\n - CPU Test\n - GPU Test\n types: [completed]\n\n "
},
{
"path": ".github/workflows/badge-unsloth.yml",
"chars": 853,
"preview": "name: Badge - Unsloth\n\non:\n workflow_run:\n workflows:\n - Examples - Unsloth\n types: [completed]\n\n workflow_"
},
{
"path": ".github/workflows/benchmark.yml",
"chars": 14992,
"preview": "name: Benchmark\npermissions:\n contents: read\non:\n workflow_dispatch:\n schedule:\n # Every Monday and Thursday at 3 "
},
{
"path": ".github/workflows/dashboard.yml",
"chars": 726,
"preview": "name: Dashboard\npermissions:\n contents: read\non:\n schedule:\n # Every day at 5 AM UTC+8\n - cron: '0 21 * * *'\n\n "
},
{
"path": ".github/workflows/docs.yml",
"chars": 1780,
"preview": "name: Deploy Documentation\n\non:\n push:\n branches:\n - main\n tags:\n - 'v*'\n workflow_dispatch:\n\nconcurre"
},
{
"path": ".github/workflows/examples-apo.yml",
"chars": 4055,
"preview": "name: Examples - APO\npermissions:\n contents: read\non:\n schedule:\n # Every day at 3 AM UTC+8\n - cron: '0 19 * * *"
},
{
"path": ".github/workflows/examples-azure.yml",
"chars": 3350,
"preview": "name: Examples - Azure\npermissions:\n contents: read\non:\n schedule:\n # Every day at 4 AM UTC+8\n - cron: '0 20 * *"
},
{
"path": ".github/workflows/examples-calc-x.yml",
"chars": 16934,
"preview": "name: Examples - Calc-X\npermissions:\n contents: read\non:\n schedule:\n # Every day at 3 AM UTC+8\n - cron: '0 19 * "
},
{
"path": ".github/workflows/examples-chartqa.yml",
"chars": 5477,
"preview": "name: Examples - ChartQA\npermissions:\n contents: read\non:\n schedule:\n # Every day at 6 AM UTC+8\n - cron: \"0 22 *"
},
{
"path": ".github/workflows/examples-claude-code.yml",
"chars": 5207,
"preview": "name: Examples - Claude Code\npermissions:\n contents: read\non:\n schedule:\n # Every day at 4 AM UTC+8\n - cron: \"0 "
},
{
"path": ".github/workflows/examples-compat.yml",
"chars": 5380,
"preview": "name: Examples - Backward Compatibility\npermissions:\n contents: read\non:\n schedule:\n # Every day at 6 AM UTC+8\n "
},
{
"path": ".github/workflows/examples-rag.yml",
"chars": 6087,
"preview": "name: Examples - RAG\npermissions:\n contents: read\non:\n schedule:\n # Every day at 6 AM UTC+8\n - cron: '0 22 * * *"
},
{
"path": ".github/workflows/examples-spider.yml",
"chars": 4377,
"preview": "name: Examples - Spider\npermissions:\n contents: read\non:\n schedule:\n # Every day at 4 AM UTC+8\n - cron: '0 20 * "
},
{
"path": ".github/workflows/examples-tinker.yml",
"chars": 5957,
"preview": "name: Examples - Tinker\npermissions:\n contents: read\non:\n schedule:\n # Every day at 3 AM UTC+8\n - cron: '0 19 * "
},
{
"path": ".github/workflows/examples-unsloth.yml",
"chars": 4300,
"preview": "name: Examples - Unsloth\npermissions:\n contents: read\non:\n schedule:\n # Every day at 5 AM UTC+8\n - cron: '0 21 *"
},
{
"path": ".github/workflows/issue-comment.yml",
"chars": 12524,
"preview": "name: Issue Comment\n\non:\n issue_comment:\n types: [created]\n\npermissions:\n pull-requests: write\n issues: write\n co"
},
{
"path": ".github/workflows/playground.yml",
"chars": 360,
"preview": "# Pre-defined workflow with workflow_dispatch trigger,\n# convenient for testing and debugging.\n\nname: Playground\npermiss"
},
{
"path": ".github/workflows/pypi-nightly.yml",
"chars": 1712,
"preview": "name: PyPI Nightly Build\n\non:\n schedule:\n # Run daily at 6:00 AM UTC+8\n - cron: '0 22 * * *'\n workflow_dispatch:"
},
{
"path": ".github/workflows/pypi-release.yml",
"chars": 2440,
"preview": "name: PyPI Release\n\non:\n push:\n tags:\n - 'v*' # Trigger on version tags like v1.0.0, v1.2.3, etc.\n workflow_d"
},
{
"path": ".github/workflows/tests-full.yml",
"chars": 13742,
"preview": "name: GPU Test\npermissions:\n contents: read\non:\n schedule:\n # Every day at 5 AM UTC+8\n - cron: '0 21 * * *'\n\n w"
},
{
"path": ".github/workflows/tests.yml",
"chars": 7914,
"preview": "name: CPU Test\n\npermissions:\n contents: read\n\non:\n push:\n branches: [ main, stable/**/* ]\n pull_request:\n branc"
},
{
"path": ".gitignore",
"chars": 4714,
"preview": "# Agentlightning specific files\nverl_old\nmeta-llama/**\n**/debug/**/*.png\n**/debug/**/*.json\nrequirements-freeze*.txt\n/pl"
},
{
"path": ".pre-commit-config.yaml",
"chars": 2133,
"preview": "repos:\n - repo: https://github.com/pre-commit/pre-commit-hooks\n rev: v6.0.0\n hooks:\n - id: end-of-file-fixer"
},
{
"path": ".python-version",
"chars": 5,
"preview": "3.12\n"
},
{
"path": "AGENTS.md",
"chars": 4480,
"preview": "# Repository Guidelines\n\n## Architecture Overview\nAgent Lightning runs through a continuous loop: runners and tracers em"
},
{
"path": "LICENSE",
"chars": 1046,
"preview": "The MIT License (MIT)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and"
},
{
"path": "RAI_README.md",
"chars": 6656,
"preview": "# Responsible AI Transparency Documentation - Agent Lightning\n\n## OVERVIEW\n\nAgent Lightning is a flexible and extensible"
},
{
"path": "README.md",
"chars": 9914,
"preview": "<p align=\"center\">\n <img src=\"docs/assets/readme-banner.svg\" alt=\"Agent-lightning-banner\" style=\"width:600px\"/>\n</p>\n\n#"
},
{
"path": "SECURITY.md",
"chars": 543,
"preview": "<!-- BEGIN MICROSOFT SECURITY.MD V1.0.0 BLOCK -->\n\n## Security\n\nMicrosoft takes the security of our software products an"
},
{
"path": "agentlightning/__init__.py",
"chars": 730,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n__version__ = \"0.3.1\"\n\nfrom .adapter import *\nfrom .algorithm import *\n"
},
{
"path": "agentlightning/adapter/__init__.py",
"chars": 412,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom .base import Adapter, OtelTraceAdapter, TraceAdapter\nfrom .message"
},
{
"path": "agentlightning/adapter/base.py",
"chars": 3276,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom typing import Generic, Sequence, TypeVar\n\nfrom opentelemetry.sdk.t"
},
{
"path": "agentlightning/adapter/messages.py",
"chars": 11260,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport json\nfrom collections import"
},
{
"path": "agentlightning/adapter/triplet.py",
"chars": 43338,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport json\nimport logging\nimport r"
},
{
"path": "agentlightning/algorithm/__init__.py",
"chars": 731,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nfrom typing import TYPE_CHECKING, A"
},
{
"path": "agentlightning/algorithm/apo/__init__.py",
"chars": 89,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom .apo import APO\n\n__all__ = [\"APO\"]\n"
},
{
"path": "agentlightning/algorithm/apo/apo.py",
"chars": 34772,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"\nAPO with textual gradients that read rollout spans and outputs to m"
},
{
"path": "agentlightning/algorithm/apo/prompts/apply_edit_variant01.poml",
"chars": 981,
"preview": "<poml>\n <p>Revise the given prompt template using the critique as constraints and improvement guide.</p>\n <cp caption="
},
{
"path": "agentlightning/algorithm/apo/prompts/apply_edit_variant02.poml",
"chars": 724,
"preview": "<!-- Conservative Edit Prompt -->\n\n<poml>\n <p>Revise the prompt to address ONE critique point clearly and effectively. "
},
{
"path": "agentlightning/algorithm/apo/prompts/text_gradient_variant01.poml",
"chars": 816,
"preview": "<poml>\n <p>You optimize a prompt template.</p>\n <cp caption=\"Original Prompt Template\">\n <text whiteSpace=\"pre\">{{ "
},
{
"path": "agentlightning/algorithm/apo/prompts/text_gradient_variant02.poml",
"chars": 802,
"preview": "<poml>\n <role>You are a prompt engineer.</role>\n <task>Analyze where the current prompt failed to elicit the right mec"
},
{
"path": "agentlightning/algorithm/apo/prompts/text_gradient_variant03.poml",
"chars": 6101,
"preview": "<poml>\n\n <role>You are an expert prompt engineer.</role>\n\n <task>Your task is to analyze the prompt and provide a crit"
},
{
"path": "agentlightning/algorithm/base.py",
"chars": 5615,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport inspect\nimport weakref\nfrom "
},
{
"path": "agentlightning/algorithm/decorator.py",
"chars": 9175,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport functools\nimport inspect\nfro"
},
{
"path": "agentlightning/algorithm/fast.py",
"chars": 11410,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport asyncio\nimport logging\nfrom "
},
{
"path": "agentlightning/algorithm/utils.py",
"chars": 5758,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport functools\nimport logging\nimp"
},
{
"path": "agentlightning/algorithm/verl/__init__.py",
"chars": 97,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom .interface import VERL\n\n__all__ = [\"VERL\"]\n"
},
{
"path": "agentlightning/algorithm/verl/interface.py",
"chars": 7739,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nfrom typing import TYPE_CHECKING, A"
},
{
"path": "agentlightning/cli/__init__.py",
"chars": 1987,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Agent Lightning command line interface entry point.\"\"\"\n\nfrom __futur"
},
{
"path": "agentlightning/cli/prometheus.py",
"chars": 4020,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Serve Prometheus metrics from the Agent Lightning multiprocess regis"
},
{
"path": "agentlightning/cli/store.py",
"chars": 4355,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Run a LightningStore server for persistent access from multiple proc"
},
{
"path": "agentlightning/cli/vllm.py",
"chars": 636,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nfrom typing import Iterable\n\n\ndef m"
},
{
"path": "agentlightning/client.py",
"chars": 17220,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Utilities for interacting with legacy Agent Lightning servers.\n\nThis"
},
{
"path": "agentlightning/config.py",
"chars": 14349,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"\nThis file is not carefully reviewed.\nIt might contain unintentional"
},
{
"path": "agentlightning/emitter/__init__.py",
"chars": 1320,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Convenient helpers for creating spans / traces.\n\nAll emitters operat"
},
{
"path": "agentlightning/emitter/annotation.py",
"chars": 15132,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Helpers for emitting annotation/operation spans.\"\"\"\n\nimport asyncio\n"
},
{
"path": "agentlightning/emitter/exception.py",
"chars": 2056,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport logging\nfrom typing import Any, Dict, Optional\n\nfrom agentlightn"
},
{
"path": "agentlightning/emitter/message.py",
"chars": 2400,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport logging\nfrom typing import Any, Dict, Optional\n\nfrom agentlightn"
},
{
"path": "agentlightning/emitter/object.py",
"chars": 4695,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport base64\nimport json\nimport logging\nfrom typing import Any, Dict, "
},
{
"path": "agentlightning/emitter/reward.py",
"chars": 11299,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Helpers for emitting reward spans and integrating with AgentOps tele"
},
{
"path": "agentlightning/env_var.py",
"chars": 4403,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Environment variable managements.\"\"\"\n\nfrom __future__ import annotat"
},
{
"path": "agentlightning/execution/__init__.py",
"chars": 458,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom .base import ExecutionStrategy\nfrom .client_server import ClientSe"
},
{
"path": "agentlightning/execution/base.py",
"chars": 2442,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport logging\nfrom typing import P"
},
{
"path": "agentlightning/execution/client_server.py",
"chars": 20350,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport asyncio\nimport logging\nimport multiprocessing\nimport os\nimport s"
},
{
"path": "agentlightning/execution/events.py",
"chars": 1963,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport multiprocessing as mp\nimport threading\nfrom multiprocessing.cont"
},
{
"path": "agentlightning/execution/inter_process.py",
"chars": 480,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom .base import ExecutionStrategy\n\n\nclass InterProcessExecutionStrate"
},
{
"path": "agentlightning/execution/shared_memory.py",
"chars": 12132,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport asyncio\nimport logging\nimport threading\nfrom contextlib import s"
},
{
"path": "agentlightning/instrumentation/__init__.py",
"chars": 3326,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport warnings\n\nAGENTOPS_INSTALLED: bool = False\nAGENTOPS_LANGCHAIN_IN"
},
{
"path": "agentlightning/instrumentation/agentops.py",
"chars": 13069,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport json\nimport logging\nfrom typ"
},
{
"path": "agentlightning/instrumentation/agentops_langchain.py",
"chars": 1560,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom typing import Any, Dict\n\nfrom agentops import instrumentation\nfrom"
},
{
"path": "agentlightning/instrumentation/litellm.py",
"chars": 1338,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"LiteLLM instrumentations.\n\nIt's unclear whether or not this file is "
},
{
"path": "agentlightning/instrumentation/vllm.py",
"chars": 2405,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport warnings\nfrom typing import "
},
{
"path": "agentlightning/instrumentation/weave.py",
"chars": 21253,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport logging\nimport threading\nimp"
},
{
"path": "agentlightning/litagent/__init__.py",
"chars": 185,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom .decorator import *\nfrom .litagent import *\n\n__all__ = [\n \"LitA"
},
{
"path": "agentlightning/litagent/decorator.py",
"chars": 19166,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Convenience decorators for building lightweight `LitAgent` implement"
},
{
"path": "agentlightning/litagent/litagent.py",
"chars": 9990,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Base abstractions for building agents that plug into Agent Lightning"
},
{
"path": "agentlightning/llm_proxy.py",
"chars": 60979,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport ast\nimport asyncio\nimport js"
},
{
"path": "agentlightning/logging.py",
"chars": 13766,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport logging\nimport os\nimport pla"
},
{
"path": "agentlightning/reward.py",
"chars": 213,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport warnings\n\nfrom .emitter.reward import * # noqa: F401,F403\n\nwarn"
},
{
"path": "agentlightning/runner/__init__.py",
"chars": 222,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom .agent import LitAgentRunner\nfrom .base import Runner\nfrom .legacy"
},
{
"path": "agentlightning/runner/agent.py",
"chars": 35908,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Agent runner implementation for executing agent rollouts.\n\nThis modu"
},
{
"path": "agentlightning/runner/base.py",
"chars": 6859,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Abstract runner interface for executing agent tasks.\"\"\"\n\nfrom __futu"
},
{
"path": "agentlightning/runner/legacy.py",
"chars": 13775,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport json\nimport logging\nimport time\nfrom typing import Any, Dict, Li"
},
{
"path": "agentlightning/semconv.py",
"chars": 5636,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Semantic conventions for Agent-lightning spans.\n\nConventions in this"
},
{
"path": "agentlightning/server.py",
"chars": 16873,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Legacy HTTP server compatible with the original Agent Lightning prot"
},
{
"path": "agentlightning/store/__init__.py",
"chars": 611,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom .base import LightningStore, LightningStoreCapabilities, Lightning"
},
{
"path": "agentlightning/store/base.py",
"chars": 36654,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nfrom typing import Any, Dict, List,"
},
{
"path": "agentlightning/store/client_server.py",
"chars": 87187,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport asyncio\nimport logging\nimpor"
},
{
"path": "agentlightning/store/collection/__init__.py",
"chars": 637,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom .base import (\n AtomicLabels,\n AtomicMode,\n Collection,\n "
},
{
"path": "agentlightning/store/collection/base.py",
"chars": 20769,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport functools\nimport time\nfrom c"
},
{
"path": "agentlightning/store/collection/memory.py",
"chars": 36173,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport asyncio\nimport logging\nimpor"
},
{
"path": "agentlightning/store/collection/mongo.py",
"chars": 54078,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport asyncio\nimport logging\nimpor"
},
{
"path": "agentlightning/store/collection_based.py",
"chars": 78030,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Collection-based LightningStore implementation.\n\nTo developers, plea"
},
{
"path": "agentlightning/store/memory.py",
"chars": 16871,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport asyncio\nimport logging\nimpor"
},
{
"path": "agentlightning/store/mongo.py",
"chars": 6794,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport asyncio\nimport hashlib\nimpor"
},
{
"path": "agentlightning/store/sqlite.py",
"chars": 72,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n# TODO: Implement this\n"
},
{
"path": "agentlightning/store/threading.py",
"chars": 11946,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport threading\nfrom typing import"
},
{
"path": "agentlightning/store/utils.py",
"chars": 4031,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport time\nfrom typing import Awaitable, Callable, Dict, List, Tuple\n\n"
},
{
"path": "agentlightning/tracer/__init__.py",
"chars": 395,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom .agentops import AgentOpsTracer\nfrom .base import Tracer, clear_ac"
},
{
"path": "agentlightning/tracer/agentops.py",
"chars": 10843,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport logging\nimport os\nimport war"
},
{
"path": "agentlightning/tracer/base.py",
"chars": 9490,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport functools\nimport logging\nfro"
},
{
"path": "agentlightning/tracer/dummy.py",
"chars": 3411,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport logging\nimport time\nfrom con"
},
{
"path": "agentlightning/tracer/otel.py",
"chars": 23261,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport asyncio\nimport logging\nimpor"
},
{
"path": "agentlightning/tracer/weave.py",
"chars": 26970,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport asyncio\nimport concurrent.fu"
},
{
"path": "agentlightning/trainer/__init__.py",
"chars": 160,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom .init_utils import build_component\nfrom .trainer import Trainer\n\n_"
},
{
"path": "agentlightning/trainer/init_utils.py",
"chars": 10755,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Utility helpers for dynamic component initialization within the trai"
},
{
"path": "agentlightning/trainer/legacy.py",
"chars": 16636,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport asyncio\nimport logging\nimport multiprocessing\nimport signal\nimpo"
},
{
"path": "agentlightning/trainer/registry.py",
"chars": 450,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Put components in this file to make them available to the Trainer.\n\n"
},
{
"path": "agentlightning/trainer/trainer.py",
"chars": 25368,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport asyncio\nimport functools\nimport logging\nimport warnings\nfrom typ"
},
{
"path": "agentlightning/types/__init__.py",
"chars": 116,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom .core import *\nfrom .resources import *\nfrom .tracer import *\n"
},
{
"path": "agentlightning/types/core.py",
"chars": 18692,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Core data models shared across Agent Lightning components.\"\"\"\n\nfrom "
},
{
"path": "agentlightning/types/resources.py",
"chars": 6946,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\n\"\"\"Typed representations of tunable"
},
{
"path": "agentlightning/types/tracer.py",
"chars": 19220,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport time\n\n\"\"\"Data models that mi"
},
{
"path": "agentlightning/utils/__init__.py",
"chars": 48,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n"
},
{
"path": "agentlightning/utils/id.py",
"chars": 598,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport hashlib\nimport uuid\n\n__all__ = [\"generate_id\"]\n\n\ndef generate_id"
},
{
"path": "agentlightning/utils/metrics.py",
"chars": 36291,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Metrics abstraction with explicit registration and several backends."
},
{
"path": "agentlightning/utils/otel.py",
"chars": 21773,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Utilities shared for OpenTelemetry span (attributes) support.\"\"\"\n\nim"
},
{
"path": "agentlightning/utils/otlp.py",
"chars": 18203,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport gzip\nimport logging\nfrom typ"
},
{
"path": "agentlightning/utils/server_launcher.py",
"chars": 42510,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport asyncio\nimport inspect\nimpor"
},
{
"path": "agentlightning/utils/system_snapshot.py",
"chars": 2319,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport platform\nimport socket\nfrom "
},
{
"path": "agentlightning/verl/__init__.py",
"chars": 224,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"This package contains a *hacky* integration of VERL with Agent Light"
},
{
"path": "agentlightning/verl/__main__.py",
"chars": 117,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom .entrypoint import main\n\nif __name__ == \"__main__\":\n main()\n"
},
{
"path": "agentlightning/verl/async_server.py",
"chars": 1691,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n# type: ignore\n\nfrom copy import deepcopy\n\nimport ray\nfrom starlette.re"
},
{
"path": "agentlightning/verl/config.yaml",
"chars": 1118,
"preview": "hydra:\n searchpath:\n - pkg://verl/trainer/config\n\ndefaults:\n - ppo_trainer\n - _self_\n\nagentlightning:\n port: 9999"
},
{
"path": "agentlightning/verl/daemon.py",
"chars": 54563,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport asyncio\nimport json\nimport os\nimport random\nimport socket\nimport"
},
{
"path": "agentlightning/verl/dataset.py",
"chars": 1181,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n# type: ignore\n\nimport torch\nfrom datasets import Dataset as HuggingFac"
},
{
"path": "agentlightning/verl/entrypoint.py",
"chars": 8687,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n# pyright: reportUnknownVariableType=false\n# pyright: reportUnknownMemb"
},
{
"path": "agentlightning/verl/trainer.py",
"chars": 25523,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n# type: ignore\n\nfrom __future__ import annotations\n\nimport random\nfrom "
},
{
"path": "contrib/.gitignore",
"chars": 111,
"preview": "# Put contrib-related gitignore files here.\n\n# recipes/envs related\nrecipes/envs/agl_envs/\nrecipes/envs/wandb/\n"
},
{
"path": "contrib/CODEOWNERS",
"chars": 86,
"preview": "# Put code owner definitions here.\n\n# Recipes\nrecipes/search_r1 @SiyunZhao @JiahangXu\n"
},
{
"path": "contrib/README.md",
"chars": 2001,
"preview": "# Contrib Area\n\nThis tree hosts experimental integrations, third-party recipes, and curated recipes that are not ready f"
},
{
"path": "contrib/agentlightning/contrib/__init__.py",
"chars": 97,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n# Namespace package for agentlightning.contrib.\n"
},
{
"path": "contrib/agentlightning/contrib/adapter/__init__.py",
"chars": 105,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n# Namespace package for agentlightning.contrib.adapter.\n"
},
{
"path": "contrib/agentlightning/contrib/adapter/agentos.py",
"chars": 4068,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"\nFlightRecorderAdapter - Import Audit Logs to LightningStore\n======="
},
{
"path": "contrib/agentlightning/contrib/adapter/triplet_group.py",
"chars": 5273,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nfrom typing import Dict, List, Opti"
},
{
"path": "contrib/agentlightning/contrib/agent/env_agent.py",
"chars": 6283,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport logging\nimport os\nfrom typin"
},
{
"path": "contrib/agentlightning/contrib/algorithm/env_verl/daemon.py",
"chars": 40330,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport asyncio\nimport json\nimport random\nimport socket\nimport threading"
},
{
"path": "contrib/agentlightning/contrib/algorithm/env_verl/trainer.py",
"chars": 25201,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n# type: ignore\n\nfrom __future__ import annotations\n\nimport random\nfrom "
},
{
"path": "contrib/agentlightning/contrib/reward/__init__.py",
"chars": 104,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n# Namespace package for agentlightning.contrib.reward.\n"
},
{
"path": "contrib/agentlightning/contrib/reward/agentos.py",
"chars": 3759,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"\nPolicyReward - Convert Policy Violations to RL Penalties\n=========="
},
{
"path": "contrib/agentlightning/contrib/runner/__init__.py",
"chars": 104,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n# Namespace package for agentlightning.contrib.runner.\n"
},
{
"path": "contrib/agentlightning/contrib/runner/agentos.py",
"chars": 8661,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"\nAgentOSRunner - Agent-Lightning Runner with Kernel Safety\n========="
},
{
"path": "contrib/recipes/agentos/README.md",
"chars": 2512,
"preview": "# Agent-OS Integration for Agent-Lightning\n\nKernel-level safety during AI agent training.\n\n## Overview\n\n[Agent-OS](https"
},
{
"path": "contrib/recipes/agentos/demo_governed_training.py",
"chars": 6414,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"\nAgent-OS + Agent-Lightning End-to-End Demo\n========================"
},
{
"path": "contrib/recipes/envs/README.md",
"chars": 3414,
"preview": "# Example of AGL Environments\n\n## Overview\n\nThis example implements agents across various environments within Agent Ligh"
},
{
"path": "contrib/recipes/envs/add_instruction.py",
"chars": 3760,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport copy\n\nfrom autogen_core.models import UserMessage\n\n# Instruction"
},
{
"path": "contrib/recipes/envs/config_env/alfworld.yaml",
"chars": 279,
"preview": "env_name: alfworld\nseed: 0\nformat_penalty: 0.1\nbinary_reward: False\nsave_rollout: False\nlog_env_obs: False\nreawrd_scale:"
},
{
"path": "contrib/recipes/envs/config_env/scienceworld.yaml",
"chars": 319,
"preview": "env_name: scienceworld\nseed: 0\nformat_penalty: 0.1\nbinary_reward: False\nsave_rollout: False\nlog_env_obs: False # True fo"
},
{
"path": "contrib/recipes/envs/config_verl/alfworld/grpo.yaml",
"chars": 2165,
"preview": "# ==========================\n# Variable definitions\n# ==========================\nvariables:\n NUM_GPUS: 2\n MINI_BATCH_S"
},
{
"path": "contrib/recipes/envs/config_verl/scienceworld/grpo.yaml",
"chars": 2218,
"preview": "# ==========================\n# Variable definitions\n# ==========================\nvariables:\n NUM_GPUS: 2\n MINI_BATCH_S"
},
{
"path": "contrib/recipes/envs/install_agl.sh",
"chars": 495,
"preview": "# This setup is based on CUDA 12.6\npip install torch torchvision --index-url https://download.pytorch.org/whl/cu126\npip "
},
{
"path": "contrib/recipes/envs/prompt_builder.py",
"chars": 6287,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom typing import Optional\n\nfrom autogen_core.models import AssistantM"
},
{
"path": "contrib/recipes/envs/train_env_agent.py",
"chars": 3579,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nimport argparse\nimport os\nimport subprocess\n\nfrom omegaconf import Omeg"
},
{
"path": "contrib/recipes/search_r1/README.md",
"chars": 4011,
"preview": "# Search-R1 Example\n\n## Overview\n\nThis example implements **Search R1** within Agent Lightning. It also serves as a demo"
},
{
"path": "contrib/recipes/search_r1/data_process.sh",
"chars": 1092,
"preview": "conda create -n retriever python=3.10\nconda activate retriever\n\n# we recommend installing torch with conda for faiss-gpu"
},
{
"path": "contrib/recipes/search_r1/qa_em.py",
"chars": 4254,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n# Copyright 2024 Bytedance Ltd. and/or its affiliates\n#\n# Licensed unde"
},
{
"path": "contrib/recipes/search_r1/retrieval_launch.sh",
"chars": 565,
"preview": "conda activate retriever\n\nfile_path=data\nindex_file=$file_path/e5_Flat.index\ncorpus_file=$file_path/wiki-18.jsonl\nretrie"
},
{
"path": "contrib/recipes/search_r1/retrieval_server.py",
"chars": 16888,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n# Copied and adapted from https://github.com/PeterGriffinJin/Search-R1/"
},
{
"path": "contrib/recipes/search_r1/search_r1_agent.py",
"chars": 8479,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\nfrom __future__ import annotations\n\nimport os\nimport re\nimport time\nfro"
},
{
"path": "contrib/recipes/search_r1/train_search_r1_agent.py",
"chars": 5509,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\nfrom __future__ import annotations\n\nimport argparse\nimport os\nfrom cop"
},
{
"path": "contrib/recipes/webshop/.gitignore",
"chars": 154,
"preview": "node_modules/\n.venv/\n.next/\ndist/\n*.tsbuildinfo\nserver/webshop/\n\n# Log files from make train\nlogs/\nstd_log.txt\n\n# Auto-g"
},
{
"path": "contrib/recipes/webshop/Dockerfile",
"chars": 5752,
"preview": "# Unified WebShop Training Image\n#\n# This Dockerfile creates a single image containing all components needed for\n# the W"
},
{
"path": "contrib/recipes/webshop/Makefile",
"chars": 3622,
"preview": "# WebShop Training Workflow\n#\n# Usage:\n# make setup # Initialize .env\n# make train # Run training stack "
},
{
"path": "contrib/recipes/webshop/README.md",
"chars": 5739,
"preview": "# WebShop Example\n\nThis example demonstrates how to train a Vercel AI SDK agent on the WebShop benchmark using Agent Lig"
},
{
"path": "contrib/recipes/webshop/agl/__init__.py",
"chars": 113,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Agent Lightning training configuration for WebShop agent.\"\"\"\n"
},
{
"path": "contrib/recipes/webshop/agl/config.py",
"chars": 6380,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Training configurations for the WebShop agent.\n\nThis module provides"
},
{
"path": "contrib/recipes/webshop/agl/generate_tasks.py",
"chars": 6281,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Generate training tasks from WebShop product data.\n\nThis script extr"
},
{
"path": "contrib/recipes/webshop/agl/requirements.txt",
"chars": 322,
"preview": "# Agent Lightning Training Dependencies\n# Python 3.10+ required\n#\n# For GPU training: ./setup.sh (installs VERL extras)\n"
},
{
"path": "contrib/recipes/webshop/agl/run_training.py",
"chars": 9915,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Train a WebShop agent using Agent Lightning with external runners.\n\n"
},
{
"path": "contrib/recipes/webshop/agl/sample_tasks.json",
"chars": 1828,
"preview": "[\n {\n \"task_id\": \"ws_001\",\n \"instruction\": \"I need a red cotton t-shirt for men, size large, under $30\",\n \"tar"
},
{
"path": "contrib/recipes/webshop/agl/tasks.py",
"chars": 2232,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"Task loading utilities for WebShop training.\n\nThis module provides u"
},
{
"path": "contrib/recipes/webshop/agl/webshop_tasks.json",
"chars": 3832661,
"preview": "[\n {\n \"task_id\": \"ws_B09QKP7XQL_0\",\n \"instruction\": \"i'm looking for a blue wireless bluetooth headphones.\",\n "
},
{
"path": "contrib/recipes/webshop/aml/compute.yml",
"chars": 544,
"preview": "# Azure ML Compute Cluster for WebShop Training\n#\n# Creates a GPU compute cluster with A100 GPUs for VERL training.\n# Au"
},
{
"path": "contrib/recipes/webshop/aml/jobs/webshop-qwen.yml",
"chars": 1354,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n# Azure ML command job for WebShop agent training with Qwen model.\n#\n# "
},
{
"path": "contrib/recipes/webshop/aml/run_webshop_aml.sh",
"chars": 5733,
"preview": "#!/usr/bin/env bash\n# Copyright (c) Microsoft. All rights reserved.\n\n# Runtime launcher script for WebShop agent trainin"
},
{
"path": "contrib/recipes/webshop/package.json",
"chars": 778,
"preview": "{\n \"name\": \"@example/webshop-training\",\n \"version\": \"0.0.0\",\n \"private\": true,\n \"scripts\": {\n \"build:headless\": \""
},
{
"path": "contrib/recipes/webshop/scripts/headless-runner.ts",
"chars": 14840,
"preview": "// Copyright (c) Microsoft. All rights reserved.\n\n/**\n * Headless WebShop Rollout Runner\n *\n * Continuously dequeues rol"
},
{
"path": "contrib/recipes/webshop/scripts/run_stack.sh",
"chars": 7066,
"preview": "#!/usr/bin/env bash\n# WebShop Training Stack Orchestrator\n#\n# Runs all three services (WebShop, AGL Coordinator, Runners"
},
{
"path": "contrib/recipes/webshop/server/.dockerignore",
"chars": 58,
"preview": "venv/\nwebshop/\n__pycache__/\n*.pyc\n*.pyo\n.git/\nactivate.sh\n"
},
{
"path": "contrib/recipes/webshop/server/requirements.txt",
"chars": 517,
"preview": "# WebShop Flask Server Dependencies\n# Python 3.8+ required\n\n# Flask server\nflask>=2.1.0\nflask-cors>=3.0.0\n\n# OpenAI Gym "
},
{
"path": "contrib/recipes/webshop/server/webshop_server.py",
"chars": 10203,
"preview": "# Copyright (c) Microsoft. All rights reserved.\n\n\"\"\"\nWebShop Flask Server\n\nA lightweight Flask server that wraps the Web"
},
{
"path": "contrib/recipes/webshop/src/agent/prompts.ts",
"chars": 1831,
"preview": "// Copyright (c) Microsoft. All rights reserved.\n\n/**\n * System prompts for WebShop agents.\n *\n * Shared between the UI "
},
{
"path": "contrib/recipes/webshop/src/agent/webshop-agent.ts",
"chars": 2399,
"preview": "// Copyright (c) Microsoft. All rights reserved.\n\n/**\n * WebShop Agent\n *\n * A ToolLoopAgent that navigates the real Web"
},
{
"path": "contrib/recipes/webshop/src/data/sample-tasks.ts",
"chars": 2547,
"preview": "// Copyright (c) Microsoft. All rights reserved.\n\n/**\n * Sample WebShop Tasks\n *\n * A collection of sample tasks for the"
},
{
"path": "contrib/recipes/webshop/src/environment/index.ts",
"chars": 109,
"preview": "// Copyright (c) Microsoft. All rights reserved.\n\nexport * from './types';\nexport * from './webshop-server';\n"
},
{
"path": "contrib/recipes/webshop/src/environment/types.ts",
"chars": 2570,
"preview": "// Copyright (c) Microsoft. All rights reserved.\n\n/**\n * WebShop Environment Types (Server-backed)\n *\n * Types for conne"
},
{
"path": "contrib/recipes/webshop/src/environment/webshop-server.ts",
"chars": 6427,
"preview": "// Copyright (c) Microsoft. All rights reserved.\n\n/**\n * WebShop Server Environment\n *\n * HTTP adapter for connecting to"
}
]
// ... and 346 more files (download for full content)
About this extraction
This page contains the full source code of the microsoft/agent-lightning GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 546 files (8.5 MB), approximately 2.3M tokens, and a symbol index with 3998 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.