Storefront has been decoupled into micro-frontends with a dedicated commerce app and shared shell.

Read the architecture guide →

Route customer requests

How the Chat workflow validates requests and chooses a BookWorm specialist.

Guide

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

  1. 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,000 characters are truncated to 1,900 characters.

  2. Layer 2: Classification and HITL disambiguation

    The decision router evaluates four structured questions in order via Microsoft-Decision-1:

    Decision checkThreshold / ruleOutcome 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
    Note

    If Microsoft-Decision-1 returns a partial response, omitted binary guardrails default to 1.0 and 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.

  3. 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 intentInitial specialistFollow-up handoff behavior
Book search, recommendations, catalog details, or review questions without a book IDBook AgentAgentv1.0.0Book AgentPrimary conversational book discovery and recommendation specialist that grounds catalog answers in read-only MCP lookup...PublishesAnalyzeText, AnonymizeTextOwnerai-capabilities-teamDiagramRepositoryOpen docsHands 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 billingQA AgentAgentv1.0.0QA AgentRead-only customer support and store-policy specialist that answers operational, shipping, returns, account, and billing...PublishesAnalyzeText, AnonymizeTextOwnerai-capabilities-teamDiagramRepositoryOpen docsHands 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 presentRating AgentAgentv1.0.0Rating AgentRead-only review intelligence specialist that summarizes customer feedback over A2A gRPC and map-reduce workflows while ...PublishesAnalyzeText, AnonymizeTextOwnercatalog-experience-teamDiagramRepositoryOpen docsCalls 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)