Agent Platform Architecture
1. Executive Summary
An agent platform enables LLM-powered systems to plan, invoke tools, maintain state, and execute multi-step workflows autonomously within policy bounds. Unlike single-shot chat completion, agents run loops: observe context → reason → select tool → execute → incorporate result → repeat until termination. Production platforms provide orchestration runtimes (LangGraph, Temporal-backed agents, custom state machines), tool registries with schema validation, Model Context Protocol (MCP) for standardized tool connectivity, memory (short-term conversation, long-term vector store), and observability (trace spans per tool call).
Principal architects design agent platforms as distributed control systems with explicit safety boundaries, idempotent tools, timeout budgets, and human-in-the-loop escalation paths. The failure mode is not slow inference—it is unbounded action loops, cascading side effects, and unaudited autonomous changes to production systems.
Platform maturity is measured by tool catalog discipline, trace completeness, and eval-gated promotions—not demo task completion rates. Executive stakeholders should see agent roadmaps as control-plane investments, not chatbot features.
2. Why This Topic Matters
Agent architecture is the 2024–2026 principal interview frontier:
- ReAct vs plan-and-execute? — Loop structure and reliability.
- Tool design for agents? — Idempotency, least privilege, schema.
- MCP vs custom integrations? — Standardization tradeoffs.
- State management? — Checkpointing long-running workflows.
- Multi-agent coordination? — Supervisor patterns, message buses.
Teams shipping "GPT with plugins" without orchestration discipline create incident generators.
Interviewers now expect blast-radius analysis: which tools can mutate production, what budgets stop runaway loops, and how traces support post-incident review. Demonstrate kill-switch and HITL paths on the whiteboard without prompting. Name the tool gateway as the trust boundary in every answer. Step budgets and idempotent tools are as important as model selection in production agent architecture. Durable orchestration is required for any agent that mutates production state. Interview answers should always name max steps, tool policy, and audit logging together.
3. Problems Being Solved
| Problem | Agent platform approach |
|---|---|
| Multi-step task completion | Tool loop with planning |
| Access to enterprise systems | Authenticated tool gateway |
| Long-running workflows | Durable execution + checkpoints |
| Consistency across sessions | Memory stores |
| Developer velocity | Reusable tools and agent templates |
| Audit and compliance | Trace every action and decision |
Workload fit matrix
| Use case | Agent fit | Caveat |
|---|---|---|
| IT ticket triage + fix | Strong | HITL for destructive ops |
| Research synthesis | Strong | Tool budget limits |
| Deterministic ETL | Weak | Use workflow engine |
| Real-time trading | Weak | Latency + safety |
| Customer refund automation | Moderate | Policy engine required |
| Code migration assistant | Strong | Sandboxed execution |
4. Assumptions and System Model
| Assumption | Implication |
|---|---|
| LLM is non-deterministic | Retry, validation, guardrails required |
| Tools have side effects | Idempotency keys, approval gates |
| Execution is bounded | Max steps, max tokens, wall-clock timeout |
| Observability is mandatory | OpenTelemetry-style traces |
| Humans retain override | Kill switch and escalation |
Safety: Tools execute only with authorized credentials; destructive actions require policy match. Liveness: Agent must terminate or escalate within budget—no infinite loops.
5. Essential Terminology
| Term | Definition |
|---|---|
| Agent loop | Iterative reason-act-observe cycle |
| Tool / function calling | Structured LLM output invoking external API |
| ReAct | Reasoning + Acting interleaved pattern |
| Plan-and-execute | Plan first, then execute steps |
| MCP | Model Context Protocol for tool/resource servers |
| Orchestrator | Runtime managing agent state and routing |
| Supervisor agent | Delegates to specialist sub-agents |
| Checkpoint | Persisted agent state for resume |
| HITL | Human-in-the-loop approval |
| Tool budget | Max invocations per session |
6. Core Mechanism
6.1 Agent platform layers
Figure 1: Orchestrator coordinates LLM loops; tool gateway enforces policy before side effects.
6.2 ReAct loop
Figure 2: Each iteration extends context with tool observations until termination condition.
6.3 Multi-agent supervisor pattern
Figure 3: Supervisor delegates subtasks; aggregates results with global budget.
7. Step-by-Step Walkthrough
Walkthrough A: Support ticket agent
- User pastes ticket; orchestrator loads session memory.
- LLM calls
search_kbtool (RAG); receives policy chunks. - LLM calls
lookup_customerwithcustomer_id; CRM returns account. - Policy: refund < $50 auto-approved; else
request_approvalHITL tool. - Human approves;
issue_refundidempotent tool executes. - Trace exported to observability; session archived.
Walkthrough B: Durable workflow agent (Temporal-style)
- Long migration agent starts; checkpoint after each file processed.
- Worker crash at step 47; workflow resumes from checkpoint.
- Tool calls wrapped in activities with retry policies.
- Safety: activity idempotency keys on object storage writes.
Walkthrough C: MCP tool registration
- Developer publishes MCP server exposing
git_logresource. - Platform discovers tools via MCP handshake; registers schemas.
- Agent runtime includes tools in LLM function list.
- Version bump of MCP server triggers platform re-registration.
Walkthrough D: Budget exhaustion
- Agent loops 15 times without resolution; step budget = 12.
- Orchestrator forces summarization prompt or escalates to human.
- Partial work persisted; user notified with trace link.
Walkthrough E: Parallel tool execution
- Agent needs
get_weather(city)andget_flight_status(flight)—independent tools. - Orchestrator issues parallel tool calls after single LLM turn returns both.
- Observations merged before next LLM turn—reduces wall-clock vs sequential.
- Policy engine allows parallel only for read tools; writes remain serial.
- Trace shows fork/join spans for latency analysis.
Walkthrough F: Agent versioning and rollback
- Agent
support-v3promoted after eval pass; canary 5% traffic. - Regression:
refundtool error rate 3× baseline in canary. - Automatic rollback to
support-v2via feature flag; kill switch not required. - Postmortem: tool schema change broke argument validation—add contract test in CI.
- Registry marks v3
deprecated; owners notified.
Tool design standards (platform policy)
| Rule | Rationale |
|---|---|
| Read tools idempotent | Safe retry |
| Write tools require idempotency key | Durable workflow replay |
| Max 20 tools per agent | LLM selection accuracy |
| JSON Schema strict mode | Reduce hallucinated args |
| Timeout per tool < 30s default | Bound agent loop |
| No raw SQL tool | Use parameterized query tool |
| Audit log every invocation | Compliance |
8. Invariants and Guarantees
| Property | Guarantee |
|---|---|
| Authorization | Tools run with scoped service identity |
| Bounded execution | Max steps/time/tokens enforced |
| Auditability | Immutable trace of tool calls |
| Idempotent retries | Safe activity replay in durable workflows |
| Policy before side effect | No bypass of approval for destructive tools |
Agents do not guarantee correct task completion—only bounded, auditable attempts.
9. Failure Scenarios
| Failure | Behavior | Mitigation |
|---|---|---|
| Infinite tool loop | Cost spike | Step budget; duplicate detection |
| Hallucinated tool args | API errors | JSON schema validation |
| Tool timeout | Partial state | Retry with backoff; compensating action |
| Over-privileged tool | Security incident | Least privilege; scoped tokens |
| Prompt injection via tool output | Unsafe next action | Sanitize observations |
| Sub-agent divergence | Inconsistent answer | Supervisor reconciliation |
| Checkpoint corruption | Workflow stuck | Versioned state schema |
10. Performance Characteristics
| Dimension | Behavior |
|---|---|
| Latency | Sum of LLM calls + tool RTTs × steps |
| Cost | Tokens × steps + tool API charges |
| Throughput | Limited by LLM rate and tool backends |
| Parallelism | Independent tools may run concurrent |
| Cold start | Tool connection pools; MCP handshake |
Agent tasks measured in seconds to minutes, not milliseconds.
11. Scalability Limits
- Context window caps history + tool outputs.
- Tool backend rate limits bound agent fleet scale.
- Supervisor fan-out complexity grows with sub-agents.
- Trace storage volume at high QPS.
- HITL queue human bottleneck for approvals.
12. Operational Considerations
- SLOs: p95 task completion time, escalation rate, tool error rate.
- Tool catalog with owners, SLAs, deprecation policy.
- Sandbox for code-execution agents.
- Kill switch per agent definition and globally.
- Eval suites: task success rate on golden scenarios.
- Version prompts and tool schemas like API contracts.
- Tool latency SLOs per tool; circuit break slow backends.
- Agent version pinning in production; blue/green via feature flags.
- Monthly tool audit: remove unused tools from agent definitions.
- Runaway loop detector: alert when same tool called >3 times with similar args.
13. Security Considerations
- OAuth device flow or service accounts per tool—never user password in prompt.
- Network egress restrictions from tool gateway.
- Secrets injected at runtime, not in LLM context.
- Output filtering before displaying to user.
- MCP server trust model—signed plugins, allowlist.
14. Cost Considerations
- Token burn from verbose tool outputs—compress observations.
- LLM tiering: small model for routing, large for synthesis.
- Tool API charges (search, CRM) multiply per step.
- Human approval labor—automate only within policy thresholds.
- Trace storage retention policies.
Durable vs ephemeral agent sessions
| Session type | Runtime | Use case |
|---|---|---|
| Ephemeral chat | In-memory orchestrator | FAQ, low risk |
| Durable workflow | Temporal/Cadence | Multi-hour migrations |
| Scheduled agent | Cron + checkpoint | Nightly reports |
Mixing ephemeral runtime with write tools is an incident pattern—always match durability to blast radius.
MCP ecosystem governance
MCP servers are plugins with network access. Platform policy should require: signed artifacts, security review for scopes, version pinning, and sandbox network policies for third-party servers. MCP is not a security boundary—the tool gateway remains authoritative. Principal architects reject "any developer can publish MCP to prod" without supply chain controls analogous to npm package promotion.
Multi-agent coordination pitfalls
Supervisor patterns fail when sub-agents have overlapping write scopes or contradictory goals. Define exclusive tool ownership per sub-agent; supervisor aggregates read-only results unless explicitly delegating a single write path. Log supervisor routing decisions for debugging infinite delegate loops between research and code agents.
15. Production Implementations
Case study: Internal devops agent (illustrative)
Context
Engineers query k8s status and restart pods via natural language; SOC2 audit required.
Architecture
LangGraph orchestrator; read-only tools default; restart_pod requires HITL + change ticket ID. MCP servers for kubectl wrapper and Grafana. Traces in Datadog.
Outcomes
60% ticket deflection for read queries; zero unauthorized restarts in 6 months (illustrative).
Extended operations narrative
Agent once looped 11 times calling search_logs with near-duplicate queries—step budget fired, escalated to human. Root cause: vague system prompt; fix added "stop when logs sufficient" and reduced tool count from 18 to 9. MCP server version 2.1 introduced breaking schema; platform CI caught mismatch before prod promotion. Durable Temporal workflow for migration agent survived 6-hour run with two worker restarts—checkpoint proved value.
Tradeoffs
| Choice | Tradeoff |
|---|---|
| LangGraph | Flexibility vs custom state machine |
| MCP | Standard vs build adapters |
| HITL on writes | Latency vs safety |
16. Alternatives and Tradeoffs
| Pattern | Pros | Cons |
|---|---|---|
| Single-shot RAG | Simple | No actions |
| Deterministic workflow | Predictable | Brittle to NL |
| ReAct agent | Flexible | Loop risk |
| Plan-and-execute | Structured | Plan drift |
| Multi-agent | Specialization | Coordination cost |
17. Common Misconceptions
| Misconception | Reality |
|---|---|
| "Agents replace workflows" | Complement; use each appropriately |
| "More tools = better" | Tool selection accuracy drops |
| "LLM will know when to stop" | Hard budgets required |
| "MCP solves security" | Still need policy gateway |
| "Autonomy without audit" | Unacceptable in enterprise |
18. Principal Architect Perspective
- Tool gateway is the trust boundary—not the LLM.
- Default read-only; escalate writes through policy.
- Durable execution for anything > 30 seconds.
- Eval-driven rollout with golden tasks per agent.
- MCP for ecosystem; custom only when necessary.
Agent platforms succeed when tools are fewer, sharper, and policy-wrapped—not when every API in the company is exposed to the LLM. Curate tool surfaces like public API products with owners and SLAs. Multi-agent designs need exclusive write domains to prevent conflicting side effects.
Operating playbook (first 90 days)
Days 1–30: Agent registry live; no production agent without owner and risk tier. Tool gateway enforces read-only default.
Days 31–60: HITL workflow for all write tools above low-risk threshold. Tracing integrated with existing APM.
Days 61–90: Eval harness blocks promotion on safety regression. Kill switch drill completed and documented.
19. Architecture Review Exercise
Scenario: Agent has direct production DB write tool with admin credentials embedded in env shared across tenants.
Findings: Critical vulnerability. Scoped read replicas, per-tenant credentials, HITL, query allowlist.
20. Whiteboard Explanation
"An agent platform wraps the LLM in an orchestration loop. The user gives a goal; the orchestrator sends context and available tool schemas to the model. The model returns either a final answer or a structured tool call. The tool gateway authenticates, checks policy, executes the API, and returns an observation that gets appended to context. This repeats until done or a step budget fires. For long tasks, we checkpoint state in a durable workflow engine. MCP standardizes how tool servers expose capabilities. Multi-agent setups use a supervisor to delegate to specialists. Every step is traced for audit."
Principal addendum: Tool gateway is the trust boundary. Default read-only; durable runtime for writes. Step budgets and idempotent tools are non-negotiable.
21. Interview Questions
- Agent vs chat completion? — Multi-step tool loop vs single response.
- ReAct pattern? — Interleaved reasoning and tool use.
- Tool schema purpose? — Constrain LLM outputs to valid calls.
- MCP role? — Standard protocol for tools/resources.
- Why tool gateway? — Policy, auth, audit centralization.
- HITL when? — High-risk or ambiguous actions.
- Checkpointing why? — Resume long workflows after failure.
- Supervisor pattern? — Delegate subtasks to specialist agents.
- Infinite loop prevention? — Step/time/token budgets.
- Idempotent tools? — Safe retries in durable execution.
- Plan-and-execute vs ReAct? — Upfront plan vs adaptive loop.
- Memory types? — Short conversation vs long-term vector store.
- Tool output injection risk? — Sanitize before re-prompting.
- Eval agent quality? — Golden tasks, success rate, safety tests.
Scoring rubric (principal)
| Dimension | Strong | Weak |
|---|---|---|
| Architecture | Orchestrator + gateway + policy | "GPT + APIs" |
| Safety | HITL, budgets, least privilege | Full autonomy |
| Ops | Traces, checkpoints, evals | Demo-only |
| Tools | Idempotency, schema | Raw SQL access |
Extended scoring notes
Principal bar: Tool gateway as trust boundary; step budgets; durable vs ephemeral runtime match. Weak hire: LangChain mention without policy or audit.
- Temporal vs in-memory orchestrator? — Durability for long workflows.
- Tool output injection defense? — Sanitize observations.
- Max tools per agent why? — LLM selection accuracy degrades.
22. Interview Follow-Ups
- Design agent to deploy canary K8s service. — Read tools auto; deploy HITL; Temporal workflow.
- 15-step loop on simple query. — Tune prompts; reduce tools; add duplicate detection.
- MCP vs internal REST tools. — Standardization vs control; hybrid common.
- Multi-tenant agent platform. — Separate credentials, traces, memory namespaces.
- Cost cap per session. — Token + tool budget; downgrade model on approach.
Additional principal scenarios
Scenario: Developer wants agent with 50 tools including production kubectl. Answer: Deny broad kubectl; provide read-only get pods and HITL-gated rollout restart with ticket ID validation.
Scenario: Multi-agent debate produces conflicting answers to user. Answer: Supervisor synthesizes with single final LLM call; cap delegate rounds; log disagreement for eval.
Scenario: MCP plugin update exfiltrates data via new tool. Answer: Signed plugins; version pinning; gateway allowlist; supply chain review same as production dependency promotion.
22A. Production Low-Level Design (Interview + Game Day)
Enterprise agent platform with durable orchestrator and tool gateway trust boundary. Production LLD and Game Day Standard.
Control vs data plane
| Plane | Components |
|---|---|
| Control | Orchestrator (budgets, checkpoints), policy engine, MCP registry, eval harness, kill switch |
| Data | LLM gateway, tool gateway executions, memory/checkpoints, audit traces |
Step-by-step ReAct loop:
| Step | Gate | Budget |
|---|---|---|
| 1 | Load session + tool allowlist | max 20 tools/agent |
| 2 | LLM returns tool_call or final | token cap |
| 3 | JSON schema validation | reject malformed |
| 4 | Policy: read / write / HITL | default deny new tools |
| 5 | Idempotent execute with key | safe retry |
| 6 | Step++ ; kill if > max steps | wall-clock timeout |
Tool risk tiers
| Tier | Gate | Example |
|---|---|---|
| Read | Auto + rate limit | search_kb, get_pods |
| Write scoped | Policy + idempotency | update ticket |
| Destructive | HITL + ticket ID | rollout restart |
| Forbidden | Not registered | admin kubectl |
One SLO
Agent platform safety: 100% tool calls via gateway in audit sample; p99 gateway < 500ms excl. backend; zero prod promotion without eval pass on golden tasks.
22B. Game Day Playbooks
| # | Drill | Inject | Detect | Mitigate | Verify |
|---|---|---|---|---|---|
| GD-1 | Infinite ReAct loop | Agent on ambiguous task | Step count = budget | Force terminate + HITL | No further tool calls |
| GD-2 | Over-privileged tool | Register sql_delete | Policy deny in staging | Remove tool; audit prod agents | Registry clean |
| GD-3 | MCP supply chain | Unsigned plugin update | Schema diff alert | Block allowlist; rollback version | Only signed tools run |
GD-1 — Runaway agent loop
23. Strong Answer Example
Question: "How would you architect a safe enterprise agent platform?"
Answer this as a 45-minute greenfield design using the PRACTICE framework. Below is how a strong student sounds aloud—treat agents as distributed control systems with side effects, not chatbots with API keys.

Figure A: PRACTICE map — Problem → Requirements → Assumptions → Capacity → Topology → Invariants → Constraints → Evolution.
Student interview script (PRACTICE)
P — Problem framing
"We're architecting an enterprise agent platform—teams deploy LLM agents that plan, call tools, and mutate systems (tickets, deployments, databases). The hard requirement is safe autonomy: bounded loops, auditable actions, and no uncontrolled production changes.
Non-goals for v1: multi-agent swarms, autonomous code execution in prod without sandbox, and exposing every internal API to the model. I'll treat orchestration + tool gateway + policy as the product—not 'GPT with admin creds'."
R — Requirements
| Type | Requirement |
|---|---|
| FR | Run agent loops; register tools (incl. MCP); checkpoint long workflows; HITL for destructive ops |
| NFR | Terminate or escalate within step/token/wall-clock budget; p99 tool gateway < 500 ms (excl. backend) |
| Safety | Default deny; read/write/HITL classification; kill switch per agent + global |
| Compliance | Full audit trail: who, which agent version, which tool, args hash, outcome |
| Ops | Eval-gated promotion; golden tasks; no prod agent without owner + risk tier |
"I'll ask: internal devops agents only, or customer-facing? Can agents write prod? I'll assume internal enterprise agents, some write paths, and SOC2-style audit."
A — Assumptions (state aloud)
| Assumption | Why it matters |
|---|---|
| LLM is non-deterministic | Retries, validation, guardrails required |
| Tools have real side effects | Idempotency keys, HITL, least privilege |
| MCP standardizes discovery—not trust | Policy enforced at gateway, not protocol |
| Long tasks need durability | Temporal / LangGraph checkpoints |
| Humans retain override | Kill switch + escalation paths |
"If they say 'agents must deploy to prod autonomously,' I'd push back unless eval + HITL + blast-radius caps are explicit—and I'd still deny blanket kubectl admin."
C — Capacity (back-of-envelope + blast radius)
Concurrent agent runs (say) → 500 active; 5K/day total
Avg steps per run → 5–15 (cap at 20)
Peak tool calls/sec → 500 × 15 / 60 ≈ 125/sec (order-of-magnitude)
Token budget per run → e.g. 32K context; hard cap prevents runaway cost
Wall-clock timeout → 5–30 min by agent tier; kill after budget
Tools per agent (max) → ≤20 (LLM selection accuracy degrades beyond ~15–20)
Write-capable tools → <5 per agent; each HITL or idempotent + scoped
Trace volume → 1 span per step; never log secrets or raw PII in spans
"Capacity here is blast radius, not just QPS—one bad agent definition with 50 tools and admin IAM is worse than 10× traffic."
T — Topology (draw this)

Figure B: Durable orchestrator + LLM gateway + tool gateway (trust boundary) → MCP/enterprise APIs; memory, traces, eval harness, kill switch on the side.
Pattern choice: Orchestrator + centralized tool gateway—not direct LLM→API wiring.
| Layer | Control |
|---|---|
| Orchestrator | Max steps, wall-clock timeout, checkpoint/resume |
| LLM gateway | Token budget, model allowlist, prompt injection defenses |
| Tool gateway | OAuth service identity, JSON schema validation, policy class |
| Policy | Read auto; write scoped; destructive → HITL + ticket ID |
| MCP | Capability registry; signed versions; gateway allowlist |
| Observability | Span per tool call; args hash; no secrets in logs |

Figure C: Observe → reason → policy gate → validate → execute → checkpoint; exit via HITL, kill switch, or step budget.
I — Invariants (safety)
"Non-negotiable for enterprise agents:
- Every tool call through the gateway—no bypass to raw credentials in the prompt.
- Idempotent tools with client-supplied idempotency keys for retries.
- Default deny on new tools until security review and owner assignment.
- Destructive = HITL (or pre-approved ticket-linked automation)—never silent prod writes.
- Bounded execution—step budget fires → escalate or terminate; no infinite ReAct loops.
- Exclusive write domains in multi-agent setups—supervisor doesn't let two agents write the same system."
Tool risk tiers (say aloud):
| Tier | Examples | Gate |
|---|---|---|
| Read | get_pods, search logs, read ticket | Auto with rate limit |
| Write scoped | Update ticket field, post comment | Policy + idempotency |
| Destructive | rollout restart, delete resource, refund | HITL + ticket validation |
| Forbidden | Admin kubectl, raw SQL DELETE | Not registered |
C — Constraints (second C)
| Constraint | Design response |
|---|---|
| LLM cost | Token caps per run/tenant; cheaper model for routing |
| Latency | Parallel read tools where safe; async for long migrations |
| Tool sprawl | Max ~20 tools/agent; monthly audit removes unused |
| MCP supply chain | Signed plugins, version pin, CI schema diff |
| Multi-tenant | Separate creds, memory namespaces, trace isolation |
| Compliance | Retention on audit logs; PII redaction in traces |
E — Evolution (phased rollout)
Phased delivery:
| Phase | Deliverable |
|---|---|
| M1 | Orchestrator + read-only tools + step budget + basic traces |
| M2 | Tool gateway + policy engine (read/write/HITL) + idempotency |
| M3 | MCP registry + signed plugins; eval harness + golden tasks |
| M4 | Durable checkpoints (Temporal); multi-agent supervisor with exclusive writes |
| M5 | Tenant isolation; automated eval gate blocks prod promotion on regression |
Failure modes I'd mention:
| Failure | Mitigation |
|---|---|
| Infinite ReAct loop | Step + token + wall-clock budget; detect duplicate tool calls |
| Tool argument hallucination | JSON schema validation; reject malformed calls |
| Over-privileged tool | Least-privilege service identity; permission boundaries |
| MCP plugin supply chain | Signed artifacts; gateway allowlist; no auto-promote |
| Conflicting multi-agent writes | Exclusive write domains; supervisor single-writer rule |
| Prompt injection via tool output | Sanitize observations; separate system/user tool content |
Observability / SLOs: steps-to-completion, tool error rate by name, HITL queue time, eval pass rate on golden tasks, kill-switch activations, cost per successful run.
Closing line (interview)
"So: durable orchestrator with step, token, and wall-clock budgets, tool gateway as the trust boundary—policy classifies read/write/HITL, idempotent scoped tools, MCP for discovery not trust, OpenTelemetry audit on every step, eval-gated promotion, and default deny on new capabilities. Safe enterprise agents are control-plane architecture—not faster chat."
Scoring signals
| Strong | Weak / red flag |
|---|---|
| Names tool gateway as trust boundary | "LangChain + admin API access" |
| Step/token budgets + kill switch | Unbounded ReAct loop |
| HITL for destructive tools | All tools auto-execute |
| Idempotency + schema validation | Trust LLM-generated args blindly |
| Eval before promotion | Demo works once → ship to prod |
| MCP trust at gateway, not protocol | "MCP makes it secure" |
Compact outline (if time-boxed to 2 minutes)
"Orchestrator (LangGraph/Temporal) with max steps, timeouts, checkpoints. LLM gateway with token caps. All tools via gateway: OAuth service identity, JSON schema, policy read/write/HITL. Destructive needs approval + ticket. Idempotency keys. MCP registered but gateway allowlists. OTEL span per step—no secrets. Eval golden tasks block bad promotions. Default deny new tools. Kill switch. Multi-agent: exclusive write domains."
24. Weak Answer Example
Question: "How would you architect a safe enterprise agent platform?"
"Use LangChain to connect GPT to our APIs; give it admin access so it can fix things fast."
Why weak / red flags: No policy engine, no step budgets, no audit trail, no idempotency, no HITL—admin access turns the LLM into an incident generator.
25. Hands-On Exercise
Lab: labs/lab-016-agentic-ai-platform/ — agent gateway on :8106
cd labs/lab-016-agentic-ai-platform
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
pytest tests/ -v
docker compose -p lab016 -f docker/docker-compose.yml up --build -d
chmod +x scripts/demo_agent.sh && ./scripts/demo_agent.sh
| Step | Endpoint | What happens |
|---|---|---|
| 1 | POST /v1/agents/run | ReAct loop with step budget |
| 2 | GET /v1/agents/runs | Audit trail of tool calls |
| 3 | POST /v1/tools/invoke | search_kb — auto-approved tool |
| 4 | POST /v1/tools/invoke | send_email — HITL approval gate |
| 5 | Policy engine | JSON schema validation + idempotency keys |
Swagger: http://localhost:8106/docs
Engineer guide: how the local stack works
- Agent gateway — auth, rate limits, and policy enforcement before runtime.
- ReAct runtime — reason → act (tool) → observe loop with max step budget.
- Tool registry — schema-validated arguments; dangerous tools require human approval.
- Audit log — every tool invocation persisted with trace ID for compliance replay.
- Idempotency — duplicate
run_id/ tool keys safe on retry (payments, tickets).
Pairs with OpenAI LLM Gateway.
Build-from-scratch exercise (optional)
- Build ReAct loop with 3 mock tools and step budget.
- Add JSON schema validation on tool arguments.
- Integrate MCP server locally; register one resource.
- Simulate tool failure; verify retry and escalation.
- Export trace JSON for one multi-step session.
26. Knowledge Check
- Agent loop steps? (Reason, act, observe, repeat.)
- Tool gateway role? (Auth, policy, execution.)
- MCP standardizes? (Tool/resource connectivity.)
- ReAct combines? (Reasoning and acting.)
- HITL purpose? (Human approval for risky actions.)
- Checkpoint enables? (Durable resume.)
- Step budget prevents? (Infinite loops.)
- Idempotent tools for? (Safe retries.)
- Supervisor agent? (Delegates to sub-agents.)
- Trace purpose? (Audit and debug.)
- Plan-and-execute vs ReAct? (Upfront plan vs adaptive loop.)
- Durable workflow for? (Long-running multi-step tasks.)
- Tool schema validates? (LLM argument structure.)
27. Flashcards
| Front | Back |
|---|---|
| Agent loop | Reason-act-observe cycle |
| Tool calling | Structured LLM API invocation |
| ReAct | Interleaved reasoning and tools |
| MCP | Model Context Protocol |
| Tool gateway | Policy-enforced tool execution |
| HITL | Human-in-the-loop approval |
| Checkpoint | Persisted agent workflow state |
| Supervisor agent | Coordinates specialist agents |
| Tool budget | Max tool calls per session |
| Plan-and-execute | Plan first, then execute steps |
28. Cheat Sheet
PLATFORM LAYERS
App → Orchestrator → LLM + Memory + Tool gateway → Backends
SAFETY
Budgets, HITL, least privilege, idempotent tools, traces
PATTERNS
ReAct | Plan-execute | Supervisor multi-agent
MCP
Standard tool servers; gateway still enforces policy
PRINCIPAL ANCHORS
Tool gateway = trust boundary
Step budget mandatory
HITL for writes
Idempotent tools
Durable for long tasks
Fewer tools better
Trace every invocation
MCP not security layer
29. Related Concepts
- LLM Serving and Model Gateways — inference tier
- RAG Architecture — retrieval as tool
- Agent Governance and Safety — policy layer
- Sagas — compensating multi-step workflows
- Event-Driven Architecture — async agent events
30. References
Primary sources
- Yao, S., et al. (2023). ReAct: Synergizing Reasoning and Acting in Language Models. ICLR.
- Anthropic Model Context Protocol specification — tool server standard.
- LangGraph, Temporal documentation — orchestration implementation choices.
Related
- OpenAI function calling / tools API documentation.
- OWASP LLM Top 10 — agent security risks.
Principal study path
Read Agent Governance and Safety next, then LLM Serving and Model Gateways, RAG Architecture, Sagas for compensating workflows, and Event-Driven Architecture for async agent patterns. Boards increasingly ask for agent blast-radius diagrams—prepare one per high-tier agent.
Distinction
| Claim | Type |
|---|---|
| ReAct pattern | Published research |
| MCP protocol | Anthropic-led standard—verify current spec |
| Platform feature sets | Vendor implementation |