How nousresearch/atropos works
To illustrate Atropos’s architecture accurately, think of it as a microservice-based RL framework that decouples three roles: 1) environment services, 2) a central trajectory API (“run-api” server), and 3) trainers/inference engines. Use the file tree and README to identify how code modules map to these roles, then represent them as distinct components with clear interfaces.
Main components
• Core Library (atroposlib/)
• atroposlib/api: Trajectory server client & server utils
• atroposlib/cli: CLI entrypoints (run-api, serve, process, view-run, sft/dpo-gen)
• atroposlib/envs: BaseEnv classes, reward functions, server handling, and front-end visualization
• atroposlib/utils & type_definitions: Shared helpers (config, I/O, metrics, batching)
• Environment Microservices (environments/)
• Each script (e.g. gsm8k_server.py, blackjack_local_server.py, tool_calling_server.py, rlaif_server.py, etc.) implements a BaseEnv subclass
• Local servers launched via CLI “serve”: communicate asynchronously with the central API
• Trajectory API Server (run-api)
• Central service that environments POST rollout data to, and trainers pull batches from
• Exposed via atroposlib/api/server.py
• Trainer & Inference Engines (external)
• Example trainer (example_trainer/) or third-party tools (Axolotl plugin) implement RL loop
• Inference-agnostic: can call OpenAI, vLLM, SGLang via atroposlib/api/utils
• Debug & Visualization Tools
• process subcommand: runs inference only, outputs JSONL + HTML via atroposlib/frontend
• view-run: Gradio UI for batch inspection
• atropos-sft-gen / atropos-dpo-gen: offline data generation
Interactions and data flows
• Environment → Trajectory API: environments asynchronously POST “step” and “episode” messages
• Trainer ← Trajectory API: trainers pull batched rollouts for learning
• Environment ↔ Inference Servers: each environment may call LLM endpoints per step
• CLI tools ↔ Central API: run-api, process, view-run, atropos-sft-gen interact with the API or run environment locally
• Telemetry → WandB or local logs: reward metrics and rollout statistics
Architectural patterns
• Microservice pattern: each environment runs as an independent service
• Publish/subscribe or queuing model: environments publish to central API, trainers subscribe
• Plugin/abstraction layers: atroposlib/api abstracts any OpenAI-compatible provider
• Async & decoupled: environments don’t block on trainer updates, support heterogeneous group sizes
Layer in key technologies
• Python 3.10+, FastAPI / Uvicorn (likely for run-api server)
• HTTP/REST or WebSocket interfaces between services
• YAML/CLI configs via BaseEnvConfig (CONFIG.md)
• JSONL + static HTML for offline diagnostics
• WandB for experiment tracking
• Docker (optional) for code_execution_server environments
• It’s better to show each environment script as an independent node
• Common utilities under “atroposlib/utils” rather than detail every file
• Async RL loop: Inference → Environment → Trajectory API → Trainer → updated policy back to Inference