POST /v1/agents — then run it from anywhere (CLI, SDK, REST, or a registered device), and every run writes to the same durable thread.
Define an agent
agents/code-assistant.ts
Execution Modes
For
in_sandbox, set sandbox to a sandbox slug from sandboxes/*.ts or an existing sandbox reference.
For local-mac, bind the agent to a registered RunMesh device with targetDeviceId. Local device agents can be created and edited from the dashboard or API today. When a run starts, the desktop app registers the cloud thread through /v1/run, executes locally, and publishes thread events back to the platform.
Filesystem Memory
When anin_sandbox agent needs durable storage, mount a workspace into the linked sandbox. The sandbox gives the agent an environment to run commands and use file tools; the workspace mount is the part of that environment that persists across agent runs and sandbox lifecycle changes.
sandboxes/dev-env.ts
agents/code-assistant.ts
/workspace during each run. Conversation threads preserve dialogue context; workspaces preserve repo files, artifacts, task notes, and other filesystem state.
For managed and local-mac, use explicit resources when the agent needs workspaces or sandboxes beyond its bound runtime:
Run an Agent
Threads
Use threads for persisted conversations:rt.agent.threads(agentSlug) for an agent’s conversation history. The lower-level thread API is available through rt.threads for listing cloud threads, reading event history, archiving, renaming, compacting, and subscribing to live frames.
Live thread updates use /v1/threads/{threadId}/events WebSockets. Final messages and tool results are durable; token, reasoning, source, and tool-output deltas are live-only.
Attachments
For file inputs, create an upload target and include the returned message part in the next run:Tools
Agents can use tool slugs from three sources:
Install marketplace tools before using them:
get_dev_url is available when the agent is attached to a sandbox runtime. request_user_input is available when the run has a user-attached channel that can answer prompts.
Configuration
defineAgent() validates common model parameters:
Provider-specific options pass through in
providerOptions.
Model Tiers
Platform models are served by Runtools-managed capacity and billed by token usage. BYOK models use the caller’s configured provider secrets and are not billed as Platform inference. Use the model availability API when a UI needs to show which Platform and BYOK models are currently selectable.Best Practices
Keep agent definitions deployable
Keep agent definitions deployable
defineAgent() should contain serializable configuration. Put integration logic in tools.Prefer OAuth-connected tools
Prefer OAuth-connected tools
OAuth tokens are resolved by Runtools services, so agents do not need provider tokens in prompts or sandbox files.
Use threads for product chat
Use threads for product chat
Threads preserve context and expose live event streams for UI surfaces.
Keep runtime-specific assumptions out of prompts
Keep runtime-specific assumptions out of prompts
The same thread can be controlled from different clients. Bind the agent to the right primitive (
in_sandbox, managed, or local-mac) and let Runtools provide runtime context.