Skip to main content
Source: clone-and-attach/ Normally OpenHands clones your repository automatically when a conversation starts. This example shows how to take control of that process: you provision the sandbox, clone the repo, run its setup script, and only then hand it off to the agent.

Why Do This?

  • Pre-warm expensive environments so the agent starts instantly
  • Clone a specific commit, tag, or monorepo sub-path that the default flow doesn’t support
  • Run custom bootstrapping before the agent gets involved
  • Reuse one prepared sandbox across multiple scripted conversations

How It Works

Steps 1–2 and 5–6 use the Cloud app server (X-Session-API-Key: <OH_API_KEY>). Steps 3–4 use the agent server (X-Session-API-Key: <session_api_key>).

The Key Field: sandbox_id

POST /api/v1/app-conversations accepts a sandbox_id parameter. Pass the ID of a sandbox you already prepared and the new conversation attaches to it instead of creating a fresh one:

Attaching Is Asynchronous

POST /api/v1/app-conversations returns a start task, not the conversation itself. Poll until app_conversation_id is available:

Quickstart

Configuration Options

All inputs accept flags or environment variable fallbacks:

See Also

  • Start a Sandbox — The prerequisite example showing the sandbox lifecycle
  • Upload Skills — Upload a skills directory into a sandbox before attaching a conversation