DoublewordDoubleword

Daytona

Building autonomous coding agents requires solving two distinct infrastructure bottlenecks: cost-effective AI reasoning and secure code execution. Doubleword provides the inference engine, generating code via high-throughput, open-model async APIs. Daytona provides the execution environment, instantly running that untrusted AI-generated code inside secure, ephemeral sandboxes that allow you to safely scale hundreds of concurrent agent workflows.

This architecture shines for autonomous background workflows. When an agent is working unsupervised, combining Doubleword and Daytona gives you three massive advantages:

  1. Absolute Security (Isolation): Background agents run unsupervised. If an agent decides to pip install a malicious package or fire off a destructive shell command, it happens inside an isolated, ephemeral Daytona sandbox. It never touches your actual machine or infrastructure.
  2. Massive Parallelism: Doubleword is built for high-throughput async work. You can ask it to generate a thousand unique attempts at a coding problem overnight, and in the morning, Daytona can instantly spin up a thousand sandboxes to test them all in parallel and keep the best result.
  3. Cheap Auto-Healing: An agent writes code, runs it, reads the error, and tries again. A ten-step debugging loop on a frontier realtime model gets expensive fast. On Doubleword's async tier, each call costs pennies, allowing the agent to iterate endlessly until it gets it right.

You can see where those pennies come from in the per-token rates:

ModelInputOutput
GPT-5.6 (OpenAI)*$5.00$30.00
Claude Opus 4.8 (Anthropic)*$5.00$25.00
GLM-5.2 on Doubleword, async$0.70$2.25

(Prices are per million tokens. *Anthropic and OpenAI figures are realtime API rates.)

The Architecture: Zero-Infrastructure Agents

Daytona doesn't ship a model of its own; you bring the model via Doubleword. Because Doubleword is fully OpenAI-compatible (and Anthropic-compatible if that's your thing), your agent simply points a standard client at Doubleword to write a script, and then hands that script to Daytona to execute.

The sandbox returns the output. If a run fails, the agent reads the error and tries again. Your own machine stays completely out of the loop. A sandbox persists until you stop or delete it, meaning you can throw it away after a one-off job or keep it around to hold state across complex, multi-step agent workflows.

Prerequisites

You need Python 3.10 or newer, along with a Doubleword API key and a Daytona API key. Set both in your shell:

export DOUBLEWORD_API_KEY="your-doubleword-key"
export DAYTONA_API_KEY="your-daytona-key"

Install

pip install daytona openai

Configure

You need two clients: one for the inference, one for the execution. The Doubleword client is the standard OpenAI client pointed at Doubleword's base URL, while the Daytona client automatically reads DAYTONA_API_KEY from your environment.

import os
from openai import OpenAI
from daytona import Daytona

llm = OpenAI(base_url="https://api.doubleword.ai/v1",
             api_key=os.environ["DOUBLEWORD_API_KEY"])

daytona = Daytona()

1. The Basic Loop: Think Cheaply, Execute Safely

Give Doubleword a task, let it write a script, and then run that script securely in a sandbox. Because a background agent isn't waiting on a human in real-time, the model calls route through the async tier.

You simply set service_tier="flex" and background=True, submit the job, and poll until it is ready. The Flex tier takes about a minute to reach its first token, runs at massive throughput, and costs a fraction of realtime inference. Finally, code_run hands back the sandbox output in .result and a status in .exit_code.

import re
import time

def write_code(task: str) -> str:
    job = llm.responses.create(
        model="Qwen/Qwen3.5-397B-A17B-FP8",   # any model on your Doubleword account
        instructions="You are a Python coding assistant. Return one runnable script and nothing else.",
        input=task,
        service_tier="flex",    # async tier: cheaper
        background=True,        # submit now, poll for the result in the background
    )
    while job.status in ("queued", "in_progress"):
        time.sleep(2)
        job = llm.responses.retrieve(job.id)
    return re.sub(r"^```[a-z]*\n|\n```$", "", job.output_text.strip())

task = "Count how many prime numbers are below 1,000,000 and print only that number."

sandbox = daytona.create()
try:
    code = write_code(task)
    print(sandbox.process.code_run(code).result)
finally:
    sandbox.delete()
78498

The script ran safely in a sandbox and returned the answer. Nothing executed on your machine, and the finally block destroyed the environment the moment the job concluded.

2. The Auto-Healing Agent: Let the AI fix its own mistakes

Generated code rarely runs perfectly the first time. When a script fails, Daytona reports a non-zero exit_code and captures the traceback in .result. You simply hand both back to Doubleword and let it repair the script.

Because each async call is so cheap on Doubleword, the agent can afford to go round this loop many times instead of giving up.

def run_until_it_works(task: str, tries: int = 3) -> str:
    code = write_code(task)
    sandbox = daytona.create()
    try:
        for _ in range(tries):
            run = sandbox.process.code_run(code)
            if run.exit_code == 0:
                return run.result
            code = write_code(
                f"Task: {task}\n\nThis script failed:\n{code}\n\nError:\n{run.result}\n\n"
                "Return a corrected script, code only."
            )
        return run.result
    finally:
        sandbox.delete()

print(run_until_it_works("prices = [19.99, 5.5, 3.25]. Print the total, rounded to 2 decimals."))
28.74

A five- or ten-step repair loop on a frontier realtime model drains budgets quickly; on Doubleword's async tier, the same robust loop costs pennies.

3. Scale Up: Massively Parallel Evaluations

Once you trust the auto-healing loop on one task, you need to know how the agent performs at scale. Daytona makes batch evaluations incredibly cheap, as every task gets its own isolated sandbox, and they all run in parallel.

You define the tasks, ask Doubleword to solve them, execute the solutions in Daytona, and score them PASS or FAIL. In the batch below, two tasks have clean answers, while two are intentionally unprovable open problems.

from concurrent.futures import ThreadPoolExecutor

def run(code: str) -> str:
    sandbox = daytona.create()
    try:
        return sandbox.process.code_run(code).result.strip()
    finally:
        sandbox.delete()

tasks = [
    ("primes below 1e6",    "Count how many prime numbers are below 1,000,000 and print only that number.", "78498"),
    ("sum 1..1000",         "Print only the sum of every integer from 1 to 1000.", "500500"),
    ("collatz conjecture",  "Is the Collatz conjecture true for every positive integer? Print only YES or NO.", "unproven"),
    ("goldbach conjecture", "Is every even integer greater than 2 the sum of two primes? Print only YES or NO.", "unproven"),
]

def check(task):
    name, prompt, expected = task
    output = run(write_code(prompt))
    return name, "PASS" if output == expected else "FAIL", output

with ThreadPoolExecutor() as pool:
    results = list(pool.map(check, tasks))

for name, verdict, output in results:
    print(f"{name:20} {verdict}  {output!r}")
print(f"{sum(v == 'PASS' for _, v, _ in results)}/{len(tasks)} passed")
primes below 1e6     PASS  '78498'
sum 1..1000          PASS  '500500'
collatz conjecture   FAIL  'NO'
goldbach conjecture  FAIL  'NO'
2/4 passed

Every task ran concurrently in its own sandbox. Because the final two are unprovable mathematical conjectures, the agent's confident but incorrect replies are safely caught and marked FAIL. While this is a hand-rolled loop, handing this logic over to a proper eval framework provides the exact same high-fidelity pass/fail signal, scaled infinitely.

4. Going Beyond Code: Grading GUI Tasks

This architecture extends far beyond simple scripting. Daytona provides each sandbox with a full desktop environment and a computer-use API that drives the mouse, keyboard, and captures screenshots.

An agent can open an app, click through it, and type into it, while a verifier checks the final state and scores it. Below, Doubleword's agent opened a terminal on a Linux desktop spun up by Daytona, executed a command, and browsed the filesystem.

A Daytona Linux desktop where the agent opened a terminal and ran a command The same desktop with the agent browsing the filesystem in a file manager

The API is incredibly streamlined:

sandbox = daytona.create()
try:
    sandbox.computer_use.start()
    screenshot = sandbox.computer_use.screenshot.take_full_screen()   # base64 PNG in .screenshot
    windows = sandbox.computer_use.display.get_windows()              # what is on screen
    sandbox.computer_use.keyboard.type("hello from the agent")        # or mouse.click(x, y)
finally:
    sandbox.computer_use.stop()
    sandbox.delete()

(Windows desktops are supported as well, per Daytona's documentation.)

Everything above runs generated Python, but because the sandbox is a full computer, an agent can reach for any tool a human would. In the example below, the agent has Chromium open on the Doubleword GitHub and a terminal running the dw CLI, both installed inside the sandbox.

A Daytona desktop with Chromium on the Doubleword GitHub and a terminal running the dw CLI

Whatever the agent interacts with, whether a browser, a CLI, or an untrusted binary downloaded from the web, it remains trapped behind Daytona's isolation boundary.

Next Steps

By combining these platforms, you get a coding agent that thinks cheaply on Doubleword and executes safely on Daytona, with zero infrastructure overhead.

To take this further:

  • Use the OpenAI Agents SDK: It runs natively against Doubleword and ships with a Daytona sandbox client, letting you build this loop within a robust agent framework.
  • Stateful Workflows: Keep a sandbox alive across steps to maintain memory and state between code_run calls for complex agents.

Grab a Doubleword API key and a Daytona API key to start building today.