Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

docs: explain agent loop and sandbox boundary (#1228)

Casey Gowrie632605f097c5
diff --git a/apps/docs/components/geistdocs/agent-runtime-diagram.tsx b/apps/docs/components/geistdocs/agent-runtime-diagram.tsx
new file mode 100644
index 000000000..049b07e1d
--- /dev/null
+++ b/apps/docs/components/geistdocs/agent-runtime-diagram.tsx
@@ -0,0 +1,148 @@
+import {
+ IconFileText,
+ IconFolderOpen,
+ IconLinked,
+ IconSandbox,
+ IconWorkflow,
+ IconWrench,
+} from "@vercel/geistdocs/assets/icons";
+import type { JSX, ReactNode } from "react";
+import { cn } from "@/lib/utils";
+
+function Environment({
+ title,
+ description,
+ children,
+}: {
+ title: string;
+ description: string;
+ children: ReactNode;
+}): JSX.Element {
+ return (
+ <section className="flex min-w-0 flex-col gap-3 rounded-xl border border-gray-alpha-400 bg-background-100 p-4 sm:p-5">
+ <div className="flex flex-col gap-1 lg:min-h-16">
+ <span className="font-mono font-medium uppercase tracking-[0.1em] text-gray-1000 text-label-14">
+ {title}
+ </span>
+ <span className="break-words text-copy-14 text-gray-900">{description}</span>
+ </div>
+ {children}
+ </section>
+ );
+}
+
+function RuntimeCard({
+ icon,
+ title,
+ description,
+ paths,
+ className,
+}: {
+ icon: ReactNode;
+ title: string;
+ description: string;
+ paths?: string[];
+ className?: string;
+}): JSX.Element {
+ return (
+ <div className={cn("flex min-w-0 items-start gap-3 rounded-lg p-4 material-small", className)}>
+ <span className="mt-0.5 shrink-0 text-gray-1000">{icon}</span>
+ <div className="flex min-w-0 flex-col gap-1">
+ <span className="font-medium text-copy-14 text-gray-1000">{title}</span>
+ <span className="text-copy-14 text-gray-900">{description}</span>
+ {paths ? (
+ <span className="mt-1 flex flex-col font-mono text-copy-13 text-gray-900">
+ {paths.map((path) => (
+ <span key={path} className="break-words">
+ {path}
+ </span>
+ ))}
+ </span>
+ ) : null}
+ </div>
+ </div>
+ );
+}
+
+function SandboxBridge(): JSX.Element {
+ return (
+ <div className="relative flex min-h-20 items-center justify-center lg:min-h-0">
+ <div
+ aria-hidden
+ className="absolute top-0 bottom-0 left-1/2 border-gray-alpha-700 border-l border-dashed lg:top-1/2 lg:bottom-auto lg:-right-4 lg:-left-4 lg:border-t lg:border-l-0"
+ />
+ <div className="relative rounded-lg border border-gray-alpha-700 bg-background-100 px-3 py-2 text-center shadow-sm">
+ <code className="bg-transparent! p-0! font-medium text-copy-13! text-gray-1000!">
+ ctx.getSandbox()
+ </code>
+ </div>
+ </div>
+ );
+}
+
+/**
+ * Shows the execution boundary between eve's trusted app runtime and isolated sandbox.
+ */
+export function AgentRuntimeDiagram(): JSX.Element {
+ return (
+ <figure
+ aria-label="Agent loop and sandbox execution boundary"
+ className="my-8 grid w-full min-w-0 items-stretch gap-4 lg:grid-cols-[minmax(0,1fr)_160px_minmax(0,1fr)]"
+ >
+ <Environment title="Trusted app runtime" description="Full Node.js access and credentials">
+ <RuntimeCard
+ icon={<IconWorkflow size={18} />}
+ title="Agent loop"
+ description="Durable workflow, model calls, and orchestration"
+ paths={["agent/agent.ts", "agent/instructions.md"]}
+ />
+ <RuntimeCard
+ icon={<IconWrench size={18} />}
+ title="Runtime code"
+ description="Tools, hooks, instrumentation, and connections"
+ paths={[
+ "agent/tools/**",
+ "agent/hooks/**",
+ "agent/instrumentation.ts",
+ "agent/connections/**",
+ ]}
+ />
+ <RuntimeCard
+ icon={<IconLinked size={18} />}
+ title="Secrets and credentials"
+ description="Provider keys, tool secrets, and MCP/OpenAPI auth stay here"
+ />
+ </Environment>
+
+ <SandboxBridge />
+
+ <Environment
+ title="Isolated sandbox"
+ description="Filesystem and processes without app secrets"
+ >
+ <div className="grid gap-3">
+ <RuntimeCard
+ icon={<IconFileText size={18} />}
+ title="Skills"
+ description="Materialized for the agent"
+ paths={["$HOME/.agents/skills", "from agent/skills/**"]}
+ className="order-2 lg:order-1"
+ />
+ <RuntimeCard
+ icon={<IconSandbox size={18} />}
+ title="Sandbox operations"
+ description="Shell commands, file access, scripts, and servers"
+ className="order-1 lg:order-2"
+ />
+ <RuntimeCard
+ icon={<IconFolderOpen size={18} />}
+ title="Workspace"
+ description="Persistent per-session files"
+ paths={["/workspace", "from agent/sandbox/workspace/**"]}
+ className="order-3"
+ />
+ </div>
+ </Environment>
+ </figure>
+ );
+}
diff --git a/apps/docs/components/geistdocs/mdx-components.tsx b/apps/docs/components/geistdocs/mdx-components.tsx
index 0aa8ee605..334461f4d 100644
--- a/apps/docs/components/geistdocs/mdx-components.tsx
+++ b/apps/docs/components/geistdocs/mdx-components.tsx
@@ -3,6 +3,7 @@ import { File, Files, Folder } from "fumadocs-ui/components/files";
import { Step, Steps } from "fumadocs-ui/components/steps";
import type { MDXComponents } from "mdx/types";
import Link from "next/link";
+import { AgentRuntimeDiagram } from "./agent-runtime-diagram";
const localComponents: MDXComponents = {
a: ({ href, ...props }) =>
@@ -14,6 +15,7 @@ const localComponents: MDXComponents = {
File,
Files,
Folder,
+ AgentRuntimeDiagram,
Step,
Steps,
};
diff --git a/docs/concepts/execution-model-and-durability.md b/docs/concepts/execution-model-and-durability.mdx
similarity index 81%
rename from docs/concepts/execution-model-and-durability.md
rename to docs/concepts/execution-model-and-durability.mdx
index 47d119223..33fe0b55f 100644
--- a/docs/concepts/execution-model-and-durability.md
+++ b/docs/concepts/execution-model-and-durability.mdx
@@ -38,6 +38,22 @@ export default defineAgent({
The world package backs workflow state, queues, hooks, and streams. Keep secrets and deployment-specific options in runtime environment variables read by that package, not in `agent.ts`. Custom worlds must implement the runtime protocol expected by eve's vendored `@workflow/*` packages (currently the `5.0.0-beta` line); the Workflow SDK rejects incompatible protocol versions during initialization. See [Self-host eve](../guides/deployment/self-hosting#persist-workflow-state), [agent.ts](../agent-config#workflow-world), and [Workflow Worlds](https://workflow-sdk.dev/worlds).
+## Agent loop and sandbox
+
+An eve agent spans two execution environments with different responsibilities:
+
+<AgentRuntimeDiagram />
+
+The agent loop runs as a durable workflow in the app runtime. Model calls, tool executors, hooks, instrumentation, and connection clients also run there with full Node.js access.
+
+App-side code reaches the sandbox through `ctx.getSandbox()`. The built-in `bash`, `read_file`, `write_file`, `glob`, and `grep` tools use it, and authored tools can use it when they need isolated filesystem or process access.
+
+The [sandbox](../sandbox) owns the per-session filesystem and processes. Authored skills are materialized under `$HOME/.agents/skills`, and `agent/sandbox/workspace/**` seeds `/workspace`. The loop and sandbox have decoupled lifetimes: the durable workflow can park or restart independently, while the app runtime opens or reuses sandbox compute only when code needs it.
+
+This split gives the agent a real filesystem and process environment without putting credentials or trusted integration code in model-controlled compute. The workflow can park without holding sandbox compute, while sandbox capacity and backends can change independently of durable orchestration. Because access flows through app-side tools, sandbox work gets the same approval and instrumentation path as any other tool call.
+
+Provider keys, tool secrets, and MCP, OpenAPI, and connection credentials stay in the app runtime. When a sandbox process needs authenticated network access, [credential brokering](./security-model#credential-brokering) handles the request without exposing the credential to the process.
+
## Resuming after a crash
Crash the process, hit a timeout, or redeploy mid-turn, and the run picks up from the last completed step rather than replaying the whole turn. Completed steps never re-run; eve replays the recorded result. A step interrupted mid-execution re-runs, so make non-idempotent side effects like charges or emails idempotent, or gate them with approval.
diff --git a/docs/concepts/security-model.md b/docs/concepts/security-model.md
index 0b67a79f9..b8d9229c0 100644
--- a/docs/concepts/security-model.md
+++ b/docs/concepts/security-model.md
@@ -20,6 +20,8 @@ The sandbox is the isolated side. The model runs shell commands there through th
A concrete trace makes the boundary clear. When the model calls a custom `charge_card` tool, its `execute` runs in the app runtime, reads `process.env.STRIPE_KEY`, calls Stripe, and returns `{ ok: true }`. The model sees only `{ ok: true }`: the key never leaves the app runtime, and nothing about the call touches the sandbox. The built-in `write_file` is the mirror image, running in the app runtime and proxying the write into the sandbox `/workspace`. Either way the model drives the work through tool calls and their results, never by holding a credential or reaching the runtime directly.
+See [Agent loop and sandbox](./execution-model-and-durability#agent-loop-and-sandbox) for how eve connects these contexts while keeping their state and lifetimes separate.
+
## Data flow at a glance
```mermaid