PART 2 · PRODUCTION SYSTEM S4 · AGENTIC INFRASTRUCTURE

Agentic Orchestrator, Tool Calling & Sandboxes

Design fault-tolerant multi-step agent loops with FSM-constrained JSON decoding, parallel tool fan-out, Firecracker MicroVM sandboxing, and taint-tracked prompt-injection guardrails.

Act I · Scope, Latency & Token Budget Math

Hard Guardrails, Grammar Guarantees & Isolation Envelope

Step 1 of 5
Hard Per-Run Budget
12K Tokens / $0.18

Circuit breaker halts runaway loops and duplicate tool calls before bill shock or context blowup.

FSM Constrained Decoding
100% Valid JSON

Logit-level grammar mask sets invalid tokens to -∞, eliminating malformed tool-call retries.

MicroVM Snapshot Restore
< 125 ms

Firecracker jailer isolates untrusted agent-generated Python in a dedicated kernel with zero host RCE.

Durable Checkpoint Loop
Max 6 Hops

Persisted step WAL + per-tool idempotency_key replay survives worker crashes mid-plan.

Act II · Wire Protocols, Tool Schemas & Sandbox Contracts

Parallel Tool Execution Frame & MicroVM Jailer Policy

Step 2 of 5
AgentStep & Parallel Tool Call Contract
MicroVM Sandbox & Guardrail Policy
Act III · Interactive Agentic Orchestrator, Live FSM Masker & Chaos Switchboard

ReAct Fan-Out, FSM Logit Masking & Taint Guardrail Lab

ORCHESTRATOR NOMINAL
Step 1 / 5
Live Policy Controls
Step & Token Budget
Step 1/6 · 1,120 / 12K tok
$0.017 / $0.18 cap
JSON Parse Reliability
100.0% (FSM Masked)
0 parse retries burned
Sandbox Boundary
MicroVM Isolated · 0 Egress
256 MB · strict-python
Guardrail Status
CLEAN · 0.04 Risk
Taint tracking active
Agentic Runtime Topology · ReAct Loop & Parallel Fan-Out
INPUT GUARD
shield Input / Output Guardrail Injection · PII · Taint Sink CLEAN · RISK 0.04 HITL Gate: refund / email account_tree Durable Orchestrator State Machine + Checkpoint WAL STEP 1/6 · LSN #101 Budget Guard: 12K tok / $0.18 psychology LLM Planner + FSM xGrammar Logit Filter FSM: 100% VALID JSON Schema: tool_call_v2 terminal Firecracker MicroVM 1 vCPU · 256MB · deny-all SNAPSHOT READY (94ms) KVM Kernel · 0 Host Egress call_split Tool Router & Breaker Idempotency · Loop Hash PARALLEL FAN-OUT READY Max Hops: 6 · Dedup Key database External APIs / SQL Read-Only & Priv Sinks 200 OK · READ-ONLY Tagged: TAINTED_TOOL_OUT Trusted System / Verified FSM / MicroVM Sandbox Retry / Circuit Breaker Tainted / Injection Blocked CHECKPOINT LSN #101
INPUT GUARD

Loading agentic orchestrator...

Invariant active
Live ReAct Trace & Token Budget
$0.017 / $0.18
1,120 / 12,000 tokens 9.3%
Live FSM Vocabulary Logit Masker
State: EXPECT_JSON_KEY
Chaos Engineering Switchboard
0 Active
Live Event Console
Act IV · Zero-Dependency Python 3.12+ Blueprints

Standard-Library Python Core & Production Stack Mapping

Auto-Synced to Simulator
Production Stack Mapping Strip 6 Agentic Infrastructure Primitives
Vendor-Agnostic Component Production Systems Operational Role
Durable Agent Orchestrator Temporal, Restate, LangGraph Platform Persists step checkpoints & replays idempotent tool calls across worker crashes
FSM Constrained Decoding xGrammar, Outlines, llguidance (vLLM / SGLang) Compiles JSON Schema into token bitmasks enforcing 100% valid syntax at logit time
Ephemeral Code Sandbox AWS Firecracker, E2B, Modal Sandboxes, gVisor Hardware-virtualized kernel isolation with <125ms snapshot restore & deny-all egress
Input/Output & Taint Guardrails Llama Guard 3, NeMo Guardrails, Lakera Guard Detects indirect prompt injections and blocks tainted context from privileged sinks
Tool Wire Protocol Model Context Protocol (MCP), JSON Schema Draft 2020-12 Standardizes tool discovery, typed argument contracts, and capability scoping
Agent Observability & Cost OpenTelemetry GenAI SIG, Langfuse, Arize Phoenix Tracks per-hop token spend, loop hashes, tool latency, and guardrail blocks
Act V · Architectural Tradeoffs & Production SLOs

Agentic Design Tradeoffs & Production Reliability Targets

Step 5 of 5
Tradeoff 01 Control Loop

ReAct Loop vs. Plan-and-Execute

ReAct + Parallel Fan-Out

Adapts immediately to unexpected tool errors and partial observations while batching independent reads via asyncio.gather.

Plan-and-Execute

Cheaper when a frontier model drafts a DAG once and small workers execute steps, but brittle if early observations invalidate the plan.

Verdict Use ReAct with parallel tool fan-out for investigative workflows; use Plan-and-Execute for predictable multi-doc batch pipelines.
Tradeoff 02 Structured Output

FSM Logit Masking vs. Retry-on-Parse-Error

FSM Logit Masking

Guarantees 100% schema-valid JSON on the first pass with <50 µs CPU bitmask overhead per token—zero wasted retry turns.

Retry-on-Parse-Error

Works with any black-box API, but markdown fences or trailing commas burn 2x–3x extra LLM latency and token budget on retries.

Verdict Always enforce FSM Constrained Decoding (xGrammar / Structured Outputs) for tool calls; keep <think> scratchpads unconstrained before the JSON block.
Tradeoff 03 Isolation Boundary

Firecracker MicroVM vs. Docker Containers

Firecracker MicroVM

Hardware KVM virtualization with a dedicated guest kernel per run and <125 ms snapshot restore—eliminating shared-kernel escape CVEs.

Docker Containers

Fast and familiar, but all containers share the host Linux kernel; untrusted LLM-generated code poses a severe privilege-escalation risk.

Verdict Never run LLM-generated code in shared Docker containers—require Firecracker MicroVMs or gVisor with deny-all egress.
Tradeoff 04 Privilege Control

Autonomous Execution vs. HITL Approval Gates

Tiered HITL + Taint Gate

Read-only tools run autonomously at full speed; destructive or external-egress sinks pause at a durable checkpoint for human approval.

Fully Autonomous

Lowest human friction, but a single indirect prompt injection inside a scraped webpage or email can trigger unauthorized refunds or data leaks.

Verdict Pair Taint Tracking with durable HITL checkpoints for every state-mutating or external-egress tool (refund_payment, send_external_email).
Production Observability SLOs
Agentic Infrastructure Targets
Valid Tool-Call JSON 99.95% FSM grammar-constrained
MicroVM Snapshot P95 < 150 ms Firecracker warm pool
Host / Egress Escapes 0 KVM + deny-all egress
Token & Cost Cap 100% Hard circuit breaker