Building Robot Agents on Open-Weight Models: A Practical Unified Runtime Framework
Robot agents—systems that translate natural language instructions into perception, planning, and physical actions—have advanced rapidly, yet the best-performing approaches often rely on closed-source frontier models. This article explains why running robot agents on open-weight models matters, and presents a practical layered runtime framework covering input standardization, action validation, context management, error recovery, structured skill primitives, data flywheel design, evaluation methodology, and cost optimization. It concludes with a phased rollout plan and a practical checklist for teams adopting this approach.
1. Background: Why Run Robot Agents on Open-Weight Models
Robot manipulation agents are systems that receive natural language instructions, combine camera feeds with robotic arm state, and progressively plan and execute manipulation actions. Over the past couple of years, the ability to complete tabletop tasks such as grasping, placing, and opening/closing in a zero-shot manner has improved significantly—but the most effective solutions largely depend on closed-source frontier models.
This dependency creates three practical problems.
First, weights are inaccessible. Researchers can only call the model through an API and cannot modify model parameters based on the interaction data their robots collect. Experience accumulates only at the level of prompts and external rules.
Second, inference costs are high. Large-scale experiments involve thousands or tens of thousands of inference calls, and per-call billing makes a full evaluation round expensive quickly, limiting iteration speed.
Third, the inference process is not controllable. Latency, output formats, and version updates are all decided by the provider, making it hard for research teams to reproduce earlier results.
Open-weight models precisely fill these gaps. They can be deployed on your own compute, fine-tuned on task-specific data, and their runtime trajectories can be fed back into training. But an open-weight model does not automatically become a good robot agent. It needs a supporting runtime framework that stitches perception, decision-making, and execution into a stable closed loop. This article focuses on how that framework layer should be designed.
2. Problem Breakdown: What Engineering Problems Must the Runtime Solve
Before designing anything, clarify the problems a robot agent encounters at runtime.
- Input standardization
Different robot platforms have different camera resolutions, coordinate frames, and joint naming conventions. The framework must normalize raw observations into a fixed structure—for example, images, end-effector pose, gripper state, and task text. Once the structure is unified, the upper-level decision logic can evolve independently of specific hardware.
- Action space constraints
Sending model outputs directly to hardware is risky. Actions must be restricted to pre-defined skill primitives, with parameter ranges checked—such as displacement limits, velocity limits, and workspace boundaries.
- State and history management
Multi-step tasks require remembering completed steps, failure reasons, and current object positions. History that is too long increases inference cost; too short, and the agent repeats actions. The framework must decide which information to keep and in what form.
- Error recovery
Grasp failures, dropped objects, and timeouts are common. The framework should categorize errors and return structured failure reasons to the model, rather than a free-form natural language description. Structured feedback lets the model correct its decisions against specific problems.
- Process logging
Every step’s observation, model output, and execution result should be fully recorded. These records serve both as debugging evidence and as training data for later stages.
These five points define the core responsibilities of a runtime framework. The design below is organized by layers.
3. Layered Design: Breaking the Agent into Replaceable Modules
A five-layer structure is recommended. Each layer does one thing, and modules communicate through well-defined data structures. This way, swapping models, changing robot platforms, or adjusting the action library only requires modifying the corresponding layer—everything else stays unchanged.
3.1 Model Access Layer
The access layer wraps the invocation interfaces of different open-weight models behind a unified API. Upper-level code only cares about “give it context, get structured output”—it does not care whether the underlying model is served locally or remotely.
The access layer must handle these differences:
- Differences in chat templates and special tokens
- Maximum context length and truncation strategies
- Sampling parameters such as temperature and max generation length
- Image input encoding methods
3.2 Context Assembly Layer
The context assembly layer decides what the model “sees.” Typical context includes the role description, the list of available skills, the current observation, recent history, and the task instruction.
The key design point for this layer is length control. Summarize history: keep full records for only the most recent steps, and compress earlier steps into a list of “completed subgoals.” This preserves task progress information while preventing unbounded context growth.
3.3 Decision Parsing Layer
Model output must be parsed into structured actions. It is recommended to require the model to output in a fixed format—for example, a JSON object—and retry a limited number of times when parsing fails.
Here is an illustrative action structure:
{"thought": "Gripper aligned with the cup, ready to close","skill": "grasp","args": {"target_id": "cup_01","force_limit_n": 8.0},"expected_result": "Object grasped with no slippage"}
After parsing, validation is mandatory: is the skill name on the whitelist, are all parameters present, and are numeric values within safe ranges? Outputs that fail validation should not go to the execution layer directly; instead, return an error message and let the model re-decide.
3.4 Execution Layer
The execution layer converts validated skill primitives into low-level control commands. It is the only layer that directly touches hardware and should carry the strictest safety responsibilities.
Common practices in the execution layer include:
- Setting global velocity and acceleration limits
- Defining forbidden-zone boundaries within the workspace
- Setting a timeout for each skill
- Providing a manual emergency-stop interface, with e-stop priority above any automated command
Execution results should be structured, containing at minimum: success or failure, error codes, a sensor feedback summary, and elapsed time.
3.5 Logging Layer
The logging layer writes the complete information for each step into storage. Its interaction with other layers is limited to receiving logs; it does not participate in decision-making, so that logging logic never affects the main flow.
Logging considerations are covered in Section 5.
Here is illustrative pseudocode for the main loop:
initialize(task_instruction, robot_config)history = []for step in 1..MAX_STEPS:obs = read_observation()context = build_context(instruction, obs, history)raw_output = model.generate(context)action, err = parse_and_validate(raw_output, skill_whitelist)if err:history.append(error_record(err))continueresult = execute(action)log_trajectory(step, obs, raw_output, action, result)history.append(summarize(action, result))if task_done(result, obs):break
Two design decisions in this pseudocode are worth noting. First, parse failures do not abort the task—the error is written into history so the model can correct itself on the next step. Second, a maximum step count is set to prevent the model from looping indefinitely and driving up costs.
4. Action Interface Design: Skill Primitives Are More Reliable Than Free-Form Output
The core risk in robot agents comes from the uncertainty of action outputs. Asking a model to directly output joint angles or continuous velocities is hard to validate and hard to interpret. A more robust approach is to define a set of skill primitives—such as grasp, place, move to a position, open drawer, press button. The granularity of primitives should be moderate: too fine and task step counts explode; too coarse and the model loses controllability.
Each skill should carry the following metadata:
- Name and natural language description
- Parameter list, including types, units, and value ranges
- Preconditions, such as “gripper must be empty”
- A set of failure codes, such as target not found, out of range, collision risk
Skill descriptions should be written concretely. For example, the “grasp” description should include graspable target types, grasp height range, and force limits. The clearer the description, the less the model fabricates parameters.
Failure code design is equally important. Unified error codes let the model make targeted corrections—for example, after receiving “target not in view,” the model will try adjusting its viewpoint instead of repeating the same action.
5. Data Flywheel: Feeding Interaction Experience Back into the Model
Another key value of the runtime framework is turning every interaction into reusable training data. This is exactly where open-weight models shine: closed-source APIs only give you inference results, while self-deployed models can directly absorb this experience.
5.1 Trajectory Structure
A complete interaction trajectory typically includes:
- Task instruction and scene identifier
- Observation summary for each step
- The model’s raw output and the parsed action
- Execution result and error codes
- Whether the task ultimately succeeded
It is recommended to store large data such as images in object storage, with trajectory files keeping only reference paths. This makes retrieval easier while keeping storage costs under control.
5.2 Data Filtering
Not all raw trajectories are suitable for training. When filtering, focus on three types of samples:
- Fully successful trajectories, used to reinforce correct behavior.
- Segments containing errors that were successfully corrected, used to learn error recovery.
- Outputs rejected due to parse failures; after manual or rule-based correction, these can be used to learn format constraints.
At the same time, filter out noisy samples—such as sensor anomalies, repetitive loops, and clearly out-of-bounds actions. If noisy samples mix into the training set, the model may learn bad manipulation habits.
5.3 Training Approaches
Common training paths include supervised fine-tuning and preference learning. Supervised fine-tuning uses successful trajectories as targets, teaching the model to imitate correct decisions; preference learning compares two outputs for the same state and learns which is more reasonable. The two can be used sequentially: the former builds basic capability, the latter refines judgment.
During training, keep in mind:
- Hold out a portion of trajectories as a validation set, so the model does not only perform well on training scenes
- Record the data source and training configuration for each version, for traceability
- Guard against overfitting to fixed object positions in a single scene
5.4 Iteration Cadence
A fixed-cycle iteration is recommended: collect a batch of trajectories, filter, train, validate on a unified evaluation set, then decide whether to deploy. Keep a baseline version for every round so changes can be quantitatively compared. Without a baseline, it is hard to tell whether a training round brought improvement or introduced regression.
6. Evaluation: Fair Comparison Matters More Than a Single Score
Evaluation is the key step in deciding whether an approach is deployable. Conclusions based on a single overall score rarely guide engineering decisions, because a total score cannot show where failures concentrate or whether costs are acceptable.
6.1 Evaluation Dimensions
Measure along at least four dimensions:
- Task success rate: completion ratio on a fixed task set.
- Average steps: number of decisions needed per task, reflecting efficiency.
- Cost per task: compute consumption for inference or API cost.
- Stability: variance in results when the same task is repeated multiple times.
All four metrics should be reviewed together. A solution with high success rate but runaway costs is hard to deploy at scale; a cheap but unstable one cannot be used in real settings either.
6.2 Fair Comparison Principles
When comparing approaches, keep the following conditions consistent:
- Use the same task set and initial scenes.
- Identical input information—do not give one side extra annotations or ground-truth state.
- Record model versions, decoding parameters, and runtime framework versions.
- Report real-robot and simulation results separately; do not mix them.
Only when these conditions hold are comparison results meaningful.
6.3 Real Robot vs. Simulation
Simulation environments make large-scale testing easy, but differ from real hardware in lighting, friction, and sensor noise. Real-robot testing offers fewer samples at higher cost, but is closer to actual deployment. A sensible approach: use simulation to screen approaches first, then validate key conclusions on real hardware. Advantages in simulation do not necessarily transfer to real robots, so real-robot results should be interpreted on their own.
7. Cost and Performance Optimization
Inference cost typically comes from three sources: input/output length per step, the number of decision steps, and retries after failures. Optimization should target all three simultaneously.
7.1 Reduce Wasted Steps
- Task decomposition: split long tasks into subgoals, checking completion for each subgoal separately.
- Early termination: end promptly when the task is detected as complete or impossible.
- Retry limits: set a maximum retry count for the same error; beyond that, escalate to a human.
7.2 Control Context Length
- Summarize history instead of keeping all raw outputs.
- Pass images only at critical steps; use structured state descriptions for the rest.
- Keep skill descriptions concise and avoid repetition.
7.3 Deployment and Inference Optimization
- Use quantization to reduce memory footprint, but confirm on the evaluation set that accuracy loss is acceptable.
- Batch concurrent requests to improve hardware utilization.
- Decouple the inference service from the control loop so network latency does not affect real-time performance.
7.4 Observability
Continuously monitor these metrics: request latency, parse failure rate, frequency of each error code, and average cost per task. When a metric goes abnormal, the problematic stage can be quickly located. This can be implemented with standard logging services and alerting systems.
8. Risks and Precautions
Robot agents are connected to the physical world, so risk management comes first.
- Action safety: all automated actions must pass validation and be constrained by velocity, force, and workspace limits.
- Human-robot collaboration: high-risk operations should include a human confirmation step.
- Emergency stop: the e-stop must be independent of agent logic and triggerable at any time.
- Data privacy: if scenes contain people or sensitive information, trajectory data must be anonymized before storage.
- Model uncertainty: the same input may yield different outputs; use multiple sampling or voting to reduce occasional errors.
9. Rollout Recommendations
If your team is ready to try this approach, proceed in phases.
Phase 1: Build the minimal closed loop. Choose a small set of fixed skills and simple scenes; implement the access, parsing, and logging layers, and ensure the main loop runs stably.
Phase 2: Establish an evaluation baseline. Define the task set and metrics, run repeated experiments in simulation, and record baseline data.
Phase 3: Introduce the data flywheel. Collect trajectories, complete filtering and one round of fine-tuning, and verify whether the new version outperforms the baseline on the unified evaluation set.
Phase 4: Expand and deploy. Add skills and scenes, gradually move to real hardware, and complete monitoring and safety mechanisms.
During implementation, use the following checklist:
- Are all action outputs validated against a whitelist and range checks?
- Are observation, output, and result fully recorded at every step?
- Are step limits and timeout mechanisms in place?
- Does evaluation use a unified task set with version information recorded?
- Is the emergency-stop mechanism independent and reliable?
