Route customer requests
How the Chat workflow validates requests and chooses a BookWorm specialist.
Audience & Outcome: This guide is for AI engineers and backend developers working on Chat APIServicev1.0.0Chat APIInternal HTTP host for BookWorm's interactive multi-agent chat workflow, agent discovery, and session persistence. Ownerai-capabilities-teamDiagramRepositoryOpen docs. You will learn how incoming conversational messages are validated, classified, disambiguated, and routed across BookWorm’s specialist agents.
Chat APIServicev1.0.0Chat APIInternal HTTP host for BookWorm's interactive multi-agent chat workflow,
agent discovery, and session persistence.
Ownerai-capabilities-teamDiagramRepositoryOpen docs routes every interactive message through a deterministic three-layer workflow rather than an open-ended LLM router. The pipeline validates and truncates input first, evaluates safety, language, scope, and specialist intent with Microsoft-Decision-1, pauses for human-in-the-loop (HITL) disambiguation when confidence is low, and coordinates bounded handoffs across Book AgentAgentv1.0.0Book AgentPrimary conversational book discovery and recommendation specialist that grounds catalog answers in read-only MCP lookup...PublishesAnalyzeText, AnonymizeTextOwnerai-capabilities-teamDiagramRepositoryOpen docs, QA AgentAgentv1.0.0QA AgentRead-only customer support and store-policy specialist that answers operational, shipping, returns, account, and billing...PublishesAnalyzeText, AnonymizeTextOwnerai-capabilities-teamDiagramRepositoryOpen docs, and Rating AgentAgentv1.0.0Rating AgentRead-only review intelligence specialist that summarizes customer feedback over A2A gRPC and map-reduce workflows while ...PublishesAnalyzeText, AnonymizeTextOwnercatalog-experience-teamDiagramRepositoryOpen docs.
Context and motivation
Customer chat messages span distinct domains—book discovery, store policies, and review analysis—alongside empty, non-English, off-topic, or prompt-injection inputs. Sending unscreened messages straight to a general LLM router wastes inference budget, increases latency, and makes routing behavior nondeterministic.
By separating deterministic input hygiene, calibrated classification, explicit low-confidence confirmation, and scoped specialist sub-workflows, BookWorm rejects invalid traffic early and keeps routing observable and testable.
How it works
The visual below traces a customer message through input validation, Microsoft-Decision-1 routing, HITL disambiguation, specialist handoffs, and final response formatting.
Loading graph...
Three-layer routing pipeline
Layer 1: Input validation and resume normalization
Disambiguation resume normalization: If an unanswered disambiguation prompt exists and the user replies in plain text (
1/book,2/qa/support/policy,3/rating/review), the workflow normalizes the reply into a structured tool result so both rich UI clients and plain-text clients resume cleanly.Deterministic hygiene & safety: Tool-result resume turns bypass text validation. For user text turns, the pipeline trims whitespace, rejects empty prompts, screens for prompt-injection and XSS markers, and applies governance prompt-safety policies. Accepted prompts longer than
2,000characters are truncated to1,900characters.Layer 2: Classification and HITL disambiguation
The decision router evaluates four structured questions in order via
Microsoft-Decision-1:Decision check Threshold / rule Outcome when triggered is_safeP(is_safe) < 0.5Short-circuits with an unsafe-input rejection is_englishP(is_english) < 0.5Short-circuits with an English-only notice is_in_scopeP(is_in_scope) < 0.5Short-circuits with an out-of-scope bookstore notice route(Book,QA,Rating)Confidence < 0.6Pauses for user disambiguation between Book, QA, and Rating route(Book,QA,Rating)Confidence >= 0.6Forwards directly to the selected specialist NoteIf
Microsoft-Decision-1returns a partial response, omitted binary guardrails default to1.0and an unanswered route choice defaults to Book AgentAgentv1.0.0Book AgentPrimary conversational book discovery and recommendation specialist that grounds catalog answers in read-only MCP lookup...PublishesAnalyzeText, AnonymizeTextOwnerai-capabilities-teamDiagramRepositoryOpen docs so transient partial responses degrade predictably.Layer 3: Response formatting
If the assistant turn carries a pending client-side UI tool call with empty text, the formatter preserves the tool call without overwriting it. Otherwise, it strips any leaked system markers, collapses excessive blank lines, ensures terminal punctuation, and falls back to a safe rephrase message if no usable text remains.
Specialist selection and handoffs
| Customer intent | Initial specialist | Follow-up handoff behavior |
|---|---|---|
| Book search, recommendations, catalog details, or review questions without a book ID | Book AgentAgentv1.0.0Book AgentPrimary conversational book discovery and recommendation specialist that grounds catalog answers in read-only MCP lookup...PublishesAnalyzeText, AnonymizeTextOwnerai-capabilities-teamDiagramRepositoryOpen docs | Hands off to Rating AgentAgentv1.0.0Rating AgentRead-only review intelligence specialist that summarizes customer feedback over A2A gRPC and map-reduce workflows while ...PublishesAnalyzeText, AnonymizeTextOwnercatalog-experience-teamDiagramRepositoryOpen docs once a single book ID is resolved, or to QA AgentAgentv1.0.0QA AgentRead-only customer support and store-policy specialist that answers operational, shipping, returns, account, and billing...PublishesAnalyzeText, AnonymizeTextOwnerai-capabilities-teamDiagramRepositoryOpen docs for store-policy follow-ups |
| Store policies, shipping, returns, refunds, accounts, orders, or billing | QA AgentAgentv1.0.0QA AgentRead-only customer support and store-policy specialist that answers operational, shipping, returns, account, and billing...PublishesAnalyzeText, AnonymizeTextOwnerai-capabilities-teamDiagramRepositoryOpen docs | Hands off book-specific portions of mixed requests to Book AgentAgentv1.0.0Book AgentPrimary conversational book discovery and recommendation specialist that grounds catalog answers in read-only MCP lookup...PublishesAnalyzeText, AnonymizeTextOwnerai-capabilities-teamDiagramRepositoryOpen docs; never claims live account or order lookup |
| Review summaries or rating analysis when a book catalog ID is already present | Rating AgentAgentv1.0.0Rating AgentRead-only review intelligence specialist that summarizes customer feedback over A2A gRPC and map-reduce workflows while ...PublishesAnalyzeText, AnonymizeTextOwnercatalog-experience-teamDiagramRepositoryOpen docs | Calls Rating APIServicev1.0.0Rating APIInternal HTTP and A2A gRPC service for collecting, listing, deleting, and summarizing customer feedback for Catalog book...PublishesFeedbackCreatedIntegrationEvent, FeedbackDeletedIntegrationEventSubscribesCreateFeedback, DeleteFeedback +3APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs over A2A gRPC; terminal specialist (cannot search the catalog or hand back) |
| Decision | Benefits | Costs and limits |
|---|---|---|
Use Microsoft-Decision-1 instead of an LLM router agent | Produces calibrated probabilities at lower latency and cost than full chat completions | Requires maintaining explicit binary/choice questions and thresholds |
| Separate Layer 1 validation from Layer 2 semantic routing | Blocks empty messages, injections, and oversized payloads before any model call | Truncating prompts over 2,000 characters can clip a trailing book UUID |
Pause for disambiguation when route confidence < 0.6 | Prevents misrouting ambiguous requests to the wrong specialist | Adds one interactive turn before answering ambiguous prompts |
| Keep Rating AgentAgentv1.0.0Rating AgentRead-only review intelligence specialist that summarizes customer feedback over A2A gRPC and map-reduce workflows while ...PublishesAnalyzeText, AnonymizeTextOwnercatalog-experience-teamDiagramRepositoryOpen docs terminal and ID-gated | Avoids duplicating MCP ServerServicev1.0.0MCP ServerInternal stateless Streamable HTTP MCP service that exposes read-only Catalog lookup tools and reusable AI prompts. PublishesListBooksGrpc, GetBookDetailsGrpc +2Ownerai-capabilities-teamDiagramRepositoryOpen docs catalog search inside Rating APIServicev1.0.0Rating APIInternal HTTP and A2A gRPC service for collecting, listing, deleting, and summarizing customer feedback for Catalog book...PublishesFeedbackCreatedIntegrationEvent, FeedbackDeletedIntegrationEventSubscribesCreateFeedback, DeleteFeedback +3APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs | Title-only review requests always route through Book AgentAgentv1.0.0Book AgentPrimary conversational book discovery and recommendation specialist that grounds catalog answers in read-only MCP lookup...PublishesAnalyzeText, AnonymizeTextOwnerai-capabilities-teamDiagramRepositoryOpen docs first |
Rejected alternatives:
- Single LLM supervisor agent: Lacks calibrated probability distributions for a deterministic
< 0.6HITL threshold and increases per-turn latency. - Per-specialist rejection: Duplicating safety, language, and scope prompts across three specialists increases drift and wastes tool invocations.
Related documentation
- Chat Agent OrchestrationFlowv1.0.0Chat Agent OrchestrationA customer submits a conversational request through Storefront; Chat API screens input, routes via a non-LLM classifier ...Ownerai-capabilities-teamView flowOpen docs — End-to-end orchestration flow for Chat APIServicev1.0.0Chat APIInternal HTTP host for BookWorm's interactive multi-agent chat workflow, agent discovery, and session persistence. Ownerai-capabilities-teamDiagramRepositoryOpen docs.
- ADR-007: Use Microsoft Decision-1 for Chat routing, safety gating, and tool selectionDecision Recordv1.0.0ADR-007: Use Microsoft Decision-1 for Chat routing, safety gating, and tool selectionReplaces the generative router agent with a provider-agnostic IDecisionClient backed by Microsoft-Decision-1 for single-...Ownerai-capabilities-teamOpen docs — Decision record for
Microsoft-Decision-1routing. - ADR-001: Keep conversational orchestration within the Chat SystemDecision Recordv1.0.0ADR-001: Keep conversational orchestration within the Chat SystemThe Chat System owns request validation, local specialist handoffs, and response formatting while business records remai...Ownerai-capabilities-teamOpen docs — Orchestration boundary within Chat SystemSystemv1.0.0Chat SystemInternal system that hosts BookWorm's conversational workflow and specialist AI agents for customer support and catalog-...Ownerai-capabilities-teamDiagramRepositoryOpen docs.