# 7.7 Decoupling brain, hands and session

Harness, sandbox and event log sit behind stable interfaces, so each can fail and be replaced alone.

1. Brain (LLM + harness), hands (sandbox), session (event log).
2. Every step: execute() on a hand, emitEvent() to the session.
3. The container dies: a tool error returns, a fresh one is provisioned.
4. The harness crashes: wake(sessionId) resumes from the last event.

- **Use when:** Hosted agents that must survive crashes and scale independently.
- **Avoid:** One container for everything, with credentials reachable from generated code.

```
execute(name, input) -> string     # hands
emitEvent(id, event)               # session: durable write
provision({ resources })           # fresh sandbox

# recovery
wake(sessionId)
events = getSession(sessionId)
resume(from=events[-1])
```

## References

- [Scaling Managed Agents](https://www.anthropic.com/engineering/managed-agents) (Anthropic)
- [Making Claude Code safer with sandboxing](https://www.anthropic.com/engineering/claude-code-sandboxing) (Anthropic)
- [12-factor agents](https://github.com/humanlayer/12-factor-agents) (HumanLayer)
