How aiming-lab/agent0 works
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: ray_trainer.py PPO trainer · main_ppo.py PPO trainer · main.py Curriculum trainer · tool_agent_loop.py Tool-agent loop
Components 20
Agent0-VL
Visual solver/verifier training line.
- SFT and RL launchers
Agent0-VL/scripts/rl-agent0.sh - Evaluation
Agent0-VL/scripts/evaluate.py - PPO trainer
Agent0-VL/verl/trainer/ppo/ray_trainer.py - Agent trajectories
Agent0-VL/verl/workers/rollout/vllm_rollout/agent0_trajectory.py - Solver/verifier rewards
Agent0-VL/verl/workers/reward_manager/agent0.py - VL model adapters
Agent0-VL/verl/models/registry.py
Curriculum training
Question generation and co-evolution line.
- Question generation
Agent0/curriculum_train/question_generate/question_generate.py - Curriculum launcher
Agent0/curriculum_train/scripts/curriculum_train.sh - Curriculum trainer
Agent0/curriculum_train/verl/trainer/main.py - Curriculum vLLM service
Agent0/curriculum_train/vllm_service_init/start_vllm_server_tool.py
Executor training
Tool-using RL on vendored VeRL.
- Executor RL entry
Agent0/executor_train/main.py - PPO trainer
Agent0/executor_train/verl/verl/trainer/main_ppo.py - Async rollout scheduler
Agent0/executor_train/verl/verl/workers/rollout/chat_scheduler.py - Tool-agent loop
Agent0/executor_train/verl/verl/experimental/agent_loop/tool_agent_loop.py - Tool manager
Agent0/executor_train/verl_tool/llm_agent/manager.py - Tool service · Serves shell, code, search, SQL, sandbox, and vision tools.
Agent0/executor_train/verl_tool/servers/serve.py - Task rewards and grading
Agent0/executor_train/verl/verl/workers/reward_manager/registry.py
Shared runtime
Distributed training and inference infrastructure.
- Ray controller · Places workers and dispatches RPC-style methods.
Agent0-VL/verl/single_controller/ray/base.py - Distributed model execution · Synchronizes training weights into inference engines.
Agent0-VL/verl/workers/sharding_manager/fsdp_vllm.py - Checkpoints
Connections 24
- 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