Back to portfolio

Design concept, not yet built

Agents that plan in code and stop at the gate.

A concept for an MCP workflow engine: a typed state machine, sandboxed Python, and human approval before anything destructive.

See the architecture
run_7f3a simulated, illustrative timings

Task

Archive customers inactive for 24 months, then drop the legacy_notes column.

  1. Discovertools/list over MCP
  2. Plantyped Plan model
  3. Sandbox execPython in a microVM
  4. Approval gatehuman decides
  5. Resultapplied or aborted

Trace

Tokens illustrative

Stuff rows into context0
Code-as-action in sandbox0

 

Approval gate

Waiting for a destructive call.

Timings and token counts are illustrative figures from a simulated run, not measurements. The context-stuffing path is a counterfactual.

A run is a graph, not a loop

Every transition is declared and typed. The model chooses inside a node, never between nodes, so a run cannot wander and always ends in a named terminal state.

State machine Discover goes to Plan, then Execute in sandbox, then a Gate. Approved goes to Apply then Done. Rejected goes to Aborted. Execute can retry back to Plan up to two times or fail. tools ok exit 0 retry, max 2 budget spent approved rejected Discover Plan Executein microVM Gate Apply Aborted Done End Failed State machine Discover goes to Plan, then Execute in sandbox, then a Gate. Approved goes to Apply then Done. Rejected goes to Aborted. Execute can retry back to Plan up to two times or fail when the budget is spent. tools ok exit 0 retry, max 2 approved rejected Discover Plan Executein microVM Gate Apply Aborted Done End Failedbudget spent

Typed edges

Each node returns a Pydantic model. A transition fires only when the output validates, which is what makes replays deterministic.

Bounded by design

Retries, tokens and wall-clock are budgets in the state, not suggestions in a prompt. Exhaust one and the run goes to Failed.

The loop it replaces

An unbounded think, act, observe cycle where the model also decides when to stop. Cheap to start, hard to cap, hard to audit.

Architecture

Select any block to see its job. Solid lines are tool traffic, the dashed line is the approval request returning to the client.

durable workflow (Temporal) MCP clients Claude Desktop Cursor any MCP host HTTP elicitation Workflow MCP server FastMCP, Streamable HTTP Pydantic AI state machine Discover Plan Execute Gate Apply / Abort typed nodes, code-as-action Approval hook policy match, signal wait E2B microVM agent-written Python ephemeral, default-deny egress sql server read and write queries git server diff, branch, PR rest server internal APIs your MCP servers OpenTelemetry spans to Pydantic Logfire: latency, tool usage, token burn durable workflow (Temporal) MCP clients Claude Desktop Cursor any MCP host HTTP elicitation Workflow MCP server FastMCP, Streamable HTTP Pydantic AI state machine Discover Plan Execute Gate Apply / Abort typed nodes, code-as-action Approval hook policy match, signal wait E2B microVM agent-written Python ephemeral, default-deny egress your MCP servers sql server read and write queries git server diff, branch, PR rest server internal APIs OpenTelemetry spans to Pydantic Logfire: latency, tool usage, token burn

Select a block

Each block is a separately testable piece. Start with the state machine, it is the part that replaces the agent loop.

pydantic-ai, fastmcp, e2b, temporalio, opentelemetry

Typed tools the model discovers

Tools are described by JSON Schema and annotations. Destructive ones carry a hint the engine uses to route them through the gate.

sql.query

        

Approval travels over the protocol

A gated call parks the workflow and asks the connected client. The reply is a signal into Temporal, so it survives restarts and cannot be skipped by the model.

    
            

    Gate policy, evaluated in code

    alter, drop, truncateAlways gated
    delete, updateGated above a row threshold, set per tool
    git push, forceGated on protected branches
    select, diff, GETPass through, traced

    Generated code never touches the host

    Agent-written Python runs in a throwaway microVM with no credentials and no route out except one the policy names.

    Isolation

    One Firecracker microVM per run. Its own kernel, no shared filesystem, destroyed when the run ends.

    Egress

    Default deny. A short allowlist is enforced outside the VM, so code inside cannot widen it.

    Secrets

    No tokens in the sandbox. Data comes in through MCP tool results, credentials stay on the tool servers.

    Audit

    Code, stdout and every blocked request are spans on the same trace as the approval that followed.

    egress probeexample policy

    Code in the sandbox tries to reach:

    Pick a destination.

    Design targets targets, not measurements

    < 1 ssandbox ready, target
    90%+fewer context tokens on heavy data tasks, target
    100%of tool calls traced, target
    0destructive calls without a recorded decision, target

    Stack

    Each piece does one job, and any of them can be swapped without touching the others.

    Protocol

    • MCP Python SDK, FastMCP tool servers and the engine's own server
    • Streamable HTTP transport for any client

    Orchestration

    • Pydantic AI typed nodes and validated outputs
    • Pydantic models for plans, results, budgets

    Execution

    • E2B Firecracker microVMs for generated code
    • Python as the action language

    Durability

    • Temporal workflows, retries, approval signals

    Observability

    • OpenTelemetry spans across every hop
    • Pydantic Logfire traces, latency, token burn