DEV Community

Cover image for Agentic AI Customer Support Platform Architecture: A Production‑Ready Design Walkthrough
Amitesh0512
Amitesh0512

Posted on Originally published at amiteshsurwar.com

Agentic AI Customer Support Platform Architecture: A Production‑Ready Design Walkthrough

Agentic AI Customer Support Platform Architecture: A Production‑Ready Design Walkthrough

Quick Answer

Agentic AI Customer Support Platform Architecture: A production‑ready agentic AI support platform uses planner‑first orchestration, HNSW vector search, LLM token limits, circuit‑broken tool calls, and hybrid cache to hit 250 ms latency at 5 k RPS.

Latency Spikes Inflate Ticket Backlog & SLA Breaches

In high‑volume, multi‑region contact centers, the classic rule‑based ticket‑routing stack breaks once the request‑per‑second (RPS) curve climbs past the 300 ms latency budget. The chain—static rules → FAQ bot → LLM → human escalation—creates a feedback loop where every latency spike inflates agent queues and churns customers. The real‑world pain points are:

  • Increased ticket backlog and SLA breaches.
  • Unpredictable Azure bill driven by unbounded LLM calls.
  • Hallucinated answers that erode brand trust.
  • Operational blind spots: no audit trail for tool executions.

Our goal: an agentic AI platform that can ingest a chat, email, or voice query, return a trustworthy answer within 250 ms for 95 % of traffic, and scale to 5 k RPS across US‑East and India‑Central without breaking the budget.

Real‑World Example

Consider a global e‑commerce company that processes ~12 M tickets annually. During the holiday season, the system spikes to 7 k RPS. The support stack must:

  • Lookup FAQ and policy docs with semantic similarity.
  • Execute actions like order lookup, refund initiation, or password reset.
  • Escalate to live agents when confidence < 0.7 or policy rules trigger.
  • Log every LLM call, token usage, and tool execution for compliance.

In production, a 250 ms 95‑tile latency is non‑negotiable; anything above that pushes customers to abandon the chat.

Trade‑offs

Decision Pros Cons
Planner‑First vs Reactive Chain Predictable single decision point, easier to audit. Single point of failure, may miss emergent sub‑tasks.
Tool‑Calling vs Pure LLM Concrete verification, lower hallucination risk. Increased orchestration overhead, more complex error handling.
HNSW vs IVF Flat in Azure AI Search HNSW gives lower latency for high‑dimensional embeddings. Higher index build cost, limited support for dynamic updates.
In‑Memory LRU vs Distributed Redis Zero‑latency for hot data, no external hop. Memory pressure, no cross‑instance sharing.
Serverless Functions vs Container Apps Pay‑as‑you‑go, auto‑scale to zero. Cold‑start latency, limited stateful orchestration.

Tuning Latency Vector Tool Cache Observability

  1. Determine Latency Tolerance: If 250 ms 95‑tile is required, lock in Planner‑First with a fallback chain that triggers only when confidence < 0.6.
  2. Choose Vector Engine: For < 10 k documents, HNSW in Azure AI Search is the sweet spot; for > 100 k, switch to IVF Flat with periodic re‑indexing.
  3. Tool Execution Strategy: Wrap every tool in a circuit breaker, log failures, and promote to escalation after N consecutive errors.
  4. Cache Policy: 50 k LRU entries per worker for embeddings, 12 h Redis TTL for FAQ vectors; monitor hit ratios and adjust.
  5. Observability Layer: Instrument all HTTP calls, LLM invocations, and vector queries with OpenTelemetry; expose 99‑tile latency dashboards.
  6. Scaling Model: Use KEDA‑driven Azure Container Apps for the SK worker (0–200 instances) and Azure Functions for FAQ‑only fallback; keep a separate Redis cache pool for high‑throughput lookups.

When This Fails in Production

  • Vector Search Latency Spike: A sudden 30 % increase in document cardinality or a sub‑optimal HNSW configuration can push query latency past 80 ms, breaking the 250 ms budget.
  • LLM Timeout or Rate‑Limit: Unanticipated OpenAI throttling or network hiccups can cause the planner to exceed the 2 second timeout, triggering the FAQ‑only fallback.
  • Tool Failure Cascades: A single failing API (e.g., order service outage) without a circuit breaker can propagate errors through the chain, forcing unnecessary escalation.
  • Cache Eviction Hotspots: Aggressive LRU eviction in a hot region can lead to repeated embeddings recomputation, inflating token costs.
  • Security Mis‑configuration: Exposing private endpoints or missing tenant‑isolation checks can result in data leakage during tool calls.

Common Mistakes Engineers Make

  • Naïve prompt construction that interpolates user text directly into system prompts, opening the door to prompt injection.
  • Over‑reliance on a single LLM call without a fallback chain, leading to hallucinations when the knowledge base is incomplete.
  • Neglecting to set a circuit breaker around tool calls, causing cascading failures during partial outages.
  • Under‑tuning vector search parameters (k, threshold) for the workload, resulting in either missed matches or unnecessary latency.
  • Failing to instrument observability at the granularity of individual tool calls, making root‑cause analysis in a live system impossible.

Better Approach Based on Experience

In a production deployment for a multinational retailer, we adopted the following refinements:

  • Typed Function Calls with SK: We defined a strict interface for every external API. The LLM receives only the function signature, not the implementation, dramatically reducing injection risk.
  • Hybrid Search (BM25 + Vector): For policy documents that are keyword‑heavy, we enabled hybrid search in Azure AI Search. This kept recall > 95 % while still leveraging semantic similarity for nuanced queries.
  • Adaptive k in Vector Search: We introduced a dynamic k parameter that increases from 5 to 10 when the similarity score falls below 0.75, balancing latency and recall in real time.
  • Circuit‑Breaker‑Enabled Tool Registry: Each tool wrapped in Polly with a 2‑second timeout and a retry policy. On the third consecutive failure, the request is routed to the escalation agent.
  • Multi‑Layer Cache with Auto‑Eviction: Embedding cache size is throttled by memory pressure; when the LRU list exceeds 50 k entries, we evict the least‑recently used items and persist the rest to Redis with a 12 h TTL.
  • Observability & Cost Dashboard: We built a Grafana dashboard that aggregates token usage, vector query latency, and tool call success rates. Alerts fire when daily spend crosses 80 % of the allocated budget.
  • Serverless + Container Hybrid: FAQ‑only fallback runs as an Azure Function (consumption plan) to keep cost low during off‑peak hours, while the SK worker runs in ACA with KEDA scaling based on the LLM request queue length.

Performance Considerations

  • LLM Token Budget: Using GPT‑4o‑mini (0.08 $/k tokens) and limiting prompts to < 200 tokens keeps the LLM cost per request under 0.016 $.
  • Vector Query Cost: Azure AI Search vector queries cost ~0.02 $ per 1 k calls; caching reduces the number of queries by 40 % in a typical workload.
  • Latency Breakdown: In a 250 ms budget, we target < 80 ms for vector search, < 100 ms for LLM call, and < 70 ms for tool execution and orchestration.
  • Throughput Scaling: With ACA scaling to 200 instances and each instance handling ~25 RPS, we comfortably hit 5 k RPS with headroom for spikes.

Scaling Notes

  • Horizontal Scale: Each SK worker is stateless; state is held in Redis or Azure Cosmos DB. This allows us to add pods on demand without session stickiness.
  • Vertical Scale: For bursty traffic, we bump the VM size for Redis to 8 vCPU and 32 GB RAM to avoid cache contention.
  • Observability Scaling: Export OpenTelemetry spans to Azure Monitor with a sampling rate of 5 % to keep ingestion cost low while still capturing 99‑tile latency spikes.
  • Cost‑Control: We enforce a hard cap on LLM usage per user session (e.g., 10 k tokens) and throttle requests that exceed this limit.

How do you keep the 250 ms latency budget at 5 k RPS?

By partitioning the stack: a planner‑first chain for most traffic, HNSW vector search < 80 ms, GPT‑4o‑mini LLM < 100 ms, and tool calls < 70 ms, all backed by an LRU+Redis cache and KEDA‑driven container scaling.

What are the pros and cons of Planner‑First versus Reactive Chain?

Planner‑First gives a single decision point, easier audit and predictable latency; Reactive Chain can discover emergent sub‑tasks but risks higher latency spikes and complex error handling.

How should tool calls be protected against cascading failures?

Wrap each tool in a Polly circuit breaker with a 2‑second timeout, exponential back‑off retries, and fail‑fast escalation after three consecutive failures.

When to choose HNSW over IVF Flat in Azure AI Search?

Use HNSW for < 10 k documents to hit < 80 ms queries; switch to IVF Flat with periodic re‑indexing when document cardinality exceeds 100 k to keep build costs manageable.

What observability strategy ensures 99‑tile latency visibility?

Instrument every HTTP, LLM, and vector call with OpenTelemetry, sample 5 % to Azure Monitor, and surface 99‑tile latency in Grafana dashboards with alerting on budget or latency thresholds.

What to Ship

  • Add a latency vector metric for each support microservice endpoint, and configure an alert that triggers when the 95th percentile latency exceeds 200 ms for more than 5 minutes.
  • Deploy a token‑bucket cache for AI inference responses, pre‑populating it with the most frequent FAQ embeddings; set a max size of 10 k items and route requests that overflow the bucket to a dedicated “cold‑cache” queue.
  • Attach a sidecar observability agent that streams request logs, latency, and ticket‑SLA impact to a central dashboard; enable a rule that auto‑escalates tickets pending > 15 minutes.
  • Wrap all external knowledge‑base calls in a circuit breaker with a 50 ms timeout and a 5‑second cooldown; on open state, route to a cached fallback.
  • Configure horizontal pod autoscaling for the inference service based on the latency‑vector metric, targeting a 90th‑percentile latency < 150 ms.
  • Add a retry‑with‑exponential‑backoff policy (max 3 retries, base 100 ms) for AI inference failures, and log each retry attempt with a unique trace ID.

Conclusion

Building an agentic AI customer support platform that survives production traffic requires a disciplined trade‑off analysis, a robust orchestration layer, and a tight feedback loop between observability and scaling. The architecture outlined above has proven resilient at 5 k RPS, 250 ms latency, and < $0.08 per 1 k tokens in a real‑world, multi‑region deployment. By avoiding the common pitfalls—prompt injection, blind LLM reliance, and unguarded tool calls—you can deliver a high‑quality, cost‑effective support experience that scales with your business.

Related Articles

Top comments (0)