# Local-to-Cloud Handoff

> Promote an interactive local agent session mid-task to a detached cloud agent that keeps running after the developer disconnects and reports back asynchronously.

- **Category**: Agentic AI
- **Subcategory**: Planning & Control Flow
- **Canonical URL**: https://designpattern.fyi/patterns/local_to_cloud_handoff/

---

## Description
**Intent**: Promote an interactive local agent session mid-task to a detached cloud agent that keeps running after the developer disconnects and reports back asynchronously.
**Context**: A developer is driving an agent interactively from a laptop or terminal, refining a plan turn by turn. At some point the work becomes long-running and self-contained — a refactor, a test-fixing loop, a multi-step build — and no longer needs steering. The developer wants to close the laptop without abandoning the run.
**Solution**: - Expose an explicit handoff action in the interactive session (command, prefix, or button) that snapshots the current state and transfers it to a cloud agent runtime. - The cloud runtime clones or mounts the repository, restores the plan and conversation context, and resumes the run autonomously in its own sandbox with its own credentials. - The local client detaches; the run survives disconnect. - On completion or when input is required, the cloud agent notifies the developer out of band and offers a way to reattach, review the diff, or pull the run back to local.


## Use Cases
- An interactive run becomes long and self-contained and no longer needs turn-by-turn steering.
- The developer needs to disconnect, sleep the machine, or go mobile without killing the run.
- A cloud runtime with repo access, credentials, and a sandbox is available to continue execution.
- Accumulated plan and context are worth preserving rather than re-prompting from scratch.





## Trade-offs


### Advantages

- Developer is freed from babysitting a long run and can disconnect or go mobile.

- Accumulated plan, context, and partial progress carry across the handoff.

- Cloud execution outlasts network drops, laptop sleep, and shift boundaries.

- The same task can be steered interactively while cheap, then detached once mechanical.




### Considerations & Drawbacks

- Cloud runtime needs its own repo access, credentials, and sandbox, widening the trust and secret-handling surface.

- A detached run can drift or burn budget unobserved if notification and budget limits are weak.

- State transfer is lossy if local-only context (uncommitted files, environment, tool state) is not captured.

- Reattaching to a moved session adds UX and consistency complexity.







---
**Reference**: [Original Source](https://www.agentpatternscatalog.org/patterns/local-to-cloud-handoff/)

