# Managed agents & local checkout

Source: https://olef.dev/docs/cloud/agents

**Outcome:** run persistent, full-harness Claude Code or Codex agents in Olef Cloud (or on your own Mac/Linux host) for **any project** (`general`, `web`, or `android`), check out any cloud agent to your laptop temporarily to debug or refine it without touching your personal `~/.claude` or `~/.codex`, and publish versioned updates safely.

## 1. Agents as installations: the whole harness runs in the workspace

Rather than spinning up a stateless container per turn and discarding local state between calls, Olef runs each managed agent as a **persistent installation** inside its own workspace:

- **Full harness preserved:** The entire Claude Code (`~/.claude`) or Codex (`~/.codex`) home lives in one dedicated workspace. Instructions (`CLAUDE.md` / `AGENTS.md`), settings (`settings.json` / `config.toml`), `skills/**`, `agents/**`, `commands/**`, `hooks/**`, declarative plugins (`plugins.manifest.json`), auto-memory, uncommitted work, and native resumable threads survive across runs.
- **Any project template:** Create agents on `general` (Ubuntu 24.04, Node 22, Python 3.12, git), `web`, or `android` workspaces in Olef Cloud or on your own Mac/Linux machine (`--where <pool>`).
- **Concurrent threads and clean hibernation:** Parallel threads run side by side without clobbering each other, and idle agent workspaces hibernate or stop automatically after inactivity (30 min default), waking cleanly on the next inbox message, event trigger, or schedule.

```bash
# Create a full-harness cloud agent on a general workspace
ocloud agent create backend/reviewer \
  --runtime claude-code \
  --template general \
  --repo acme/api \
  --instructions-file ./reviewer-instructions.md

# Or declare and update idempotently from a JSON spec
ocloud agent apply --file ./agent-spec.json

# Inspect agents, configure egress allowlists, or put compute to sleep manually
ocloud agent ls
ocloud agent show backend/reviewer
ocloud agent set backend/reviewer --egress-allow api.github.com --egress-allow sentry.io
ocloud agent sleep backend/reviewer     # stops compute now; next message wakes it
```

## 2. Debug cloud agents locally (Brain vs. Body)

Inspecting or tuning a misbehaving cloud agent through a web form gives you little visibility into what the harness actually sees. Olef separates an agent's portable **Brain** from its workspace **Body**:

> **Diagram:** Brain vs. Body architecture: An agent's portable Brain (setup files, skills, hooks, plugin manifest, and optional auto-memory stored as encrypted versioned revisions) detaches cleanly from its 50 GB workspace Body, letting you check out the agent to an isolated folder on your laptop in --edit mode (workplace stays live) or --live mode (exclusive lease routes live events to your laptop via the host tunnel), open it in isolation, diff with preflight audit, and redeploy a new revision.
>
> Brain vs. Body lets you pull a cloud agent onto your laptop without altering personal configuration, test it live against real events, audit for laptop-only drift, and publish a versioned revision.

### Choose the right local workflow

| Workflow | Command | What happens to the cloud workplace? | Best for |
| --- | --- | --- | --- |
| **Edit safely** | `ocloud agent checkout <agent> --edit [--with-memory]` | **Stays live** serving traffic; optimistic `base_revision` concurrency prevents silent overwrites | Tuning skills, hooks, instructions, or plugins without interrupting active runs |
| **Live local debug** | `ocloud agent checkout <agent> --live [--with-memory] [--interrupt]` | **Paused under an exclusive lease**; incoming events and inbox messages route straight to your laptop over the host tunnel | Stepping through real incoming events interactively on your machine (`--abort` hands routing back immediately) |
| **Build a new agent locally** | `ocloud agent init <name> [--from-local]` → `ocloud agent deploy --as team/name` | Created fresh when you deploy (`--to cloud` or `--to host:<pool>`) | Authoring a new agent or copying an existing `~/.claude` / `~/.codex` setup into a team agent |
| **Link your personal home** | `ocloud agent link me/<name> --local-home` | Runs live on your machine's Olef Host using your personal `~/.claude` or `~/.codex` | Reaching your laptop setup from Olef's web dashboard, macOS tray, or Android app |

### Step-by-step: live local debugging and redeploy

```bash
# 1. Check out the cloud agent locally (live lease routes events to your laptop)
ocloud agent checkout backend/reviewer --live --with-memory

# 2. Launch Claude Code or Codex pointed strictly at the isolated agent home.
#    Defaults to Olef's local gateway proxy (zero extra login, production parity);
#    pass --own-auth to use your own vendor sign-in instead, or --app claude-desktop / codex-desktop.
ocloud agent open backend/reviewer

# 3. Preview revision diff and preflight audit (catches hardcoded /Users/... paths,
#    missing target secrets, or unallowed egress hosts before pushing)
ocloud agent diff backend/reviewer

# 4. Publish a new versioned revision and release the live lease
ocloud agent redeploy backend/reviewer --note "Fix flaky pagination skill" --yes

# Need to bail out mid-debug? Hand routing back to the workplace immediately:
ocloud agent checkout backend/reviewer --abort
```

Cross-platform plugins listed in `plugins.manifest.json` reconcile automatically between your macOS laptop and the Linux cloud VM, and you can pin or roll back any agent's known-good baseline with `ocloud agent baseline <agent> --seq <n>`.

## 3. Durable inboxes, threads, and human escalation

Every managed agent has a durable inbox address (`team/name` or `me/name`), and **threads** are the primary unit of work, backed by native resumable sessions:

```bash
# Open a new thread with an agent
ocloud thread new backend/reviewer "Audit PR #418 for auth regressions and verify tests pass"

# Inspect running threads, live timeline, cost, and structured verification results
ocloud thread list
ocloud thread show <thread-id>
ocloud thread timeline <thread-id>
ocloud thread results <thread-id>
ocloud agent run <run-id>

# Send follow-up instructions on the same thread
ocloud thread send <thread-id> "Also check rate-limit middleware for unauthenticated routes"
```

When an agent encounters a product ambiguity or requires an approval, compute pauses and the structured card lands in **Needs you** across four surfaces:

- **Web dashboard** ([app.olef.dev](https://app.olef.dev))
- **macOS menu-bar Inbox** (works even for cloud-only users with no local host running)
- **CLI** (`ocloud msg answer`)
- **Olef for Android** (answer questions or approve actions from your phone)

```bash
ocloud msg answer <msg-id> --text "Approve the schema migration and open a draft PR"
ocloud msg answer <msg-id> --decision approve
```

If nobody answers within the policy window, Olef escalates automatically along your organization tree (**addressee → inbox admins → team owner → parent team → org owner**):

```bash
ocloud escalation policy set --team backend --every-s 3600
ocloud escalation preview
```

## Next: pair agents with deterministic workflows

To wake sleeping agents on exact `jq` conditions (zero polling), validate cross-team payloads with JSON Schema and WebAssembly before spending compute, and separate untrusted inputs structurally, continue to [Hybrid workflows (agents + rails)](https://olef.dev/docs/cloud/hybrid-workflows).

Full CLI references: [`ocloud agent`](https://olef.dev/docs/reference/ocloud/agent) · [`ocloud thread`](https://olef.dev/docs/reference/ocloud/thread) · [`ocloud inbox`](https://olef.dev/docs/reference/ocloud/inbox) · [`ocloud msg`](https://olef.dev/docs/reference/ocloud/msg) · [`ocloud escalation`](https://olef.dev/docs/reference/ocloud/escalation).
