Run the agent
This is the main event. We:
- Enter the
DaytonaAsyncComputercontext manager, which starts the sandbox's computer-use processes (Xvfb, window manager, VNC). - Start a session recording.
sandbox.computer_use.recording.start(...)returns a handle we need later to stop and download. - Build the
Agentwith a single tool,ComputerTool(computer=computer), and run it withRunner.run(...)inside atrace(...)block so the run shows up in the OpenAI traces dashboard. - In a
finallyblock, stop the recording and download it locally, using the filename Daytona reports (currently an.mp4).
max_turns=50 is a generous ceiling for a form this size; a good run will come in well under that.
python
async with DaytonaAsyncComputer(sandbox) as computer:
recording = await sandbox.computer_use.recording.start("form-fill")
print(f"Recording started: {recording.id}")
try:
with trace("Daytona form-fill demo"):
agent = Agent(
name="Form filler",
instructions=INSTRUCTIONS,
tools=[ComputerTool(computer=computer)],
model="gpt-5.4",
)
result = await Runner.run(agent, TASK, max_turns=50)
print(f"\n--- Final output ---\n{result.final_output}")
finally:
stopped = await sandbox.computer_use.recording.stop(recording.id)
print(f"\nRecording stopped: {stopped.file_name} ({stopped.status})")
local_recording_path = Path(stopped.file_name).name
await sandbox.computer_use.recording.download(recording.id, local_recording_path)
print(f"Recording downloaded to: {local_recording_path}")text
Recording started: de5b8077-352e-41b0-b2da-165ede8cbca0
--- Final output ---
DONE
Recording stopped: de5b8077-352e-41b0-b2da-165ede8cbca0_form-fill_20260419_161419.mp4 (completed)
Recording downloaded to: de5b8077-352e-41b0-b2da-165ede8cbca0_form-fill_20260419_161419.mp4