# aiming-lab/agent0 architecture

> Architecture diagram of the GitHub repository aiming-lab/agent0, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aiming-lab/agent0
- Repository: https://github.com/aiming-lab/agent0

## Overview

#### Repository Scope
Agent0 Series is a research codebase for zero-data, tool-integrated self-evolution of language agents and vision-language agents. It contains three substantial implementation lines: Agent0-VL for solver/verifier visual reasoning, `Agent0/curriculum_train` for curriculum-agent co-evolution, and `Agent0/executor_train` for tool-using executor RL training on a newer vendored VeRL stack.

#### Primary Entry Points
- Agent0-VL supervised stages and RL launchers: `Agent0-VL/scripts/sft_stage1.sh`, `Agent0-VL/scripts/sft_stage2.sh`, `Agent0-VL/scripts/rl-agent0.sh`; evaluation begins at `Agent0-VL/scripts/evaluate.py`.
- Curriculum generation/training begins at `Agent0/curriculum_train/question_generate/question_generate.py` and `Agent0/curriculum_train/verl/trainer/main.py`, launched by `Agent0/curriculum_train/scripts/curriculum_train.sh`.
- Executor/tool RL begins at `Agent0/executor_train/main.py`; the main underlying PPO entry point is `Agent0/executor_train/verl/verl/trainer/main_ppo.py`.

#### Training Orchestration and RL Loop
The core control loop is distributed PPO/GRPO-style optimization: load prompts, generate trajectories, obtain rewards, compute advantages/losses, update actor/critic/reference roles, then checkpoint and repeat. Agent0-VL uses `Agent0-VL/verl/trainer/main_ppo.py`, `Agent0-VL/verl/trainer/ppo/ray_trainer.py`, and `Agent0-VL/verl/trainer/ppo/agent0_core_algos.py`; executor training uses equivalent upstream-style modules under `Agent0/executor_train/verl/verl/trainer/ppo/`.
Ray manages worker placement and RPC-style method dispatch through `Agent0-VL/verl/single_controller/ray/base.py` and `Agent0/executor_train/verl/verl/single_controller/ray/base.py`.

#### Generation, Agent Interaction, and Tools
Rollout workers abstract inference backends: Hugging Face, vLLM, and SGLang. Agent0-VL’s agent-specific trajectories are implemented in `Agent0-VL/verl/workers/rollout/vllm_rollout/agent0_trajectory.py` and `Agent0-VL/verl/workers/rollout/vllm_rollout/vllm_agent0_rollout_spmd.py`. Executor training adds asynchronous chat/server scheduling and multi-turn tool-agent loops in `Agent0/executor_train/verl/verl/workers/rollout/chat_scheduler.py`, `Agent0/executor_train/verl/verl/experimental/agent_loop/tool_agent_loop.py`, and `Agent0/executor_train/verl_tool/llm_agent/manager.py`.
Tool execution is a hard boundary between model output and external effects. The tool service exposes shell, code, search, SQL, sandbox, and vision tools via `Agent0/executor_train/verl_tool/servers/serve.py` and `Agent0/executor_train/verl_tool/servers/tools/`.

#### Rewards and Self-Evaluation
Rewards convert completed trajectories and tool observations into scalar learning signals. Agent0-VL contains Agent0-specific verification and reward management at `Agent0-VL/verl/utils/reward_score/agent0_verify.py` and `Agent0-VL/verl/workers/reward_manager/agent0.py`, reflecting its solver/verifier roles. General executor rewards are selected through `Agent0/executor_train/verl/verl/workers/reward_manager/registry.py`; task grading supports math, code, and sandbox-based validation under `Agent0/executor_train/verl/verl/utils/reward_score/`.

#### Models, Distributed Execution, and Checkpoints
Model adapters support Qwen/Llama and vision-language variants, with Transformers and Megatron implementations. Key boundaries are `Agent0-VL/verl/models/registry.py`, `Agent0-VL/verl/models/transformers/qwen2_vl.py`, and `Agent0/executor_train/verl/verl/models/mcore/qwen2_5_vl/model.py`. Training can use FSDP or Megatron workers; sharding managers synchronize training weights into inference engines (`Agent0-VL/verl/workers/sharding_manager/fsdp_vllm.py`, `Agent0/executor_train/verl/verl/workers/sharding_manager/megatron_sglang.py`). Checkpoint formats are backend-specific in `Agent0-VL/verl/utils/checkpoint/` and `Agent0/executor_train/verl/verl/utils/checkpoint/`.

#### Runtime and External Dependencies
The material runtime is Python/PyTorch on multi-GPU infrastructure, coordinated by Ray, with FSDP/Megatron parallelism and vLLM/SGLang inference. Optional external services include MCP-compatible tools, web search providers, code/sandbox executors, and a standalone evaluation/model API at `Agent0/executor_train/eval_service/app.py`. Curriculum training can initialize a vLLM service through `Agent0/curriculum_train/vllm_service_init/start_vllm_server_tool.py`.

Main entry points: [`Agent0-VL/verl/trainer/ppo/ray_trainer.py`](https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/verl/trainer/ppo/ray_trainer.py) (PPO trainer), [`Agent0/executor_train/verl/verl/trainer/main_ppo.py`](https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/verl/verl/trainer/main_ppo.py) (PPO trainer), [`Agent0/curriculum_train/verl/trainer/main.py`](https://github.com/aiming-lab/agent0/blob/main/Agent0/curriculum_train/verl/trainer/main.py) (Curriculum trainer), [`Agent0/executor_train/verl/verl/experimental/agent_loop/tool_agent_loop.py`](https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/verl/verl/experimental/agent_loop/tool_agent_loop.py) (Tool-agent loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vl["Agent0-VL"]
  node_vl_launch["SFT and RL launchers<br/>shell entrypoints<br/>[rl-agent0.sh]"]
  node_vl_eval["Evaluation<br/>[evaluate.py]"]
  node_vl_ppo["PPO trainer<br/>RL orchestration<br/>[ray_trainer.py]"]
  node_vl_rollout["Agent trajectories<br/>vLLM rollout"]
  node_vl_reward["Solver/verifier rewards<br/>reward manager<br/>[agent0.py]"]
  node_vl_models["VL model adapters<br/>model registry<br/>[registry.py]"]
end

subgraph group_curriculum["Curriculum training"]
  node_curr_questions["Question generation<br/>curriculum generator"]
  node_curr_launch["Curriculum launcher<br/>shell entrypoint"]
  node_curr_train["Curriculum trainer<br/>VeRL trainer<br/>[main.py]"]
  node_curr_vllm["Curriculum vLLM service<br/>inference service setup"]
end

subgraph group_executor["Executor training"]
  node_exec_entry["Executor RL entry<br/>training entrypoint<br/>[main.py]"]
  node_exec_ppo["PPO trainer<br/>RL orchestration<br/>[main_ppo.py]"]
  node_exec_rollout["Async rollout scheduler<br/>chat scheduler<br/>[chat_scheduler.py]"]
  node_agent_loop["Tool-agent loop<br/>multi-turn agent loop<br/>[tool_agent_loop.py]"]
  node_tool_manager["Tool manager<br/>tool dispatch<br/>[manager.py]"]
  node_tool_service{{"Tool service<br/>external-effects boundary<br/>[serve.py]"}}
  node_exec_reward["Task rewards and grading<br/>reward registry<br/>[registry.py]"]
end

subgraph group_runtime["Shared runtime"]
  node_ray["Ray controller<br/>distributed control plane<br/>[base.py]"]
  node_distributed["Distributed model execution<br/>FSDP/Megatron sharding<br/>[fsdp_vllm.py]"]
  node_checkpoints[("Checkpoints<br/>training state storage")]
end

node_vl_launch -->|"starts"| node_vl_ppo
node_vl_ppo -->|"generates trajectories"| node_vl_rollout
node_vl_rollout -->|"completed trajectories"| node_vl_reward
node_vl_reward -->|"scalar rewards"| node_vl_ppo
node_vl_ppo -->|"updates"| node_vl_models
node_vl_ppo -->|"saves"| node_checkpoints
node_vl_eval -->|"evaluates"| node_vl_models
node_curr_launch -->|"starts"| node_curr_train
node_curr_questions -->|"curriculum prompts"| node_curr_train
node_curr_train -->|"co-evolves"| node_curr_questions
node_curr_train -->|"uses generation service"| node_curr_vllm
node_exec_entry -->|"starts"| node_exec_ppo
node_exec_ppo -->|"dispatches prompts"| node_exec_rollout
node_exec_rollout -->|"schedules turns"| node_agent_loop
node_agent_loop -->|"tool calls"| node_tool_manager
node_tool_manager -->|"executes"| node_tool_service
node_tool_service -->|"observations"| node_agent_loop
node_agent_loop -->|"trajectories and outcomes"| node_exec_reward
node_exec_reward -->|"rewards"| node_exec_ppo
node_exec_ppo -->|"saves"| node_checkpoints
node_ray -->|"coordinates workers"| node_vl_ppo
node_ray -->|"coordinates workers"| node_exec_ppo
node_distributed -->|"syncs weights"| node_vl_rollout
node_distributed -->|"syncs weights"| node_exec_rollout

click node_vl_launch "https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/scripts/rl-agent0.sh"
click node_vl_eval "https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/scripts/evaluate.py"
click node_vl_ppo "https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/verl/trainer/ppo/ray_trainer.py"
click node_vl_rollout "https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/verl/workers/rollout/vllm_rollout/agent0_trajectory.py"
click node_vl_reward "https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/verl/workers/reward_manager/agent0.py"
click node_vl_models "https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/verl/models/registry.py"
click node_curr_questions "https://github.com/aiming-lab/agent0/blob/main/Agent0/curriculum_train/question_generate/question_generate.py"
click node_curr_launch "https://github.com/aiming-lab/agent0/blob/main/Agent0/curriculum_train/scripts/curriculum_train.sh"
click node_curr_train "https://github.com/aiming-lab/agent0/blob/main/Agent0/curriculum_train/verl/trainer/main.py"
click node_curr_vllm "https://github.com/aiming-lab/agent0/blob/main/Agent0/curriculum_train/vllm_service_init/start_vllm_server_tool.py"
click node_exec_entry "https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/main.py"
click node_exec_ppo "https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/verl/verl/trainer/main_ppo.py"
click node_exec_rollout "https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/verl/verl/workers/rollout/chat_scheduler.py"
click node_agent_loop "https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/verl/verl/experimental/agent_loop/tool_agent_loop.py"
click node_tool_manager "https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/verl_tool/llm_agent/manager.py"
click node_tool_service "https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/verl_tool/servers/serve.py"
click node_exec_reward "https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/verl/verl/workers/reward_manager/registry.py"
click node_ray "https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/verl/single_controller/ray/base.py"
click node_distributed "https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/verl/workers/sharding_manager/fsdp_vllm.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_vl_launch,node_vl_eval,node_vl_ppo,node_vl_rollout,node_vl_reward,node_vl_models toneBlue
class node_curr_questions,node_curr_launch,node_curr_train,node_curr_vllm toneAmber
class node_exec_entry,node_exec_ppo,node_exec_rollout,node_agent_loop,node_tool_manager,node_tool_service,node_exec_reward toneMint
class node_ray,node_distributed,node_checkpoints toneRose
```

## Components

### Agent0-VL

Visual solver/verifier training line.

- [SFT and RL launchers](https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/scripts/rl-agent0.sh): shell entrypoints · `Agent0-VL/scripts/rl-agent0.sh`
- [Evaluation](https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/scripts/evaluate.py): evaluation script · `Agent0-VL/scripts/evaluate.py`
- [PPO trainer](https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/verl/trainer/ppo/ray_trainer.py): RL orchestration · `Agent0-VL/verl/trainer/ppo/ray_trainer.py`
- [Agent trajectories](https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/verl/workers/rollout/vllm_rollout/agent0_trajectory.py): vLLM rollout · `Agent0-VL/verl/workers/rollout/vllm_rollout/agent0_trajectory.py`
- [Solver/verifier rewards](https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/verl/workers/reward_manager/agent0.py): reward manager · `Agent0-VL/verl/workers/reward_manager/agent0.py`
- [VL model adapters](https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/verl/models/registry.py): model registry · `Agent0-VL/verl/models/registry.py`

### Curriculum training

Question generation and co-evolution line.

- [Question generation](https://github.com/aiming-lab/agent0/blob/main/Agent0/curriculum_train/question_generate/question_generate.py): curriculum generator · `Agent0/curriculum_train/question_generate/question_generate.py`
- [Curriculum launcher](https://github.com/aiming-lab/agent0/blob/main/Agent0/curriculum_train/scripts/curriculum_train.sh): shell entrypoint · `Agent0/curriculum_train/scripts/curriculum_train.sh`
- [Curriculum trainer](https://github.com/aiming-lab/agent0/blob/main/Agent0/curriculum_train/verl/trainer/main.py): VeRL trainer · `Agent0/curriculum_train/verl/trainer/main.py`
- [Curriculum vLLM service](https://github.com/aiming-lab/agent0/blob/main/Agent0/curriculum_train/vllm_service_init/start_vllm_server_tool.py): inference service setup · `Agent0/curriculum_train/vllm_service_init/start_vllm_server_tool.py`

### Executor training

Tool-using RL on vendored VeRL.

- [Executor RL entry](https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/main.py): training entrypoint · `Agent0/executor_train/main.py`
- [PPO trainer](https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/verl/verl/trainer/main_ppo.py): RL orchestration · `Agent0/executor_train/verl/verl/trainer/main_ppo.py`
- [Async rollout scheduler](https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/verl/verl/workers/rollout/chat_scheduler.py): chat scheduler · `Agent0/executor_train/verl/verl/workers/rollout/chat_scheduler.py`
- [Tool-agent loop](https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/verl/verl/experimental/agent_loop/tool_agent_loop.py): multi-turn agent loop · `Agent0/executor_train/verl/verl/experimental/agent_loop/tool_agent_loop.py`
- [Tool manager](https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/verl_tool/llm_agent/manager.py): tool dispatch · `Agent0/executor_train/verl_tool/llm_agent/manager.py`
- [Tool service](https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/verl_tool/servers/serve.py): external-effects boundary · Serves shell, code, search, SQL, sandbox, and vision tools. · `Agent0/executor_train/verl_tool/servers/serve.py`
- [Task rewards and grading](https://github.com/aiming-lab/agent0/blob/main/Agent0/executor_train/verl/verl/workers/reward_manager/registry.py): reward registry · `Agent0/executor_train/verl/verl/workers/reward_manager/registry.py`

### Shared runtime

Distributed training and inference infrastructure.

- [Ray controller](https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/verl/single_controller/ray/base.py): distributed control plane · Places workers and dispatches RPC-style methods. · `Agent0-VL/verl/single_controller/ray/base.py`
- [Distributed model execution](https://github.com/aiming-lab/agent0/blob/main/Agent0-VL/verl/workers/sharding_manager/fsdp_vllm.py): FSDP/Megatron sharding · Synchronizes training weights into inference engines. · `Agent0-VL/verl/workers/sharding_manager/fsdp_vllm.py`
- **Checkpoints**: training state storage

## Connections

- SFT and RL launchers → PPO trainer: starts
- PPO trainer → Agent trajectories: generates trajectories
- Agent trajectories → Solver/verifier rewards: completed trajectories
- Solver/verifier rewards → PPO trainer: scalar rewards
- PPO trainer → VL model adapters: updates
- PPO trainer → Checkpoints: saves
- Evaluation → VL model adapters: evaluates
- Curriculum launcher → Curriculum trainer: starts
- Question generation → Curriculum trainer: curriculum prompts
- Curriculum trainer → Question generation: co-evolves
- Curriculum trainer → Curriculum vLLM service: uses generation service
- Executor RL entry → PPO trainer: starts
- PPO trainer → Async rollout scheduler: dispatches prompts
- Async rollout scheduler → Tool-agent loop: schedules turns
- Tool-agent loop → Tool manager: tool calls
- Tool manager → Tool service: executes
- Tool service → Tool-agent loop: observations
- Tool-agent loop → Task rewards and grading: trajectories and outcomes
- Task rewards and grading → PPO trainer: rewards
- PPO trainer → Checkpoints: saves
- Ray controller → PPO trainer: coordinates workers
- Ray controller → PPO trainer: coordinates workers
- Distributed model execution → Agent trajectories: syncs weights
- Distributed model execution → Async rollout scheduler: syncs weights
