Skip to main content

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​

ProblemAgent platform approach
Multi-step task completionTool loop with planning
Access to enterprise systemsAuthenticated tool gateway
Long-running workflowsDurable execution + checkpoints
Consistency across sessionsMemory stores
Developer velocityReusable tools and agent templates
Audit and complianceTrace every action and decision

Workload fit matrix​

Use caseAgent fitCaveat
IT ticket triage + fixStrongHITL for destructive ops
Research synthesisStrongTool budget limits
Deterministic ETLWeakUse workflow engine
Real-time tradingWeakLatency + safety
Customer refund automationModeratePolicy engine required
Code migration assistantStrongSandboxed execution

4. Assumptions and System Model​

AssumptionImplication
LLM is non-deterministicRetry, validation, guardrails required
Tools have side effectsIdempotency keys, approval gates
Execution is boundedMax steps, max tokens, wall-clock timeout
Observability is mandatoryOpenTelemetry-style traces
Humans retain overrideKill 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​

TermDefinition
Agent loopIterative reason-act-observe cycle
Tool / function callingStructured LLM output invoking external API
ReActReasoning + Acting interleaved pattern
Plan-and-executePlan first, then execute steps
MCPModel Context Protocol for tool/resource servers
OrchestratorRuntime managing agent state and routing
Supervisor agentDelegates to specialist sub-agents
CheckpointPersisted agent state for resume
HITLHuman-in-the-loop approval
Tool budgetMax 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​

  1. User pastes ticket; orchestrator loads session memory.
  2. LLM calls search_kb tool (RAG); receives policy chunks.
  3. LLM calls lookup_customer with customer_id; CRM returns account.
  4. Policy: refund < $50 auto-approved; else request_approval HITL tool.
  5. Human approves; issue_refund idempotent tool executes.
  6. Trace exported to observability; session archived.

Walkthrough B: Durable workflow agent (Temporal-style)​

  1. Long migration agent starts; checkpoint after each file processed.
  2. Worker crash at step 47; workflow resumes from checkpoint.
  3. Tool calls wrapped in activities with retry policies.
  4. Safety: activity idempotency keys on object storage writes.

Walkthrough C: MCP tool registration​

  1. Developer publishes MCP server exposing git_log resource.
  2. Platform discovers tools via MCP handshake; registers schemas.
  3. Agent runtime includes tools in LLM function list.
  4. Version bump of MCP server triggers platform re-registration.

Walkthrough D: Budget exhaustion​

  1. Agent loops 15 times without resolution; step budget = 12.
  2. Orchestrator forces summarization prompt or escalates to human.
  3. Partial work persisted; user notified with trace link.

Walkthrough E: Parallel tool execution​

  1. Agent needs get_weather(city) and get_flight_status(flight)—independent tools.
  2. Orchestrator issues parallel tool calls after single LLM turn returns both.
  3. Observations merged before next LLM turn—reduces wall-clock vs sequential.
  4. Policy engine allows parallel only for read tools; writes remain serial.
  5. Trace shows fork/join spans for latency analysis.

Walkthrough F: Agent versioning and rollback​

  1. Agent support-v3 promoted after eval pass; canary 5% traffic.
  2. Regression: refund tool error rate 3× baseline in canary.
  3. Automatic rollback to support-v2 via feature flag; kill switch not required.
  4. Postmortem: tool schema change broke argument validation—add contract test in CI.
  5. Registry marks v3 deprecated; owners notified.

Tool design standards (platform policy)​

RuleRationale
Read tools idempotentSafe retry
Write tools require idempotency keyDurable workflow replay
Max 20 tools per agentLLM selection accuracy
JSON Schema strict modeReduce hallucinated args
Timeout per tool < 30s defaultBound agent loop
No raw SQL toolUse parameterized query tool
Audit log every invocationCompliance

8. Invariants and Guarantees​

PropertyGuarantee
AuthorizationTools run with scoped service identity
Bounded executionMax steps/time/tokens enforced
AuditabilityImmutable trace of tool calls
Idempotent retriesSafe activity replay in durable workflows
Policy before side effectNo bypass of approval for destructive tools

Agents do not guarantee correct task completion—only bounded, auditable attempts.

9. Failure Scenarios​

FailureBehaviorMitigation
Infinite tool loopCost spikeStep budget; duplicate detection
Hallucinated tool argsAPI errorsJSON schema validation
Tool timeoutPartial stateRetry with backoff; compensating action
Over-privileged toolSecurity incidentLeast privilege; scoped tokens
Prompt injection via tool outputUnsafe next actionSanitize observations
Sub-agent divergenceInconsistent answerSupervisor reconciliation
Checkpoint corruptionWorkflow stuckVersioned state schema

10. Performance Characteristics​

DimensionBehavior
LatencySum of LLM calls + tool RTTs × steps
CostTokens × steps + tool API charges
ThroughputLimited by LLM rate and tool backends
ParallelismIndependent tools may run concurrent
Cold startTool 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 typeRuntimeUse case
Ephemeral chatIn-memory orchestratorFAQ, low risk
Durable workflowTemporal/CadenceMulti-hour migrations
Scheduled agentCron + checkpointNightly 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​

ChoiceTradeoff
LangGraphFlexibility vs custom state machine
MCPStandard vs build adapters
HITL on writesLatency vs safety

16. Alternatives and Tradeoffs​

PatternProsCons
Single-shot RAGSimpleNo actions
Deterministic workflowPredictableBrittle to NL
ReAct agentFlexibleLoop risk
Plan-and-executeStructuredPlan drift
Multi-agentSpecializationCoordination cost

17. Common Misconceptions​

MisconceptionReality
"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​

  1. Tool gateway is the trust boundary—not the LLM.
  2. Default read-only; escalate writes through policy.
  3. Durable execution for anything > 30 seconds.
  4. Eval-driven rollout with golden tasks per agent.
  5. 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​

  1. Agent vs chat completion? — Multi-step tool loop vs single response.
  2. ReAct pattern? — Interleaved reasoning and tool use.
  3. Tool schema purpose? — Constrain LLM outputs to valid calls.
  4. MCP role? — Standard protocol for tools/resources.
  5. Why tool gateway? — Policy, auth, audit centralization.
  6. HITL when? — High-risk or ambiguous actions.
  7. Checkpointing why? — Resume long workflows after failure.
  8. Supervisor pattern? — Delegate subtasks to specialist agents.
  9. Infinite loop prevention? — Step/time/token budgets.
  10. Idempotent tools? — Safe retries in durable execution.
  11. Plan-and-execute vs ReAct? — Upfront plan vs adaptive loop.
  12. Memory types? — Short conversation vs long-term vector store.
  13. Tool output injection risk? — Sanitize before re-prompting.
  14. Eval agent quality? — Golden tasks, success rate, safety tests.

Scoring rubric (principal)​

DimensionStrongWeak
ArchitectureOrchestrator + gateway + policy"GPT + APIs"
SafetyHITL, budgets, least privilegeFull autonomy
OpsTraces, checkpoints, evalsDemo-only
ToolsIdempotency, schemaRaw 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.

  1. Temporal vs in-memory orchestrator? — Durability for long workflows.
  2. Tool output injection defense? — Sanitize observations.
  3. Max tools per agent why? — LLM selection accuracy degrades.

22. Interview Follow-Ups​

  1. Design agent to deploy canary K8s service. — Read tools auto; deploy HITL; Temporal workflow.
  2. 15-step loop on simple query. — Tune prompts; reduce tools; add duplicate detection.
  3. MCP vs internal REST tools. — Standardization vs control; hybrid common.
  4. Multi-tenant agent platform. — Separate credentials, traces, memory namespaces.
  5. 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​

PlaneComponents
ControlOrchestrator (budgets, checkpoints), policy engine, MCP registry, eval harness, kill switch
DataLLM gateway, tool gateway executions, memory/checkpoints, audit traces

Step-by-step ReAct loop:

StepGateBudget
1Load session + tool allowlistmax 20 tools/agent
2LLM returns tool_call or finaltoken cap
3JSON schema validationreject malformed
4Policy: read / write / HITLdefault deny new tools
5Idempotent execute with keysafe retry
6Step++ ; kill if > max stepswall-clock timeout

Tool risk tiers​

TierGateExample
ReadAuto + rate limitsearch_kb, get_pods
Write scopedPolicy + idempotencyupdate ticket
DestructiveHITL + ticket IDrollout restart
ForbiddenNot registeredadmin 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​

#DrillInjectDetectMitigateVerify
GD-1Infinite ReAct loopAgent on ambiguous taskStep count = budgetForce terminate + HITLNo further tool calls
GD-2Over-privileged toolRegister sql_deletePolicy deny in stagingRemove tool; audit prod agentsRegistry clean
GD-3MCP supply chainUnsigned plugin updateSchema diff alertBlock allowlist; rollback versionOnly 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.

PRACTICE interview answer map for safe enterprise agent platform

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​

TypeRequirement
FRRun agent loops; register tools (incl. MCP); checkpoint long workflows; HITL for destructive ops
NFRTerminate or escalate within step/token/wall-clock budget; p99 tool gateway < 500 ms (excl. backend)
SafetyDefault deny; read/write/HITL classification; kill switch per agent + global
ComplianceFull audit trail: who, which agent version, which tool, args hash, outcome
OpsEval-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)​

AssumptionWhy it matters
LLM is non-deterministicRetries, validation, guardrails required
Tools have real side effectsIdempotency keys, HITL, least privilege
MCP standardizes discovery—not trustPolicy enforced at gateway, not protocol
Long tasks need durabilityTemporal / LangGraph checkpoints
Humans retain overrideKill 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 → &lt;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)​

Safe enterprise agent platform topology

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.

LayerControl
OrchestratorMax steps, wall-clock timeout, checkpoint/resume
LLM gatewayToken budget, model allowlist, prompt injection defenses
Tool gatewayOAuth service identity, JSON schema validation, policy class
PolicyRead auto; write scoped; destructive → HITL + ticket ID
MCPCapability registry; signed versions; gateway allowlist
ObservabilitySpan per tool call; args hash; no secrets in logs

Agent ReAct loop with safety gates

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:

  1. Every tool call through the gateway—no bypass to raw credentials in the prompt.
  2. Idempotent tools with client-supplied idempotency keys for retries.
  3. Default deny on new tools until security review and owner assignment.
  4. Destructive = HITL (or pre-approved ticket-linked automation)—never silent prod writes.
  5. Bounded execution—step budget fires → escalate or terminate; no infinite ReAct loops.
  6. Exclusive write domains in multi-agent setups—supervisor doesn't let two agents write the same system."

Tool risk tiers (say aloud):

TierExamplesGate
Readget_pods, search logs, read ticketAuto with rate limit
Write scopedUpdate ticket field, post commentPolicy + idempotency
Destructiverollout restart, delete resource, refundHITL + ticket validation
ForbiddenAdmin kubectl, raw SQL DELETENot registered

C — Constraints (second C)​

ConstraintDesign response
LLM costToken caps per run/tenant; cheaper model for routing
LatencyParallel read tools where safe; async for long migrations
Tool sprawlMax ~20 tools/agent; monthly audit removes unused
MCP supply chainSigned plugins, version pin, CI schema diff
Multi-tenantSeparate creds, memory namespaces, trace isolation
ComplianceRetention on audit logs; PII redaction in traces

E — Evolution (phased rollout)​

Phased delivery:

PhaseDeliverable
M1Orchestrator + read-only tools + step budget + basic traces
M2Tool gateway + policy engine (read/write/HITL) + idempotency
M3MCP registry + signed plugins; eval harness + golden tasks
M4Durable checkpoints (Temporal); multi-agent supervisor with exclusive writes
M5Tenant isolation; automated eval gate blocks prod promotion on regression

Failure modes I'd mention:

FailureMitigation
Infinite ReAct loopStep + token + wall-clock budget; detect duplicate tool calls
Tool argument hallucinationJSON schema validation; reject malformed calls
Over-privileged toolLeast-privilege service identity; permission boundaries
MCP plugin supply chainSigned artifacts; gateway allowlist; no auto-promote
Conflicting multi-agent writesExclusive write domains; supervisor single-writer rule
Prompt injection via tool outputSanitize 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​

StrongWeak / red flag
Names tool gateway as trust boundary"LangChain + admin API access"
Step/token budgets + kill switchUnbounded ReAct loop
HITL for destructive toolsAll tools auto-execute
Idempotency + schema validationTrust LLM-generated args blindly
Eval before promotionDemo 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
StepEndpointWhat happens
1POST /v1/agents/runReAct loop with step budget
2GET /v1/agents/runsAudit trail of tool calls
3POST /v1/tools/invokesearch_kb — auto-approved tool
4POST /v1/tools/invokesend_email — HITL approval gate
5Policy engineJSON schema validation + idempotency keys

Swagger: http://localhost:8106/docs

Engineer guide: how the local stack works​

  1. Agent gateway — auth, rate limits, and policy enforcement before runtime.
  2. ReAct runtime — reason → act (tool) → observe loop with max step budget.
  3. Tool registry — schema-validated arguments; dangerous tools require human approval.
  4. Audit log — every tool invocation persisted with trace ID for compliance replay.
  5. Idempotency — duplicate run_id / tool keys safe on retry (payments, tickets).

Pairs with OpenAI LLM Gateway.

Build-from-scratch exercise (optional)​

  1. Build ReAct loop with 3 mock tools and step budget.
  2. Add JSON schema validation on tool arguments.
  3. Integrate MCP server locally; register one resource.
  4. Simulate tool failure; verify retry and escalation.
  5. Export trace JSON for one multi-step session.

26. Knowledge Check​

  1. Agent loop steps? (Reason, act, observe, repeat.)
  2. Tool gateway role? (Auth, policy, execution.)
  3. MCP standardizes? (Tool/resource connectivity.)
  4. ReAct combines? (Reasoning and acting.)
  5. HITL purpose? (Human approval for risky actions.)
  6. Checkpoint enables? (Durable resume.)
  7. Step budget prevents? (Infinite loops.)
  8. Idempotent tools for? (Safe retries.)
  9. Supervisor agent? (Delegates to sub-agents.)
  10. Trace purpose? (Audit and debug.)
  11. Plan-and-execute vs ReAct? (Upfront plan vs adaptive loop.)
  12. Durable workflow for? (Long-running multi-step tasks.)
  13. Tool schema validates? (LLM argument structure.)

27. Flashcards​

FrontBack
Agent loopReason-act-observe cycle
Tool callingStructured LLM API invocation
ReActInterleaved reasoning and tools
MCPModel Context Protocol
Tool gatewayPolicy-enforced tool execution
HITLHuman-in-the-loop approval
CheckpointPersisted agent workflow state
Supervisor agentCoordinates specialist agents
Tool budgetMax tool calls per session
Plan-and-executePlan 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

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.
  • 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​

ClaimType
ReAct patternPublished research
MCP protocolAnthropic-led standard—verify current spec
Platform feature setsVendor implementation