AI Agent Platform: Tool Calling, Memory, Sandboxing, and Step Budgets
End-to-end design of a production AI agent platform covering tool dispatch, multi-tier memory, secure sandboxed execution, and deterministic step-budget enforcement.
AI & MLOps · advanced · 12 min read · 2391 words · By Sandip Das, AWS Container Hero · Published · Updated
What this covers
- Overview
- Requirements
- High-Level Architecture
- Core Components
- Data Model
- Key Flows
- Scaling and Performance
- Reliability and Failure Modes
- Trade-offs and Alternatives
- Interview Talking Points
Key components
- Agent Orchestrator — Owns the plan-execute-observe loop, checkpoints state to Redis, and streams results to the client.
- LLM Planner — Calls the LLM API with a context-managed prompt and returns a structured next action or final answer.
- Step Budget Enforcer — Atomically tracks steps, tokens, and wall-clock time per session and halts execution on breach.
- Tool Registry — Stores tool definitions, JSON schemas, execution backends, and permission requirements in Postgres.
- Sandbox Executor (Firecracker) — Runs each tool call inside an isolated MicroVM with enforced CPU, memory, and network limits.
- Memory Service — Provides three-tier memory: Redis STM for context, pgvector LTM for semantic retrieval, and S3 episodic logs.
- Task Queue (Kafka) — Decouples tool dispatch from orchestration and provides back-pressure for long-running tools.
- Observability Stack — Collects per-step OpenTelemetry traces and Prometheus metrics for debugging, alerting, and cost attribution.
Overview
An AI agent platform lets an LLM iteratively plan, call external tools, observe results, and refine its approach until a goal is met or a budget is exhausted. Unlike a single-shot prompt, an agent loop can execute code, query databases, browse the web, and call APIs — making reliability, security, and cost control first-class concerns. This page designs a platform capable of running thousands of concurrent agent sessions, each with isolated execution environments, multi-tier memory, deterministic step budgets, and full observability.
The core challenge is not the LLM call itself — that is a commodity API call — but everything around it: how do you prevent a rogue tool from exfiltrating data? How do you give the agent the right context without blowing the context window? How do you stop a runaway agent from spending $400 in a single session?
The rest of this walkthrough — the trade-offs, the scaling numbers and the build prompt — is part of LearnXops Premium. See membership, or create a free account to read the beginner walkthroughs in full.
Topics: ai-agents, mlops, llm, sandboxing, system-design
Related system designs
- A/B Testing and Online Experimentation Platform (Premium)
- CI/CD for Machine Learning: Reproducible Builds, Automated Retraining and Model Promotion (Premium)
- Distributed Model Training Pipeline: Sharding, Checkpointing and Fault Recovery (Premium)
- Embedding Pipeline: Bulk Generation, Incremental Refresh, and Reindexing (Premium)
- Experiment Tracking and the Model Registry: Runs, Artefacts, Lineage and Promotion (Premium)
- Feature Store: Offline/Online Parity, Point-in-Time Correctness, and Backfills (Premium)