Agentic Policies: A Tutorial
Agentic policies can complete general-purpose manipulation tasks without any additional training or fine-tuning. They pair an off-the-shelf language model with a harness that the designer builds around the model to connect it to the robot. The model then acts in a closed loop: it decides what to sense or how to move, observes the result, and decides again.
Have the model files? Load them from a folder
The folder is copied into this browser, so nothing downloads. Your browser may say "upload", but the files stay on your computer. To make the folder once and share it:
This page is the paper's running example, live. Every cell runs in your browser and can be edited; Shift+Enter runs a cell, and running a cell first runs the cells it needs that haven't run yet. Setup code is folded away; open it to see everything that runs. Runs here can differ from the paper's, and between browsers and computers: the paper's results come from the downloaded script on a GPU.
1 Introduction
This tutorial is for designers who want to build an agentic policy. We explain how these policies work and what the designer must provide, and we build a working example step by step. We begin by defining an agentic policy, describing the loop that it runs, and listing what the designer must provide. We then assemble these pieces into a minimal implementation, work through the paper's three challenges (grounding, learning and safety), and end with a version of the task for you to solve yourself.
We use one running example throughout: Push-T (Chi et al., 2023). A robot must push a T-shaped block across a table until the block matches a goal pose. In these boxes we build an agentic policy for Push-T, one step at a time. In order, the code of Steps 1 to 6 forms one script that runs an episode of this task.
Step 1: Install
In the paper this step installs the simulator and the model libraries with pip. Here they are already
loaded in your browser, as stand-ins: the code below is the paper's, word for word, and its
torch and transformers calls go to the model picked at the top of the page.
Step 2: Push-T setup
We create the simulator and start an episode from the initial state fixed by SEED. The robot
is a disc, the arena is 512 \times 512 pixels, and all positions are in pixels.
frames collects the rendered frames of the episode, and block returns the
position of a point on the block (by default its centre of mass).
The simulator accepts one command: a target position for the robot. We wrap this command in two motion
primitives. goto moves the robot straight to a point, and approach first circles
around the block, so that the robot reaches a point next to the block without bumping into it. These two
functions are the robot's API in our example.
2 What Is an Agentic Policy?
We define an agentic policy as a system with two parts. The first is a model: a general-purpose language or vision-language model that makes the decisions, and whose weights are fixed and are not trained for the robot or the task. The second is a harness: everything that the designer builds around the model to connect it to the robot. The harness determines what the model observes, what actions it can invoke, and what is retained.
Critically, the model acts in a closed loop: it decides what to sense or how to move, observes the result, and decides again. Agentic policies do not call the tools in a fixed sequence chosen by the designer; the model decides which tools to call, and in what order, while the policy runs.
Several names are in use for parts of this space, including code as policies (Liang et al., 2023), agent as policy (Jia et al., 2026), LLM as policy (Zhang et al., 2026), robot-use agent (Chu et al., 2026) and agentic manipulation policy (Chen et al., 2026). We use agentic policy as the umbrella term. All of them rely on a model with fixed weights acting through tools that the designer provides. This stands in contrast to vision-language-action models, which are trained end-to-end on robot data to map images and language directly to motor commands (Brohan et al., 2023; Kim et al., 2024; Black et al., 2024).
3 How Do Agentic Policies Work?
An agentic policy runs like a conversation loop between a model and a robot. The model reads the task and its prompt, together with what it has done and observed so far, and writes an action. The action is executed: typically it senses the scene or moves the robot. The result (an observation) is handed back to the model, which then writes the next action. The loop ends when the model declares the task complete, or when a budget set by the designer runs out. One run of this loop is an episode.
We write an agentic policy as
where \pi is the off-the-shelf model with fixed weights and k = 0, 1, 2, \ldots counts the model's decisions within the episode. The task \tau is given by the user in natural language. The prompt \rho (the system prompt) is provided by the designer. The context h_k is everything the model has done and observed so far in this episode, starting from an initial context h_0. The output a_k \in \mathcal{A} is the next action: a block of code or a tool call. We write \sim because the action is sampled: given the same inputs, the model may write a different action each time.
The harness is everything else that the designer provides, and it has three parts: the prompt, the tools, and the runtime. The tools \mathcal{T} are the functions that the model's actions call to sense the scene and move the robot. The runtime is the program that runs the loop. The tools don't appear in the equation because the model never reads their implementation: it reads their descriptions, which are part of the prompt, and what they return, which becomes part of the context.
Model
The designer selects the model \pi.
The designer can trade off between a smaller, faster model and a larger model with greater reasoning capabilities. Many models also expose a setting for how much they reason before answering; more reasoning takes time, but could improve the answer. The model can be hosted locally or remotely, and it must write its actions in a form that the runtime can execute.
Step 3: The model
Our model is LittleLamb-ToolCalling, an open-weight language model with 0.3 billion
parameters (the menu at the top also offers Qwen3-4B). It sits at the small and fast end of the tradeoff,
and we switch its reasoning off. pi is the one function through which we query the model. Its
inputs are a task, a prompt, a context, and the tools whose descriptions the model reads; its output is the
text that the model writes.
How the model runs in your browser
On this page torch and transformers are stand-ins (in
runtime.py, below). The tokenizer keeps the messages and tools, and
model.generate builds the same prompt with the same chat template and waits for the model
picked at the top of the page: WebLLM for Qwen3-4B, Transformers.js for LittleLamb. The menu decides
the model; MODEL names the paper's. torch.manual_seed seeds the sampling, so a
run repeats on this page, but the browser's random numbers are not torch's, so your run differs from the
paper's.
Tools
The designer specifies the tools \mathcal{T}.
The tools should be the model's only connection to the robot. Some tools sense (detect an object, capture an image, read a force sensor). Some move the robot (go to a pose, close the gripper, run a learned policy). Others do neither, such as calling another model or declaring the task complete. Each tool has two parts: a description that the model reads, and an implementation that runs when the tool is called. Because the model never reads the implementation, the description should make clear what the tool does, how precise it is, what preconditions it has, and what else it changes.
Step 4: The tools
We give the model three tools. push_block and rotate_block move the robot so that
the block translates or rotates by a requested amount, and done declares the task complete.
Each tool is a Python function: its docstring is the description that the model reads, and its body is the
implementation.
Every tool (besides an accepted done) returns the same kind of observation, written by
observe: the block's remaining position error and angle error, whether each is within the
tolerance TOL, and the correction that would remove it. complete checks whether
both errors are within tolerance.
The first tool's implementation calls the robot's API from Step 2: the robot moves to a point behind the block and pushes the block along the requested direction.
rotate_block pushes one end of the bar of the T sideways. done is refused while an
error is outside tolerance, so the model cannot end the episode by wrongly declaring the task complete. By
contrast, push_block and rotate_block are refused once both errors are within
tolerance, and their message tells the model to call done; without it, our small model rarely
calls done.
Prompt
The designer writes the system prompt \rho.
The prompt tells the model its role, documents the tools, and states any rules for operating the robot. Rules in the prompt guide the model, but they are not guarantees. The prompt should be task-invariant: the policy uses the same prompt for every task it attempts. Information about the task at hand belongs in the task \tau, which the user writes.
Step 5: The prompt
Our prompt states the model's role, how to use the tools, and when to declare the task complete. It does not
state the task: the task is tau in Step 6, which is passed to pi separately. Our
small model needs one change of layout: pi writes the task as the first line of the system
message, above the prompt, and the user messages carry the observations.
We don't type the tool descriptions a second time. Inside pi, each tool's signature and
docstring are converted into the format this model was trained to read, and added to the system message.
For done, the model reads:
Runtime
The designer provides the runtime.
The runtime is the program that runs the loop. At each decision it gives the model the task, the prompt and the context, and receives an action. It executes this action using the tools, and appends the action and what it returns to the context. It ends the episode when the model declares the task complete or the budget runs out. Unlike a tool, the runtime is not something the model chooses to call: it runs at every decision, and the model should not be able to change it.
Step 6: The runtime
execute reads the tool call in the text that the model wrote, calls that tool, and returns
what the tool returns. If the text is not a valid call, or the tool raises an exception, the error message is
returned as the observation.
The loop gives the model the task tau, the prompt and the context, executes the action, and
appends the action and its observation to the context h. The episode ends when
done is accepted, or after BUDGET decisions. At the end the runtime prints the
goal coverage, the fraction of the goal region that the block covers (higher is better), and saves
the episode, which you can replay on the right.
Two lines of the runtime are concessions to our small model. The context starts with one observation, and
the model reads only the latest one, h[-1:]. We return to these choices under Context, below.
Actions
The policy generates its actions a \in \mathcal{A}.
Each action is a block of code or a tool call, written by the model against the tool set. The model can go further and write tools of its own, such as a routine for a grasp it uses often; saved for later episodes, such an action is a skill. Executing an action takes time: it may loop, read sensors and command many motions before it returns. So we distinguish the agent actions a_k written by the model from the robot actions u_t sent to the robot at each control step t. The two run on different clocks. While the model writes, no new robot actions are issued, so each agent action should leave the robot in a state where it can safely wait.
The first action of your run, a_0:
In this minimal example every action is one tool call. In the paper's run the first action is
rotate_block with deg -150: the model copied the angle from the first observation,
and the tool limited the rotation to 60 degrees. Executing that one agent action sent 48 robot actions
u_t to the simulator: six calls to goto of 8 control steps each. The step
counter on the right counts them.
Context
The policy collects its context h.
The model does not directly observe the scene. It observes only what the runtime gives it, which is chiefly what its actions return. Executing a_k returns an observation o_{k+1}, and both are appended to the context:
The observation may contain object positions from a perception tool, an image, a return value, or an error message. The runtime decides which part of the context the model reads at each decision. For now the initial context h_0 is empty; Challenge 2 adds long-term memory.
Before the first decision, the runtime places a first observation in the context. After the first decision of your run, the context holds three entries: the first observation, the action, and the observation that it returned.
Compare the two observations. Each tool disturbs the error that the other one reduces, and the model learns
how large this disturbance is only from the next observation. At its next decision the model reads only the
latest observation: given all of h, our small model gets confused and repeats its previous
action.
4 Challenge 1: Grounding
The model reasons in text, and the robot runs on sensor data and low-level actions. Grounding converts between the two, in both directions, and it passes through the tools: the scene reaches the model only through what the tools return, and the model moves the robot only by calling them. Tools that do more of the grounding are easier for the model to use, but the designer must engineer each of them, and they limit what the policy can observe and do.
How Does the Model See?
Our observe reads the block pose directly from the simulator. A robot with a camera must first
recover this pose from its sensor data. The sketch below is one way to do so; each numbered step is a choice
for the designer. It is pseudocode and does not run.
# Perceptual grounding: from camera images to the text the model reads.
# Each step is a choice of the designer.
def describe_scene(names=("T-shaped block", "goal region")):
rgb, depth = camera.read() # 1. color and depth images
# 2. Pixels to 3D points in the robot frame. K: camera intrinsics.
# cam_pose: the camera's pose in the robot frame (from calibration).
points = to_points(depth, K, cam_pose)
objects = []
for name, mask in segment(rgb, names): # 3. links a name to pixels
p = points[mask] # the object's 3D points
objects.append({"name": name,
"pose": fit_pose(p, name), # 4. its state
"size": extent(p),
"affordances": affordances(name, p)})
relations = relate(objects) # 5. e.g., "block near goal"
o = {"objects": objects, "relations": relations}
return json.dumps(o) # 6. the observation o
Our observe is the special case that skips steps 1 to 3 and 5: it reads the poses of the block
and the goal (step 4), and returns only their differences, as the corrections that the tools take (step 6).
How Does the Model Act?
A tool such as "move the block to the goal" is easy for the model to call, but the designer must engineer how
the robot acts on it. A tool such as goto can produce any motion, but the model must get every
number right. The tools of Step 4 sit in the middle: the model closes the loop by reading the errors and
choosing which one to correct. move_block_to_goal moves this loop into one task-level tool,
with the model's choice replaced by a fixed rule: correct the angle first, then the position.
The loop of Step 6, unchanged:
In the paper this policy completes 23 of 24 episodes (seeds 0 to 23), most of them in three decisions, against 13.3 decisions with the tools of Step 4. The decisions did not disappear: the rule that makes them is now code that the designer wrote and must maintain. And the policy can only do what the tool offers: it cannot rotate the block in place, or move it anywhere but the goal.
How Does the Policy Transfer?
The model reads the description of a tool, never its implementation, so the designer can change how a tool
moves the robot without changing anything the model reads. This is what transfer to a new robot asks of
push_block and rotate_block. Below is a second rotate_block: the robot
pushes the other half of the bar from below, in the opposite direction, which rotates the block the same way.
The docstring is the same word for word; only the lines marked changed differ.
In the paper the model's calls do not change: it still copies rotate_block_by_deg. The policy
does: it ends 18 of 24 episodes in 18.5 decisions on average, against 24 of 24 in 13.3. The new push shifts the
block differently, so near the goal each correction disturbs the other more. The description still holds, but
it does not state everything the motion does, and a designer who changes the body of a tool must test the
policy again.
5 Challenge 2: Learning
The weights of the model are fixed, so an agentic policy learns only by changing what the model reads. The only part of the context that persists between episodes is the initial context h_0: the long-term memory. One function stores an entry, one retrieves entries, and the runtime gives what is retrieved to the model. The model follows what it reads, so an entry that improves one decision can mislead another.
What Does the Policy Store?
store_memory saves one piece of user feedback as an entry of a JSON file. This file is
h_0. Each entry is stored under a name that states when it is relevant (for example
angle). Here the file lives in your browser's Python, until you reload the page.
How Does the Policy Retrieve?
Reading all of h_0 at every decision does not scale, and even one entry read at the
wrong time can stop the policy: told at every decision to "prioritize rotating the block over pushing", our
model rotates at almost every decision and no longer completes the task. load_memory queries
with the latest observation and matches exactly: the errors give the name of the situation (far,
angle, position or complete), and it returns the entry stored under
that name, or an empty text.
Who Stores and Retrieves?
Storage and retrieval can be tools that the model calls, or steps that the runtime runs at fixed points. Our small model never calls a retrieval tool, so the runtime does both: it stores the feedback before the episode, and before every decision it places the retrieved entry before the latest observation, for that decision only.
In the paper the feedback leaves the success rate unchanged (24 of 24 episodes) and cuts the decisions from 13.3 to 8.4 on average. Try a wrong entry, or one that is given at every decision, and watch the model follow it just as closely. Note what the policy itself did not do: the user wrote the entries, the designer named the situations, and the runtime decided when to store and retrieve.
6 Challenge 3: Safety
The model is a black box whose decisions can be neither predicted nor fully explained, and each action can pass a check while a sequence of them still leads somewhere unsafe. Safety therefore has to be handled inside the loop, by the model, and around it, in code that the model cannot change. We add a keep-out region to Push-T: a disc of radius 40 px centred at (200, 100) that the block must never enter. The robot itself may enter it.
How Does the Model Know if It Is Safe?
The model knows of a hazard only when a tool reports it or the prompt states it. clearance
measures the distance from the outline of the T to the region, negative once inside; every observation now
carries it, and a rule appended to the prompt says the block must never enter.
The loop of Step 6, unchanged:
This does not keep the block out. In the paper's run (seed 0) the first action leaves the block 27 px inside the region while its centre of mass is still 48 px outside. The browser's model samples differently, and on seed 0 it misses the region; on seed 22 it rotates the block 18 px into the region, then 32 px, before carrying it out. Your run may differ. A rule in the prompt is guidance; a rule in code is a constraint. Every rule that must hold belongs in code, stated in the prompt too, with what it constrains reported in every observation.
What Does the Policy Do When It Is Unsafe?
The model can only act through its tools, so a way to stop must be one of them. stop ends the
episode with the model's reason. Before each decision the runtime checks the clearance, and if the block is
inside the region it places a warning before the latest observation.
The warning comes only after an observation reports the block inside, so it does not keep the block out; a
block that enters and leaves during one rotation is never reported. A stop that the model calls
is a request. A stop that the runtime enforces does not depend on the model, and a limit that must hold during
a motion belongs in the tool or the robot's API, which can check it at every control step.
How Does the User Know if the Policy Is Safe?
The context records every action and observation, but these logs are long. One more call to the model, after
the episode, summarizes the record for the user. The facts on which safety depends are computed in code from
h, so that the model only puts them into words. Given the raw record alone, the paper's model
writes reports that sound plausible but that the record does not support.
The record shows what the policy did, not why, and a hazard appears in it only if a tool reported it. Treat the record and the report as evidence, not as a certificate of safety.
7 Your Turn: Push-A
The same arena, the same robot and the same API, but the block is now an A. Your job is the harness: decide
what the model should observe, write tools that move the A, and write the prompt. The runtime from Step 6
works unchanged once you have programmed observe, T, and rho.
Some things to think about:
- Which of the T's tools still work?
push_blockonly uses the centre of mass, butrotate_blockpushes the T's bar at points that are empty space on an A. - Where can the robot push to turn an A? Its feet, its apex, the crossbar?
- What should the descriptions say, so that a 0.3B model calls the right tool with the right numbers?
- Does the T's observation still tell the model what it needs? Are its tolerances right for an A?
One way to do it
Then run the loop of Step 6 with your harness:
What this page loads before the first cell
Two files stand in for what the paper's code gets from pip. pusht.py is gym-pusht's simulator
(same physics and start poses) without gymnasium, pygame or OpenCV, plus the A. runtime.py
sends prompts to the model on this page, turns docstrings into tool descriptions as the tokenizer does,
and keeps episodes for replay. Python itself runs in your browser with Pyodide.