How verl-project/uni-agent works
Purpose and Entry Points
Uni-Agent is a Python framework for large-scale, long-horizon agent inference, evaluation, trajectory collection, and RL/SFT data generation. It separates agent harnesses, tasks, tools, sandbox infrastructure, and model serving. Primary runtime entry and orchestration layers are uni_agent/framework/entry.py, uni_agent/framework/framework.py, and uni_agent/framework/task_runner.py; runnable integrations live under examples/inference/ and examples/quickstart/training/.
Framework Orchestration
The framework loads task configuration, initializes distributed/runtime dependencies, routes task execution, and manages concurrent rollouts. uni_agent/framework/base.py defines framework-facing abstractions; uni_agent/framework/task_runner.py executes task instances; uni_agent/framework/multi_modal_postprocess.py processes model outputs beyond plain text. This is the boundary between training/inference drivers and the agent interaction stack.
Agent and Tool Layer
White-box harnesses implement a common agent contract and are selected through a registry: uni_agent/agents/base.py, uni_agent/agents/registry.py, and implementations such as uni_agent/agents/react/agent.py, uni_agent/agents/claude_code/agent.py, and uni_agent/agents/mini_swe_agent/agent.py. Agents invoke reusable tools—shell execution, file editing, completion, and submission—through uni_agent/tools/base.py, uni_agent/tools/shell.py, and uni_agent/tools/edit_file.py.
Gateway for External Harnesses and Model Calls
The Gateway makes model endpoints compatible with OpenAI- and Anthropic-style agent harnesses while preserving training-relevant token and session state. uni_agent/gateway/gateway.py handles gateway behavior, uni_agent/gateway/manager.py pools/manages sessions, and provider adaptation is isolated in uni_agent/gateway/adapters/openai.py and uni_agent/gateway/adapters/anthropic.py. Session codecs and types in uni_agent/gateway/session/codec.py and uni_agent/gateway/session/session.py convert request/response and tool-dispatch events into continuous, traceable trajectories.
Tasks, Rewards, and Data Preparation
Tasks provide the environment-facing contract, dataset preprocessing, instance routing, and reward calculation independently of an agent. Core extension points are uni_agent/tasks/base.py, uni_agent/tasks/config.py, and uni_agent/tasks/registry.py. SWE-Bench and SWE-reBench integrations implement task-specific preprocessing, execution context, and scoring in uni_agent/tasks/swe_bench/task.py, uni_agent/tasks/swe_bench/reward.py, and uni_agent/tasks/swe_rebench/task.py.
Execution Isolation and Infrastructure
Sandbox implementations decouple tool execution from orchestration. The shared contract and selection mechanism are uni_agent/sandbox/base.py and uni_agent/sandbox/registry.py; supported backends include local/Docker (uni_agent/sandbox/local.py, uni_agent/sandbox/docker.py) and remote elastic compute (uni_agent/sandbox/modal.py, uni_agent/sandbox/vefaas.py, uni_agent/sandbox/openyuanrong.py). Modal and Volcengine veFaaS are material external services for isolated, scalable agent environments.
Trajectory Integrity and Operational Interfaces
Session-aware logging and redaction preserve correlation among gateway events, tools, sandbox activity, rewards, and training trajectories: uni_agent/logging/context.py, uni_agent/logging/session.py, and uni_agent/logging/redaction.py. The optional Lark chat application is a separate interactive integration, entered via app/lark_chat/main.py and event handling in app/lark_chat/listener.py, rather than the core framework runtime.
Components 19
Framework Runtime
- Runtime entry
uni_agent/framework/entry.py - Framework orchestrator · Loads configuration, initializes runtime dependencies, and coordinates rollouts.
uni_agent/framework/framework.py - Task runner
uni_agent/framework/task_runner.py - Multimodal postprocess
uni_agent/framework/multi_modal_postprocess.py
Agent Interaction
- Agent registry
uni_agent/agents/registry.py - Agent contract
uni_agent/agents/base.py - Agent harnesses
uni_agent/agents/react/agent.py - Agent tools
uni_agent/tools/base.py - Model gateway · Provides OpenAI- and Anthropic-style model interfaces with trajectory state.
uni_agent/gateway/gateway.py - Gateway sessions
uni_agent/gateway/manager.py - Provider adapters
uni_agent/gateway/adapters/openai.py
Tasks & Evaluation
- Task registry
uni_agent/tasks/registry.py - Task contract
uni_agent/tasks/base.py - SWE-Bench tasks
uni_agent/tasks/swe_bench/task.py - Reward scoring
uni_agent/tasks/swe_bench/reward.py
Isolated Execution
- Sandbox registry
uni_agent/sandbox/registry.py - Sandbox backends · Runs tool actions in local, container, Modal, or veFaaS environments.
uni_agent/sandbox/docker.py
Trajectory Operations
- Session logging · Preserves and redacts cross-layer session traces.
uni_agent/logging/session.py - Lark chat app · Separate interactive integration outside the core runtime.
app/lark_chat/main.py
Connections 22
- Runtime entry → Framework orchestrator: starts
- Framework orchestrator → Task runner: orchestrates
- Framework orchestrator → Task registry: selects task
- Task registry → Task contract: implements
- Task contract → SWE-Bench tasks: specializes
- Task runner → Agent registry: selects agent
- Agent registry → Agent contract: resolves contract
- Agent contract → Agent harnesses: implemented by
- Agent harnesses → Model gateway: requests model calls
- Model gateway → Gateway sessions: manages state
- Model gateway → Provider adapters: adapts providers
- Agent harnesses → Agent tools: invokes
- Agent tools → Sandbox registry: executes through
- Sandbox registry → Sandbox backends: selects backend
- Task runner → Multimodal postprocess: processes outputs
- Task runner → Reward scoring: evaluates
- SWE-Bench tasks → Reward scoring: defines scoring
- Model gateway → Session logging: records sessions
- Agent tools → Session logging: records actions
- Sandbox backends → Session logging: records execution
- Reward scoring → Session logging: records outcomes
- Lark chat app → Model gateway: interactive model access