cd /news/ai-agents/building-production-agent-platforms-… Β· home β€Ί topics β€Ί ai-agents β€Ί article
[ARTICLE Β· art-86658] src=pub.towardsai.net β†— pub= topic=ai-agents verified=true sentiment=Β· neutral

Building Production Agent Platforms: MCP Security, Governance, and AI FinOps

Enterprises deploying AI agents face runaway costs and security risks without proper governance, warns a new technical guide from Kusum Singh. The article details how a single rogue agent can incur $500K per month in expenses and outlines a hierarchical agent architecture with a Model Context Protocol (MCP) router that enforces tool authorization levels, distributed tracing, and AI FinOps practices. It includes a case study of a HIPAA-compliant healthcare AI assistant and provides patterns for multi-tenant isolation, disaster recovery, and platform team operating models.

read15 min views1 publishedAug 4, 2026

Your AI agents are costing you a fortune, and you probably don’t know why.

Without proper governance, agents make unlimited tool calls, invoke expensive models unnecessarily, and bypass security controls you spent months implementing.

In Part 1, we discussed how top enterprises architect AI control planes and LLM gateways. But here’s what we didn’t tell you: agents fundamentally change the game.

Agents aren’t just smarter chatbots. They’re autonomous systems that make decisions, access tools, and consume resources on your behalf. Without governance, a single rogue agent can cost you $500K/month. Without observability, you won’t know it’s happening until the bill arrives.

This is Part 2 of our enterprise AI architecture series. Here’s how leading healthcare companies, financial services firms, and SaaS platforms structure agent platforms for safety, cost control, and observability.

Missed Part 1? Start here: [https://medium.com/@kusumsingh209/enterprise-ai-control-plane-architecture-separating-governance-from-execution-6772a1176f53]. Otherwise, let’s talk agents.

βœ… Agent architecture and autonomous decision-making

βœ… Model Context Protocol (MCP) security and server isolation

βœ… Tool authorization with least-privilege policies

βœ… Agent observability with distributed tracing

βœ… AI FinOps: tracking, attribution, and optimization

βœ… Real-world case study: HIPAA-compliant healthcare AI assistant

βœ… Event bus architecture for async decoupling

βœ… Multi-tenant agent isolation patterns

βœ… Disaster recovery and failover strategies

βœ… Platform team operating model for scale

Production agents follow a hierarchical pattern:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚      SUPERVISOR AGENT       β”‚  ← Decision-makerβ”‚  β€’ Receives user request    β”‚  ← Determines strategyβ”‚  β€’ Plans task breakdown     β”‚  ← Evaluates successβ”‚  β€’ Monitors sub-agents      β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚    PLANNER      β”‚  ← Task orchestrator    β”‚  β€’ Breaks down  β”‚  ← Assigns to workers    β”‚    complex      β”‚  ← Manages workflow    β”‚    into steps   β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚                 β”‚            β”‚             β”‚β”Œβ”€β”€β”€β–Όβ”€β”€β”         β”Œβ”€β”€β”€β–Όβ”€β”€β”     β”Œβ”€β”€β–Όβ”€β”€β”€β”    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”β”‚Workerβ”‚         β”‚Workerβ”‚     β”‚Workerβ”‚    β”‚ Worker β”‚β”‚ API  β”‚         β”‚ DB   β”‚     β”‚ File β”‚    β”‚ Search β”‚β””β”€β”€β”¬β”€β”€β”€β”˜         β””β”€β”€β”€β”¬β”€β”€β”˜     β””β”€β”€β”¬β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜   β”‚                 β”‚            β”‚             β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β”‚             β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚   MCP ROUTER   β”‚  ← Tool gateway             β”‚  (Security,    β”‚  ← Authorization             β”‚   Filtering)   β”‚  ← Audit logging             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β”‚        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚            β”‚            β”‚    β”Œβ”€β”€β”€β–Όβ”€β”€β”    β”Œβ”€β”€β–Όβ”€β”€β”€β”    β”Œβ”€β”€β”€β–Όβ”€β”€β”    β”‚ Tool β”‚    β”‚ Tool β”‚    β”‚ Tool β”‚    β”‚  A   β”‚    β”‚  B   β”‚    β”‚  C   β”‚    β””β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”˜

Key Insight: The MCP Router acts as a tool authorization gateway, enforcing:

Model Context Protocol (MCP) provides standardized tool integration, but security is your responsibility.

Tool Authorization Levels:

Level 1: BLOCKED (No access)Example: Financial system read-write (default deny)
Level 2: TENANT-SPECIFIC (Tenant A can use; Tenant B cannot)Example: Medical records API (HIPAA-compliant customers only)
Level 3: PARAMETERIZED (Can use, but with constraints)Example: SQL queries (read-only, masked results, query plan preview)
Level 4: UNRESTRICTED (Approved for all)Example: Public API queries, weather data
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚   Agent Authorization Matrix β”‚β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€_____β”‚ Agent            β”‚ DB  β”‚ FS  β”‚ API β”‚β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”‚ Medical Summary  β”‚ βœ“   β”‚ βœ—   β”‚ βœ“   β”‚β”‚ Finance Report   β”‚ βœ“   β”‚ βœ“   β”‚ βœ—   β”‚β”‚ General QA       β”‚ βœ—   β”‚ βœ—   β”‚ βœ“   β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”˜

Output Sanitization:

Every tool response is filtered:

1. Check for PII (redact email addresses, phone numbers)2. Remove system internals (stack traces, config details)3. Mask sensitive fields (salary ranges, password hashes)4. Validate format (ensure expected structure)5. Size limit (prevent token explosion)6. Encoding check (prevent injection)

Audit Logging:

Every tool call is logged with:

{  "timestamp": "2024-01-15T10:30:00Z",  "agent_id": "medical-summary-v2",  "tenant_id": "hospital-abc",  "tool_name": "fetch_patient_records",  "parameters": {    "patient_id": "12345",    "fields": ["diagnosis", "medications"]  // Logged  },  "result": {    "status": "success",    "records_returned": 3,    "pii_fields_redacted": 2  },  "cost": {    "tool_call_cost": 0.001,    "token_impact": 250  }}

Single request β†’ multiple agent calls β†’ tool invocations β†’ LLM calls.

Without observability: You can’t see where latency/cost/errors come from.

With distributed tracing (OpenTelemetry):

Request starts (trace_id=abc123)β”‚β”œβ”€ Supervisor decides strategy (span_id=001)β”‚  β”œβ”€ Context: medical diagnosis requiredβ”‚  β”œβ”€ Duration: 150msβ”‚  └─ Decision: Route to medical specialist agentβ”‚β”œβ”€ Planner breaks into tasks (span_id=002)β”‚  β”œβ”€ Task 1: Fetch patient recordsβ”‚  β”œβ”€ Task 2: Retrieve relevant literatureβ”‚  β”œβ”€ Task 3: Generate diagnosisβ”‚  └─ Duration: 300msβ”‚β”œβ”€ Worker 1: Fetch patient records (span_id=003)β”‚  β”œβ”€ Tool: fetch_patient_recordsβ”‚  β”œβ”€ Duration: 200msβ”‚  β”œβ”€ Cost: $0.001β”‚  └─ PII fields redacted: 5β”‚β”œβ”€ Worker 2: Retrieve literature (span_id=004)β”‚  β”œβ”€ Tool: semantic_search (vector DB)β”‚  β”œβ”€ Duration: 400msβ”‚  β”œβ”€ Cost: $0.005β”‚  └─ Results: 10 papersβ”‚β”œβ”€ Worker 3: LLM call (span_id=005)β”‚  β”œβ”€ Model: domain-specialized medical modelβ”‚  β”œβ”€ Input tokens: 2,500β”‚  β”œβ”€ Output tokens: 800β”‚  β”œβ”€ Duration: 1,200msβ”‚  β”œβ”€ Cost: $0.25β”‚  └─ Quality score: 0.94 (groundedness)│└─ Response assembly (span_id=006)   β”œβ”€ Validate output   β”œβ”€ Cite sources (retrieved papers)   β”œβ”€ Add audit trail   └─ Duration: 100ms
Total Request:β”œβ”€ Duration: 2,350msβ”œβ”€ Cost: $0.256β”œβ”€ Tool calls: 2β”œβ”€ LLM calls: 1└─ Audit events: 5

Metrics to Track:

Per-Agent Metrics:β”œβ”€ Success rate (%)β”œβ”€ Average latency (ms)β”œβ”€ Cost per call ($)β”œβ”€ Tool invocations (count)β”œβ”€ Error rate (%)└─ Hallucination rate (%)Per-Tool Metrics:β”œβ”€ Call frequencyβ”œβ”€ Success rateβ”œβ”€ Latency percentiles (p50, p95, p99)β”œβ”€ Cost per call└─ Authorization denials (blocked calls)Per-Tenant Metrics:β”œβ”€ Total cost ($)β”œβ”€ Budget remainingβ”œβ”€ Agent performance└─ Compliance events (PII, auth failures)

Modern agents benefit from reasoning models:

Quick Response Agent (GPT-4o-mini)β”œβ”€ Good for: FAQ, routing, categorizationβ”œβ”€ Cost: $0.15/M tokens└─ Latency: 400msStandard Agent (Claude 3.5 Sonnet)β”œβ”€ Good for: General-purpose, analysisβ”œβ”€ Cost: $3.00/M tokens└─ Latency: 800msReasoning Agent (o1 or similar)β”œβ”€ Good for: Complex reasoning, coding, mathβ”œβ”€ Cost: $15/M tokensβ”œβ”€ Latency: 5,000ms (slower but higher quality)└─ Use case: When accuracy > speed

When to use reasoning models:

Evaluation Pipeline:

Agent generates response    ↓LLM Judge (separate model)    β”œβ”€ Groundedness: "Is answer supported by retrieved facts?"    β”œβ”€ Relevance: "Does answer address the question?"    β”œβ”€ Safety: "Any hallucinations or harmful content?"    └─ Compliance: "Does answer respect privacy/regulations?"    ↓Scoring (0-100)    β”œβ”€ 90+: Confident, serve to user    β”œβ”€ 70-89: Moderate, flag for review    └─ <70: Low confidence, escalate to human

The Scenario: An agent makes 10 tool calls per request (normal). Each tool call costs $0.01. Your platform gets 10,000 requests/day.

Daily cost: 10,000 Γ— 10 Γ— $0.01 = $1,000/dayMonthly cost: $1,000 Γ— 30 = $30,000/monthAnnual cost: $30,000 Γ— 12 = $360,000/year

Now add in:

Your $30K/month becomes $50K-100K/month quickly.

Without governance: You won’t realize this until the bill arrives.

With AI FinOps:

Budget Tracking (Real-time)    β†“β”œβ”€ Per-tenant spending ($X of $50K budget)β”œβ”€ Per-agent cost attribution (Medical Agent: $12K, Finance: $8K)β”œβ”€ Per-tool cost (DB queries: $5K, LLM calls: $15K)└─ Cost trends (↑ 15% this week, investigate why)    ↓Anomaly Detection    β”œβ”€ Agent A suddenly costs 10x normal    β”œβ”€ Tool B hit rate dropped (more calls needed)    └─ Outlier request (1 request = $500)    ↓Automatic Actions    β”œβ”€ Alert ops team    β”œβ”€ Downgrade model (Claude β†’ GPT-4o-mini)    β”œβ”€ Disable expensive agent    └─ Escalate for approval

FinOps Implementation:

python

python
class AgentFinOps:    def track_call(self, agent_id, tenant_id, cost):        # Real-time budget check        remaining = self.get_budget(tenant_id)        if remaining - cost < 0:            self.trigger_alert("Budget exceeded")            return "BLOCKED"                # Track cost attribution        self.log_cost(agent_id, tenant_id, cost)                # Check for anomalies        avg = self.get_agent_avg_cost(agent_id)        if cost > avg * 3:            self.flag_anomaly(agent_id, cost, avg)                return "ALLOWED"

Production platforms decouple agent execution from downstream processing:

Agent Makes LLM Call    β†“β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚      SYNCHRONOUS (User waits)      β”‚β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ ─│ 1. LLM call (500ms)                β”‚β”‚ 2. Tool invocation (200ms)         β”‚β”‚ 3. Response assembly (100ms)       β”‚β”‚ β†’ Total: 800ms (user-facing)       β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚  EVENT BUS (Kafka/SQS/Pub-Sub)    β”‚β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”‚ Publish events asynchronously:    β”‚β”‚ β”œβ”€ agent.call.completed           β”‚β”‚ β”œβ”€ cost.accrued                   β”‚β”‚ β”œβ”€ tool.called                    β”‚β”‚ └─ response.generated             β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚                     β”‚           β”‚            β”‚β”Œβ”€β”€β”€β–Όβ”€β”€β”           β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”  β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”β”‚Billingβ”‚          β”‚Audit   β”‚  β”‚Qualityβ”‚  β”‚Complianceβ”‚β”‚Agent  β”‚          β”‚Logger  β”‚  β”‚Scorer β”‚  β”‚Checker   β”‚β””β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
These run asynchronously without blocking user response.

Benefits:

Modern platforms use feature flags to control agent behavior:

json

{  "medical_summary_agent": {    "enabled": true,    "version": "2.1",    "approval_required": true,    "approval_model": "claude-opus",  // LLM judge for approval    "max_tool_calls": 10,    "budget_cap": 100,  // $100/request max    "allowed_tools": ["patient_db", "medical_literature"],    "blocked_users": [],    "rollout_percentage": 75,    "fallback_agent": "general_qa"  }}

Use Cases:

Agents must respect data boundaries:

USER REQUEST (contains sensitive data)    β†“β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚  DATA CLASSIFICATION        β”‚β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”‚ Input contains:             β”‚β”‚ β”œβ”€ Patient name (PHI)       β”‚β”‚ β”œβ”€ Medical history (PHI)    β”‚β”‚ └─ Social security (PII)    β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚  PRIVACY BOUNDARY CHECK   β”‚β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”‚ Can agent process PHI?    β”‚β”‚ β”œβ”€ Is agent HIPAA-cert?   β”‚β”‚ β”œβ”€ Is tenant healthcare?  β”‚β”‚ └─ Is consent logged?     β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚    β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚  APPROVED βœ“    β”‚  β†’ Process request    β”‚  BLOCKED βœ—     β”‚  β†’ Reject + escalate to human    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Example Policy (HIPAA):

IF request contains PHI:  THEN require:    - HIPAA-certified agent    - Healthcare tenant    - Logged consent    - Audit trail (immutable log)    - Encryption in transit + at restELSE:  ALLOW processing

Critical decisions require human approval:

Agent generates response    ↓Risk Score (LLM judge)    β”œβ”€ Low risk (score < 0.3): Serve immediately    β”œβ”€ Medium risk (0.3-0.7): Flag for review    └─ High risk (> 0.7): Require approval        ↓    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚  APPROVAL QUEUE         β”‚    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€    β”‚ 1. Medical diagnosis    β”‚    β”‚    (Cost: $25)          β”‚    β”‚    Requested: Dr. Smith β”‚    β”‚    Status: Pending      β”‚    β”‚                         β”‚    β”‚ 2. Financial trade      β”‚    β”‚    (Cost: $50)          β”‚    β”‚    Requested: Trader B  β”‚    β”‚    Status: Pending      β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚        β”Œβ”€β”€β”€β”΄β”€β”€β”€β”        β”‚       β”‚    β”Œβ”€β”€β”€β–Όβ”€-─┐ β”Œβ–Όβ”€β”€β”€-─┐    β”‚Approveβ”‚ β”‚Rejectβ”‚    β””β”€β”€β”€β”€β”€β”€β”€β”˜ └─────-β”˜        β”‚       β”‚    Response  Alternative    Served    Method

When to require approval:

Scenario: A patient submits a request via a healthcare app.

Step 1: REQUEST RECEPTIONInput: "I've had a persistent cough for 3 weeks. My temp is 101F.         Should I see a doctor?"
Metadata: β”œβ”€ Tenant: MedCare Hospitalβ”œβ”€ Patient ID: 12345β”œβ”€ Region: US-East (HIPAA-compliant)└─ Timestamp: 2024-01-15 10:30:00
↓ [Route through gateway pipeline]
Step 2: AUTHENTICATION & COMPLIANCE CHECKβ”œβ”€ API key valid βœ“β”œβ”€ Tenant authorization βœ“β”œβ”€ HIPAA-certified infrastructure βœ“β”œβ”€ Data residency (US-only) βœ“β””β”€ Patient consent logged βœ“
↓ [Approved for processing]
Step 3: AGENT SELECTIONAnalysis:β”œβ”€ Request type: Medical diagnosisβ”œβ”€ Risk level: High (medical decision)β”œβ”€ Approval required: Yesβ”œβ”€ Recommended agent: Medical Summary Agent v2.1
Selected Agent: Medical Summary Agentβ”œβ”€ Model: Domain-specialized medical modelβ”œβ”€ Allowed tools: [FHIR API, Medical literature, Patient history]β”œβ”€ Approval model: Claude Opus└─ Max tool calls: 10
↓ [Agent starts execution]
Step 4: AGENT EXECUTION - SUPERVISOR DECIDES STRATEGYSupervisor: "This is a symptom assessment. I need:  1. Patient medical history (chronic conditions, meds)  2. Current vital signs context  3. Differential diagnosis reasoning"
Decision: Route to medical specialist agent (not general QA)Confidence: 0.92
↓
Step 5: PLANNER BREAKS INTO TASKSTask 1: Fetch patient medical historyTask 2: Retrieve relevant medical literatureTask 3: Generate differential diagnosisTask 4: Assess risk level (needs doctor visit?)Task 5: Generate patient-friendly response
↓
Step 6: WORKER 1 - FETCH PATIENT HISTORYTool call: fetch_patient_records via FHIR APIβ”œβ”€ Patient ID: 12345β”œβ”€ Fields: ['chronic_conditions', 'medications', 'allergies']└─ Scope: Read-only (least privilege)
Response:β”œβ”€ Chronic conditions: Noneβ”œβ”€ Current medications: Allergy medicineβ”œβ”€ Allergies: Penicillinβ”œβ”€ Recent visits: Flu vaccination 2 weeks ago└─ Tool cost: $0.01, Latency: 150ms
↓
Step 7: WORKER 2 - SEMANTIC SEARCH MEDICAL LITERATURETool call: semantic_search (vector DB)β”œβ”€ Query: "persistent cough fever 3 weeks differential diagnosis"β”œβ”€ Search depth: Medical journals + guidelines└─ Limit: Top 10 results
Results:β”œβ”€ Paper 1: "Respiratory infections during flu season" (match: 0.92)β”œβ”€ Paper 2: "COVID-19 symptom timeline" (match: 0.88)β”œβ”€ Paper 3: "Bronchitis vs pneumonia" (match: 0.85)β”œβ”€ ... 7 more results└─ Tool cost: $0.005, Latency: 300ms
↓
Step 8: WORKER 3 - LLM MEDICAL ANALYSISModel: Domain-specialized medical modelInput:β”œβ”€ Patient presentation (cough, fever 101F)β”œβ”€ Medical history (no chronic conditions)β”œβ”€ Medications (allergy med)β”œβ”€ Retrieved literature (10 papers)└─ Constraints: HIPAA, patient-friendly language
Processing:β”œβ”€ Input tokens: 2,500β”œβ”€ Processing time: 1,200msβ”œβ”€ Output tokens: 800└─ Cost: $0.25
Output:"Based on your symptoms (persistent cough, fever for 3 weeks), the most likely causes are:
1. Viral infection (most likely, matches current flu patterns)2. Bronchitis (secondary possibility)3. Pneumonia (less likely, but monitor for difficulty breathing)
RECOMMENDATION: You should see a doctor within 24 hours. Your symptoms don't suggest an emergency, but persistent fever + cough warrants professional evaluation.
When to seek immediate care:- Difficulty breathing- Chest pain- Confusion- Blood in sputum"
Quality score (LLM judge): 0.94 (groundedness)Safety score (toxicity, hallucination): 0.97Compliance score: HIPAA compliant βœ“
↓
Step 9: APPROVAL WORKFLOWRisk score: 0.68 (medium-high)Reason: Clinical decision, needs doctor oversight
Approval model (Claude Opus): Reviews responseβ”œβ”€ Medical accuracy: βœ“ Supported by literatureβ”œβ”€ Safety: βœ“ No contradictions to guidelinesβ”œβ”€ Completeness: βœ“ Addresses all symptoms└─ Appropriateness: βœ“ Recommends doctor visit
Approval decision: APPROVED βœ“Approval time: 400ms
↓
Step 10: RESPONSE ASSEMBLY & AUDITFinal response:β”œβ”€ Clinical summary (above)β”œβ”€ Cited sources (medical papers retrieved)β”œβ”€ "Please consult with a healthcare provider" disclaimerβ”œβ”€ Audit trail (immutable log of processing)└─ Timestamp of approval
Audit event logged:{  "event_id": "evt_abc123",  "timestamp": "2024-01-15T10:30:45Z",  "patient_id": "12345",  "agent": "medical_summary_v2.1",  "tools_called": [    {"tool": "fetch_patient_records", "status": "success", "cost": 0.01},    {"tool": "semantic_search", "status": "success", "cost": 0.005},    {"tool": "llm_model", "status": "success", "tokens": 3300, "cost": 0.25}  ],  "approval_status": "approved",  "risk_score": 0.68,  "total_cost": 0.265,  "compliance_checks": ["HIPAA", "GDPR", "consent"],  "response_latency_ms": 2450}
↓
Step 11: RESPONSE TO PATIENT"Based on your symptoms, I recommend seeing a doctor within 24 hours.[Clinical summary above]
⚠️ IMPORTANT: This is not medical advice. Please consult with a healthcare professional for diagnosis and treatment."
↓
Step 12: ASYNC PROCESSING (Doesn't block user response)Event bus publishes:β”œβ”€ cost.accrued ($0.265)β”œβ”€ agent.call.completedβ”œβ”€ audit.event.loggedβ”œβ”€ quality.score.recorded (0.94)└─ compliance.check.passed
Subscribers (process async):β”œβ”€ Billing service: Update customer invoiceβ”œβ”€ Analytics service: Track agent performanceβ”œβ”€ Compliance service: Archive immutable audit log└─ Monitoring service: Update dashboards
FINAL METRICS:β”œβ”€ Total latency: 2,450msβ”œβ”€ User response time: <500ms (async doesn't block)β”œβ”€ Total cost: $0.265β”œβ”€ Tool calls: 2β”œβ”€ LLM calls: 1 (domain-specialized)β”œβ”€ Approval: Human reviewed βœ“β”œβ”€ Compliance: HIPAA βœ“β””β”€ Safety: No hallucinations βœ“

βœ… Control plane enforced HIPAA policies before request reached agent

βœ… LLM gateway routed to domain-specialized medical model (not generic)

βœ… Tool authorization prevented access to unauthorized databases

βœ… Observability tracked every step (latency, cost, quality)

βœ… Approval workflow ensured human review of medical decision

βœ… Audit logging created HIPAA-compliant immutable record

βœ… Async processing kept user response fast (<500ms)

βœ… Cost tracking attributed all spending to this patient interaction

Without this architecture? The agent might make unlimited tool calls, use wrong models, skip approval, and generate non-compliant responses. You’d have no audit trail.

SaaS platforms must isolate tenant data:

Tenant A (Healthcare Provider)β”œβ”€ Can access: Medical records, patient dataβ”œβ”€ Budget: $10,000/monthβ”œβ”€ Agents: Medical Summary, Diagnosis Assistant└─ Compliance: HIPAATenant B (Finance Company)β”œβ”€ Can access: Trading data, market researchβ”œβ”€ Budget: $50,000/monthβ”œβ”€ Agents: Trading Bot, Risk Analyzer└─ Compliance: SOXShared Infrastructure (Isolated)β”œβ”€ Separate namespaces in K8sβ”œβ”€ Separate Redis keys (tenant:data:...)β”œβ”€ Row-level security in databasesβ”œβ”€ Separate audit logs (immutable, tenant-specific)└─ Network policies (tenant traffic isolated)

Isolation Levels:

Level 1: Logical isolation (same database, row-level filtering)Level 2: Database isolation (separate databases, same cluster)Level 3: Infrastructure isolation (separate Kubernetes namespaces)Level 4: Physical isolation (separate cloud accounts / regions)

For healthcare: Recommend Level 3+ (namespace isolation, separate compute)

Production systems plan for failures:

PRIMARY REGION (US-EAST)β”œβ”€ Active agentsβ”œβ”€ Primary LLM gatewayβ”œβ”€ Hot cache (Redis cluster)└─ Primary database (PostgreSQL with replication)                    β”‚                    β”‚ (Network partition)                    β”‚                    X (Failure detected)FALLBACK REGION (US-WEST)β”œβ”€ Standby agents (hot standby)β”œβ”€ Secondary LLM gateway (ready to activate)β”œβ”€ Replica cache (sync'd from primary)└─ Replica database (read-only, promoted to primary)Failover Process:1. Health check fails on primary (3x failures, 5 sec timeout)2. Circuit breaker opens3. DNS updates point to US-WEST4. Replica database promoted to primary5. Standby agents become active6. Traffic redirects to secondary gatewayβ†’ Total failover time: <30 secondsRTO (Recovery Time Objective): 30 secondsRPO (Recovery Point Objective): 5 seconds

Enterprise platforms need comprehensive observability:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚  APPLICATION LAYER METRICS      β”‚β”‚  β”œβ”€ Agent success rate          β”‚β”‚  β”œβ”€ End-to-end latency(p50,p95,p99)β”‚  β”œβ”€ Cost per request            β”‚β”‚  └─ Approval wait time          β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚  GATEWAY LAYER METRICS          β”‚β”‚  β”œβ”€ Cache hit rate (%)          β”‚β”‚  β”œβ”€ Router decision time        β”‚β”‚  β”œβ”€ Fallback frequency          β”‚β”‚  └─ Provider latency            β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚  PROVIDER METRICS               β”‚β”‚  β”œβ”€ Availability (uptime %)     β”‚β”‚  β”œβ”€ Error rate per provider     β”‚β”‚  β”œβ”€ Latency percentiles         β”‚β”‚  └─ Cost per provider           β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚        β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚  ALERTS       β”‚        β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€        β”‚ P95 > 5s?     β”‚        β”‚ Cost > 10%?   β”‚        β”‚ Error > 1%?   β”‚        β”‚ Cache < 20%?  β”‚        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Dashboard Examples:

Dashboard 1: Financial (CFO/Finance)

Dashboard 2: Operations (DevOps/SRE)

Dashboard 3: Security (Security/Compliance)

For scale, you need a dedicated platform team:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚  PLATFORM TEAM STRUCTURE    β”‚β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”‚                             β”‚β”‚  Platform Lead              β”‚β”‚  └─ Owns platform roadmap   β”‚β”‚                             β”‚β”‚  Infrastructure (2-3 eng)   β”‚β”‚  └─ K8s, gateway, DR        β”‚β”‚                             β”‚β”‚  Governance (1-2 eng)       β”‚β”‚  └─ Policies, registries    β”‚β”‚                             β”‚β”‚  Observability (1-2 eng)    β”‚β”‚  └─ Metrics, dashboards     β”‚β”‚                             β”‚β”‚  Security (1 eng)           β”‚β”‚  └─ MCP security, complianceβ”‚β”‚                             β”‚β”‚  FinOps (0.5 eng)           β”‚β”‚  └─ Cost tracking, billing  β”‚β”‚                             β”‚β”‚  Developer Advocate (1 eng) β”‚β”‚  └─ Agent framework docs    β”‚β”‚                             β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

RACI Matrix:

TaskPlatformApp TeamSecurityOpsDeploy new agent-RCAGateway updateA-CRSecurity policyRCA-Cost optimizationAC-RIncident responseCCCA

Agents fundamentally change the economics and governance of AI systems:

Without governance:

With governance:

Agents aren’t just β€œsmarter LLM calls.” They’re autonomous systems that require:

βœ… Supervisor/Planner pattern (hierarchical decision-making)

βœ… MCP Router (tool authorization gateway)

βœ… Approval workflows (human-in-the-loop for high-risk decisions)

βœ… Distributed tracing (visibility into multi-step execution)

βœ… AI FinOps (track, attribute, and optimize costs)

βœ… Compliance boundaries (respect data privacy)

βœ… Disaster recovery (failover when primary fails)

βœ… Platform governance (centralized policies)

You’ve now read the complete enterprise AI architecture series:

Next steps:

Questions? Drop a comment. I read every one and respond to implementation questions.

Sharing? If this helped your team, share it with fellow architects and engineers.

Building this? Document your journey. The enterprise AI ops space needs more real-world patterns.

Published: Part: 2 of 2 Previous: Enterprise AI Control Plane Architecture (Part 1) Series Complete: Thanks for reading the full enterprise AI architecture guide!

If you implement this architecture, document your decisions:

TITLE: Implement Weighted Scoring RouterCONTEXT: Need intelligent model selectionDECISION: Use capability (30%) + cost (10%) + latency (15%) +           compliance (20%) + availability (10%) + quality (15%)RATIONALE: Balances multiple concerns, tunable weights per use caseTRADEOFFS: Slightly more complex than simple rules
TITLE: Enforce HIPAA Boundary for Medical AgentsCONTEXT: Healthcare tenant requires HIPAA complianceDECISION: Agents can only access HIPAA-certified tools,          responses require approval before deliveryRATIONALE: Prevents unauthorized data access, ensures complianceTRADEOFFS: Slower response time (approval workflow)
TITLE: Track Costs at Tool-Call GranularityCONTEXT: Need to attribute costs to specific agents/tenantsDECISION: Log every tool call + LLM invocation with cost metadataRATIONALE: Enables accurate chargeback, anomaly detectionTRADEOFFS: Storage + query overhead (manageable with aggregation)

Enterprise AI isn’t just about deploying smart systems. It’s about building smart systems that:

This series gave you the architecture patterns. The implementation is yours.

Good luck building. πŸš€

Building Production Agent Platforms: MCP Security, Governance, and AI FinOps was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

── more in #ai-agents 4 stories Β· sorted by recency
── more on @kusum singh 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/building-production-…] indexed:0 read:15min 2026-08-04 Β· β€”