1:"$Sreact.fragment" 2:I[97333,["/_next/static/chunks/51cf3403df3ab8db.js","/_next/static/chunks/e1faea17a9e9ed14.js"],""] 50:I[39271,["/_next/static/chunks/1f465ca74a71847d.js","/_next/static/chunks/6628e8793cd41c7c.js"],"OutletBoundary"] 51:"$Sreact.suspense" 0:{"buildId":"3CCc4JxoD54WNKxdcWa8x","rsc":["$","$1","c",{"children":[["$","div",null,{"className":"min-h-screen bg-[var(--bg)]","children":["$","article",null,{"className":"section-container pt-32 max-w-3xl","children":[["$","$L2",null,{"href":"/blog","className":"inline-flex items-center gap-2 text-sm text-muted hover:text-accent transition-colors mb-8","children":[["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","width":24,"height":24,"viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","strokeWidth":2,"strokeLinecap":"round","strokeLinejoin":"round","className":"lucide lucide-arrow-left h-4 w-4","aria-hidden":"true","children":[["$","path","1l729n",{"d":"m12 19-7-7 7-7"}],["$","path","x3x0zl",{"d":"M19 12H5"}],"$undefined"]}],"Back to Blog"]}],["$","header",null,{"className":"mb-10","children":[["$","div",null,{"className":"flex flex-wrap items-center gap-3 text-sm text-muted mb-4","children":[["$","span",null,{"className":"inline-flex items-center gap-1.5","children":[["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","width":24,"height":24,"viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","strokeWidth":2,"strokeLinecap":"round","strokeLinejoin":"round","className":"lucide lucide-calendar h-3.5 w-3.5","aria-hidden":"true","children":[["$","path","1cmpym",{"d":"M8 2v4"}],["$","path","4m81vk",{"d":"M16 2v4"}],["$","rect","1hopcy",{"width":"18","height":"18","x":"3","y":"4","rx":"2"}],["$","path","8toen8",{"d":"M3 10h18"}],"$undefined"]}],"February 20, 2025"]}],["$","span",null,{"className":"inline-flex items-center gap-1.5","children":[["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","width":24,"height":24,"viewBox":"0 0 24 24","fill":"none","stroke":"currentColor","strokeWidth":2,"strokeLinecap":"round","strokeLinejoin":"round","className":"lucide lucide-clock h-3.5 w-3.5","aria-hidden":"true","children":[["$","circle","1mglay",{"cx":"12","cy":"12","r":"10"}],["$","path","mmk7yg",{"d":"M12 6v6l4 2"}],"$undefined"]}],"6 min read"]}]]}],["$","h1",null,{"className":"font-[family-name:var(--font-outfit)] text-3xl font-bold tracking-tight text-foreground sm:text-4xl lg:text-5xl","children":"Multi-Agent Systems in Production: Patterns That Actually Work"}],["$","div",null,{"className":"mt-4 flex flex-wrap gap-2","children":[["$","span","Multi-Agent Systems",{"className":"rounded-full border border-[var(--card-border)] bg-[var(--card-bg)] px-3 py-1 text-xs text-muted","children":"Multi-Agent Systems"}],["$","span","LangGraph",{"className":"rounded-full border border-[var(--card-border)] bg-[var(--card-bg)] px-3 py-1 text-xs text-muted","children":"LangGraph"}],["$","span","AI Architecture",{"className":"rounded-full border border-[var(--card-border)] bg-[var(--card-bg)] px-3 py-1 text-xs text-muted","children":"AI Architecture"}],["$","span","Production AI",{"className":"rounded-full border border-[var(--card-border)] bg-[var(--card-bg)] px-3 py-1 text-xs text-muted","children":"Production AI"}],["$","span","System Design",{"className":"rounded-full border border-[var(--card-border)] bg-[var(--card-bg)] px-3 py-1 text-xs text-muted","children":"System Design"}]]}]]}],["$","div",null,{"className":"prose-custom","children":[["$","h1",null,{"className":"font-[family-name:var(--font-outfit)] text-3xl font-bold tracking-tight text-foreground mt-10 mb-4 first:mt-0","children":"Multi-Agent Systems in Production: Patterns That Actually Work"}],"\n",["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":"After building and deploying multi-agent systems that handle thousands of requests daily in healthcare and customer support, I've developed strong opinions about what works and what doesn't. This post covers the patterns that survived contact with production reality."}],"\n",["$","h2",null,{"className":"font-[family-name:var(--font-outfit)] text-2xl font-semibold tracking-tight text-foreground mt-10 mb-3","children":"The Problem with Single-Agent Architectures"}],"\n",["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":"Most tutorials show you a single LLM agent with a bag of tools. This works great for demos. In production, it falls apart because:"}],"\n","$L3","\n","$L4","\n","$L5","\n","$L6","\n","$L7","\n","$L8","\n","$L9","\n","$La","\n","$Lb","\n","$Lc","\n","$Ld","\n","$Le","\n","$Lf","\n","$L10","\n","$L11","\n","$L12","\n","$L13","\n","$L14","\n","$L15","\n","$L16","\n","$L17","\n","$L18","\n","$L19","\n","$L1a","\n","$L1b","\n","$L1c","\n","$L1d","\n","$L1e","\n","$L1f","\n","$L20","\n","$L21","\n","$L22","\n","$L23","\n","$L24","\n","$L25","\n","$L26","\n","$L27","\n","$L28","\n","$L29","\n","$L2a","\n","$L2b","\n","$L2c"]}]]}]}],["$L2d"],"$L2e"]}],"loading":null,"isPartial":false} 3:["$","ol",null,{"className":"list-decimal list-inside space-y-2 text-muted mb-5","children":["\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Context window pollution"}],": One agent handling everything means every tool description, every piece of context, competes for attention"]}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"No separation of concerns"}],": A billing question and a technical support question require completely different context, tools, and guardrails"]}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Debugging nightmares"}],": When something goes wrong, you're searching through one massive chain of thought"]}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Inconsistent quality"}],": An agent that's great at classification might be terrible at generation, and vice versa"]}],"\n"]}] 4:["$","h2",null,{"className":"font-[family-name:var(--font-outfit)] text-2xl font-semibold tracking-tight text-foreground mt-10 mb-3","children":"Pattern 1: The Router-Specialist Architecture"}] 5:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":"This is the pattern I use most. A lightweight router agent classifies the request and delegates to specialized agents."}] 6:["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"className":"overflow-x-auto rounded-xl border border-[var(--card-border)] bg-[var(--surface)] p-4 text-sm mb-5","style":{"backgroundColor":"#22272e","color":"#adbac7"},"tabIndex":"0","data-language":"python","data-theme":"github-dark-dimmed","children":["$","code",null,{"className":"rounded bg-[var(--card-bg)] px-1.5 py-0.5 text-sm font-mono text-accent","data-language":"python","data-theme":"github-dark-dimmed","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":"from"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" langgraph.graph "}],["$","span",null,{"style":{"color":"#F47067"},"children":"import"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" StateGraph, "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"END"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":"from"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" typing "}],["$","span",null,{"style":{"color":"#F47067"},"children":"import"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" TypedDict, Literal"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":"class"}],["$","span",null,{"style":{"color":"#F69D50"},"children":" OrchestratorState"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"("}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"TypedDict"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"):"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" messages: "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"list"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" classification: "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"str"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" specialist_response: "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"str"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" confidence: "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"float"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" iteration: "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"int"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":"def"}],["$","span",null,{"style":{"color":"#DCBDFB"},"children":" router"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"(state: OrchestratorState) -> OrchestratorState:"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"\"\"Lightweight classifier — fast model, minimal prompt.\"\"\""}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" classification "}],["$","span",null,{"style":{"color":"#F47067"},"children":"="}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" classify_with_gpt4_mini("}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" state["}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"messages\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"]["}],["$","span",null,{"style":{"color":"#F47067"},"children":"-"}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"1"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"],"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F69D50"},"children":" categories"}],["$","span",null,{"style":{"color":"#F47067"},"children":"="}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"["}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"medical_query\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":", "}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"billing\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":", "}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"scheduling\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":", "}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"general\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"]"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#ADBAC7"},"children":" )"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" return"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" **"}],"$L2f"]}],"\n","$L30","\n","$L31","\n","$L32","\n","$L33","\n","$L34","\n","$L35","\n","$L36","\n","$L37","\n","$L38","\n","$L39","\n","$L3a","\n","$L3b","\n","$L3c","\n","$L3d","\n","$L3e","\n","$L3f","\n","$L40","\n","$L41","\n","$L42","\n","$L43"]}]}]}] 7:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":["$","strong",null,{"className":"font-semibold text-foreground","children":"Why this works:"}]}] 8:["$","ul",null,{"className":"list-disc list-inside space-y-2 text-muted mb-5","children":["\n",["$","li",null,{"className":"text-base leading-relaxed","children":"The router uses a fast, cheap model (GPT-4 mini or Claude Haiku)"}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":"Each specialist has its own tailored prompt, tools, and guardrails"}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":"Adding a new category means adding one specialist — no changes to existing agents"}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":"Classification confidence below threshold triggers clarification instead of guessing"}],"\n"]}] 9:["$","h2",null,{"className":"font-[family-name:var(--font-outfit)] text-2xl font-semibold tracking-tight text-foreground mt-10 mb-3","children":"Pattern 2: The Pipeline Architecture"}] a:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":"For tasks with sequential stages, I use a pipeline where each agent's output feeds into the next."}] b:["$","pre",null,{"className":"overflow-x-auto rounded-xl border border-[var(--card-border)] bg-[var(--surface)] p-4 text-sm mb-5","children":["$","code",null,{"className":"rounded bg-[var(--card-bg)] px-1.5 py-0.5 text-sm font-mono text-accent","children":"[Document Ingestion] → [Entity Extraction] → [Analysis] → [Report Generation]\n"}]}] c:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":["$","strong",null,{"className":"font-semibold text-foreground","children":"Real-world example: Medical Report Analysis"}]}] d:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":"In our healthcare platform, when a doctor uploads a patient report:"}] e:["$","ol",null,{"className":"list-decimal list-inside space-y-2 text-muted mb-5","children":["\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Extraction Agent"}],": Pulls structured data (lab values, medications, diagnoses) from unstructured text"]}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Validation Agent"}],": Cross-references extracted data against medical ontologies (ICD-10, SNOMED)"]}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Analysis Agent"}],": Identifies patterns, flags abnormalities, suggests differential diagnoses"]}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Report Agent"}],": Generates a structured clinical summary for the doctor"]}],"\n"]}] f:["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"className":"overflow-x-auto rounded-xl border border-[var(--card-border)] bg-[var(--surface)] p-4 text-sm mb-5","style":{"backgroundColor":"#22272e","color":"#adbac7"},"tabIndex":"0","data-language":"python","data-theme":"github-dark-dimmed","children":["$","code",null,{"className":"rounded bg-[var(--card-bg)] px-1.5 py-0.5 text-sm font-mono text-accent","data-language":"python","data-theme":"github-dark-dimmed","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":"def"}],["$","span",null,{"style":{"color":"#DCBDFB"},"children":" extraction_node"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"(state):"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"\"\"Extract structured medical entities from raw text.\"\"\""}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" extracted "}],["$","span",null,{"style":{"color":"#F47067"},"children":"="}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" medical_ner_chain.invoke({"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"report\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": state["}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"raw_report\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"],"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"extraction_schema\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"MEDICAL_ENTITY_SCHEMA"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":","}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#ADBAC7"},"children":" })"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" return"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" {"}],["$","span",null,{"style":{"color":"#F47067"},"children":"**"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"state, "}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"entities\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": extracted, "}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"stage\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": "}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"extraction_complete\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"}"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":"def"}],["$","span",null,{"style":{"color":"#DCBDFB"},"children":" validation_node"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"(state):"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"\"\"Validate extracted entities against medical ontologies.\"\"\""}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" validated "}],["$","span",null,{"style":{"color":"#F47067"},"children":"="}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" []"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" for"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" entity "}],["$","span",null,{"style":{"color":"#F47067"},"children":"in"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" state["}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"entities\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"]:"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" is_valid "}],["$","span",null,{"style":{"color":"#F47067"},"children":"="}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" validate_against_ontology(entity)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" validated.append({"}],["$","span",null,{"style":{"color":"#F47067"},"children":"**"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"entity, "}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"validated\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": is_valid})"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" return"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" {"}],["$","span",null,{"style":{"color":"#F47067"},"children":"**"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"state, "}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"entities\""}],"$L44","$L45","$L46","$L47","$L48"]}]]}]}]}] 10:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Key insight"}],": Each agent in the pipeline can use a different model. The extraction agent might use a fine-tuned model, while the analysis agent uses GPT-4 with a carefully crafted prompt."]}] 11:["$","h2",null,{"className":"font-[family-name:var(--font-outfit)] text-2xl font-semibold tracking-tight text-foreground mt-10 mb-3","children":"Pattern 3: The Debate Architecture"}] 12:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":"For high-stakes decisions, I use multiple agents that independently analyze the same input and then a synthesis agent resolves disagreements."}] 13:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":"This pattern is critical in our medical AI system where diagnostic accuracy matters:"}] 14:["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"className":"overflow-x-auto rounded-xl border border-[var(--card-border)] bg-[var(--surface)] p-4 text-sm mb-5","style":{"backgroundColor":"#22272e","color":"#adbac7"},"tabIndex":"0","data-language":"python","data-theme":"github-dark-dimmed","children":["$","code",null,{"className":"rounded bg-[var(--card-bg)] px-1.5 py-0.5 text-sm font-mono text-accent","data-language":"python","data-theme":"github-dark-dimmed","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":"def"}],["$","span",null,{"style":{"color":"#DCBDFB"},"children":" parallel_analysis"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"(state):"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"\"\"Run multiple diagnostic agents in parallel.\"\"\""}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" analyses "}],["$","span",null,{"style":{"color":"#F47067"},"children":"="}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" []"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" for"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" agent "}],["$","span",null,{"style":{"color":"#F47067"},"children":"in"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" [conservative_agent, aggressive_agent, specialist_agent]:"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" result "}],["$","span",null,{"style":{"color":"#F47067"},"children":"="}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" agent.invoke(state["}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"patient_data\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"])"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#ADBAC7"},"children":" analyses.append(result)"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" return"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" {"}],["$","span",null,{"style":{"color":"#F47067"},"children":"**"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"state, "}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"analyses\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": analyses}"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":"def"}],["$","span",null,{"style":{"color":"#DCBDFB"},"children":" synthesis"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"(state):"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"\"\"Resolve disagreements between agents.\"\"\""}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" analyses "}],["$","span",null,{"style":{"color":"#F47067"},"children":"="}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" state["}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"analyses\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"]"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#768390"},"children":" # If all agents agree, high confidence"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" if"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" all_agree(analyses):"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" return"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" {"}],["$","span",null,{"style":{"color":"#F47067"},"children":"**"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"state, "}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"final_diagnosis\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": analyses["}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"0"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"], "}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"confidence\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"0.95"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"}"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#768390"},"children":" # If disagreement, present options with reasoning"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" return"}],"$L49"]}],"\n","$L4a","\n","$L4b","\n","$L4c","\n","$L4d","\n","$L4e"]}]}]}] 15:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"When to use this"}],": Only for decisions where being wrong has serious consequences. It's expensive (3x the LLM calls) but catches errors that single-agent systems miss."]}] 16:["$","h2",null,{"className":"font-[family-name:var(--font-outfit)] text-2xl font-semibold tracking-tight text-foreground mt-10 mb-3","children":"Pattern 4: Human-in-the-Loop Escalation"}] 17:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":"Every production multi-agent system needs a graceful path to human intervention. Here's how I implement it:"}] 18:["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"className":"overflow-x-auto rounded-xl border border-[var(--card-border)] bg-[var(--surface)] p-4 text-sm mb-5","style":{"backgroundColor":"#22272e","color":"#adbac7"},"tabIndex":"0","data-language":"python","data-theme":"github-dark-dimmed","children":["$","code",null,{"className":"rounded bg-[var(--card-bg)] px-1.5 py-0.5 text-sm font-mono text-accent","data-language":"python","data-theme":"github-dark-dimmed","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#6CB6FF"},"children":"ESCALATION_TRIGGERS"}],["$","span",null,{"style":{"color":"#F47067"},"children":" ="}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" {"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"low_confidence\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": "}],["$","span",null,{"style":{"color":"#F47067"},"children":"lambda"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" state: state["}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"confidence\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"] "}],["$","span",null,{"style":{"color":"#F47067"},"children":"<"}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":" 0.6"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":","}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"sensitive_topic\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": "}],["$","span",null,{"style":{"color":"#F47067"},"children":"lambda"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" state: "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"any"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"("}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" t "}],["$","span",null,{"style":{"color":"#F47067"},"children":"in"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" state["}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"classification\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"] "}],["$","span",null,{"style":{"color":"#F47067"},"children":"for"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" t "}],["$","span",null,{"style":{"color":"#F47067"},"children":"in"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" ["}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"legal\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":", "}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"emergency\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":", "}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"complaint\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"]"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#ADBAC7"},"children":" ),"}]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"repeated_clarification\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": "}],["$","span",null,{"style":{"color":"#F47067"},"children":"lambda"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" state: state["}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"clarification_count\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"] "}],["$","span",null,{"style":{"color":"#F47067"},"children":">"}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":" 2"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":","}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"user_request\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": "}],["$","span",null,{"style":{"color":"#F47067"},"children":"lambda"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" state: "}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"speak to human\""}],["$","span",null,{"style":{"color":"#F47067"},"children":" in"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" state["}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"messages\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"]["}],["$","span",null,{"style":{"color":"#F47067"},"children":"-"}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"1"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"].lower(),"}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#ADBAC7"},"children":"}"}]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":"def"}],["$","span",null,{"style":{"color":"#DCBDFB"},"children":" should_escalate"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"(state) -> "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"bool"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":":"}]]}],"\n","$L4f"]}]}]}] 19:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":["$","strong",null,{"className":"font-semibold text-foreground","children":"The escalation should include:"}]}] 1a:["$","ul",null,{"className":"list-disc list-inside space-y-2 text-muted mb-5","children":["\n",["$","li",null,{"className":"text-base leading-relaxed","children":"Full conversation history"}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":"Agent classification and confidence scores"}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":"Attempted solutions and why they failed"}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":"Suggested actions for the human operator"}],"\n"]}] 1b:["$","h2",null,{"className":"font-[family-name:var(--font-outfit)] text-2xl font-semibold tracking-tight text-foreground mt-10 mb-3","children":"Failure Modes I've Encountered"}] 1c:["$","h3",null,{"className":"font-[family-name:var(--font-outfit)] text-xl font-semibold text-foreground mt-8 mb-3","children":"1. The Infinite Loop"}] 1d:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":["An agent that keeps calling tools without making progress. ",["$","strong",null,{"className":"font-semibold text-foreground","children":"Solution"}],": Hard iteration limits with graceful degradation."]}] 1e:["$","h3",null,{"className":"font-[family-name:var(--font-outfit)] text-xl font-semibold text-foreground mt-8 mb-3","children":"2. The Confident Wrong Answer"}] 1f:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":["An agent that produces a plausible-sounding but incorrect response with high confidence. ",["$","strong",null,{"className":"font-semibold text-foreground","children":"Solution"}],": The debate pattern, plus always showing confidence scores to end users."]}] 20:["$","h3",null,{"className":"font-[family-name:var(--font-outfit)] text-xl font-semibold text-foreground mt-8 mb-3","children":"3. The Context Leak"}] 21:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":["Information from one conversation leaking into another due to shared state. ",["$","strong",null,{"className":"font-semibold text-foreground","children":"Solution"}],": Strict state isolation per conversation, no global mutable state."]}] 22:["$","h3",null,{"className":"font-[family-name:var(--font-outfit)] text-xl font-semibold text-foreground mt-8 mb-3","children":"4. The Cost Spiral"}] 23:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":["A complex query that triggers cascading agent calls, burning through tokens. ",["$","strong",null,{"className":"font-semibold text-foreground","children":"Solution"}],": Per-request cost budgets with automatic circuit breaking."]}] 24:["$","figure",null,{"data-rehype-pretty-code-figure":"","children":["$","pre",null,{"className":"overflow-x-auto rounded-xl border border-[var(--card-border)] bg-[var(--surface)] p-4 text-sm mb-5","style":{"backgroundColor":"#22272e","color":"#adbac7"},"tabIndex":"0","data-language":"python","data-theme":"github-dark-dimmed","children":["$","code",null,{"className":"rounded bg-[var(--card-bg)] px-1.5 py-0.5 text-sm font-mono text-accent","data-language":"python","data-theme":"github-dark-dimmed","style":{"display":"grid"},"children":[["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":"class"}],["$","span",null,{"style":{"color":"#F69D50"},"children":" CostTracker"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":":"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" def"}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":" __init__"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"(self, max_budget_cents: "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"int"}],["$","span",null,{"style":{"color":"#F47067"},"children":" ="}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":" 50"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"):"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#6CB6FF"},"children":" self"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":".max_budget "}],["$","span",null,{"style":{"color":"#F47067"},"children":"="}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" max_budget_cents"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#6CB6FF"},"children":" self"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":".current_spend "}],["$","span",null,{"style":{"color":"#F47067"},"children":"="}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":" 0"}]]}],"\n",["$","span",null,{"data-line":"","children":" "}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" def"}],["$","span",null,{"style":{"color":"#DCBDFB"},"children":" track"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"(self, model: "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"str"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":", tokens: "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"int"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"):"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":" cost "}],["$","span",null,{"style":{"color":"#F47067"},"children":"="}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" calculate_cost(model, tokens)"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#6CB6FF"},"children":" self"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":".current_spend "}],["$","span",null,{"style":{"color":"#F47067"},"children":"+="}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" cost"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" if"}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":" self"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":".current_spend "}],["$","span",null,{"style":{"color":"#F47067"},"children":">"}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":" self"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":".max_budget:"}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" raise"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" BudgetExceededError("}]]}],"\n",["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" f"}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"Request exceeded budget: $"}],["$","span",null,{"style":{"color":"#F47067"},"children":"{"}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"self"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":".current_spend"}],["$","span",null,{"style":{"color":"#F47067"},"children":"/"}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"100"}],["$","span",null,{"style":{"color":"#F47067"},"children":":.2f}"}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\""}]]}],"\n",["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#ADBAC7"},"children":" )"}]}]]}]}]}] 25:["$","h2",null,{"className":"font-[family-name:var(--font-outfit)] text-2xl font-semibold tracking-tight text-foreground mt-10 mb-3","children":"Observability Is Non-Negotiable"}] 26:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":"You cannot debug multi-agent systems without proper observability. At minimum, you need:"}] 27:["$","ol",null,{"className":"list-decimal list-inside space-y-2 text-muted mb-5","children":["\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Trace IDs"}]," that follow a request through all agents"]}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Token usage"}]," per agent per request"]}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Latency"}]," breakdowns (which agent is the bottleneck?)"]}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Decision logs"}]," (why did the router choose this specialist?)"]}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Error rates"}]," per agent (is one specialist failing more than others?)"]}],"\n"]}] 28:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":"We use LangSmith for tracing and custom Prometheus metrics for monitoring. The dashboard shows real-time agent performance and automatically alerts when error rates exceed thresholds."}] 29:["$","h2",null,{"className":"font-[family-name:var(--font-outfit)] text-2xl font-semibold tracking-tight text-foreground mt-10 mb-3","children":"Key Takeaways"}] 2a:["$","ol",null,{"className":"list-decimal list-inside space-y-2 text-muted mb-5","children":["\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Start with two agents"}]," (router + one specialist), not ten. Add complexity only when data proves you need it."]}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Each agent should have a single, clear responsibility"}],". If you can't describe what an agent does in one sentence, it's doing too much."]}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Invest heavily in the router"}],". A good router makes average specialists work well. A bad router makes excellent specialists useless."]}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Budget for observability from day one"}],". You'll spend more time debugging than building."]}],"\n",["$","li",null,{"className":"text-base leading-relaxed","children":[["$","strong",null,{"className":"font-semibold text-foreground","children":"Always have a human escalation path"}],". The goal is augmenting humans, not replacing them."]}],"\n"]}] 2b:["$","hr",null,{"className":"my-8 border-[var(--card-border)]"}] 2c:["$","p",null,{"className":"text-base leading-relaxed text-muted mb-5","children":["$","em",null,{"children":"In my next post, I'll dive deeper into RAG pipeline optimization — specifically, how we achieved sub-200ms retrieval latency while maintaining 95%+ relevance for medical queries."}]}] 2d:["$","script","script-0",{"src":"/_next/static/chunks/e1faea17a9e9ed14.js","async":true}] 2e:["$","$L50",null,{"children":["$","$51",null,{"name":"Next.MetadataOutlet","children":"$@52"}]}] 2f:["$","span",null,{"style":{"color":"#ADBAC7"},"children":"state,"}] 30:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"classification\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": classification.category,"}]]}] 31:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"confidence\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": classification.confidence,"}]]}] 32:["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#ADBAC7"},"children":" }"}]}] 33:["$","span",null,{"data-line":"","children":" "}] 34:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":"def"}],["$","span",null,{"style":{"color":"#DCBDFB"},"children":" route_to_specialist"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"(state: OrchestratorState) -> "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"str"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":":"}]]}] 35:["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"\"\"Deterministic routing based on classification.\"\"\""}]}] 36:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" if"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" state["}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"confidence\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"] "}],["$","span",null,{"style":{"color":"#F47067"},"children":"<"}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":" 0.7"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":":"}]]}] 37:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" return"}],["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"clarification_agent\""}]]}] 38:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" return"}],["$","span",null,{"style":{"color":"#F47067"},"children":" f"}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\""}],["$","span",null,{"style":{"color":"#F47067"},"children":"{"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"state["}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"'classification'"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"]"}],["$","span",null,{"style":{"color":"#F47067"},"children":"}"}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"_agent\""}]]}] 39:["$","span",null,{"data-line":"","children":" "}] 3a:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":"graph "}],["$","span",null,{"style":{"color":"#F47067"},"children":"="}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" StateGraph(OrchestratorState)"}]]}] 3b:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":"graph.add_node("}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"router\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":", router)"}]]}] 3c:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":"graph.add_node("}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"medical_query_agent\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":", medical_agent)"}]]}] 3d:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":"graph.add_node("}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"billing_agent\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":", billing_agent)"}]]}] 3e:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":"graph.add_node("}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"scheduling_agent\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":", scheduling_agent)"}]]}] 3f:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":"graph.add_node("}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"general_agent\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":", general_agent)"}]]}] 40:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":"graph.add_node("}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"clarification_agent\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":", clarification_agent)"}]]}] 41:["$","span",null,{"data-line":"","children":" "}] 42:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":"graph.set_entry_point("}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"router\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":")"}]]}] 43:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#ADBAC7"},"children":"graph.add_conditional_edges("}],["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"router\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":", route_to_specialist)"}]]}] 44:["$","span",null,{"style":{"color":"#ADBAC7"},"children":": validated, "}] 45:["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"stage\""}] 46:["$","span",null,{"style":{"color":"#ADBAC7"},"children":": "}] 47:["$","span",null,{"style":{"color":"#96D0FF"},"children":"\"validation_complete\""}] 48:["$","span",null,{"style":{"color":"#ADBAC7"},"children":"}"}] 49:["$","span",null,{"style":{"color":"#ADBAC7"},"children":" {"}] 4a:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" **"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"state,"}]]}] 4b:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"final_diagnosis\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": synthesize_with_reasoning(analyses),"}]]}] 4c:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"confidence\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": calculate_agreement_score(analyses),"}]]}] 4d:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#96D0FF"},"children":" \"requires_human_review\""}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":": "}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":"True"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":","}]]}] 4e:["$","span",null,{"data-line":"","children":["$","span",null,{"style":{"color":"#ADBAC7"},"children":" }"}]}] 4f:["$","span",null,{"data-line":"","children":[["$","span",null,{"style":{"color":"#F47067"},"children":" return"}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":" any"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":"(check(state) "}],["$","span",null,{"style":{"color":"#F47067"},"children":"for"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":" check "}],["$","span",null,{"style":{"color":"#F47067"},"children":"in"}],["$","span",null,{"style":{"color":"#6CB6FF"},"children":" ESCALATION_TRIGGERS"}],["$","span",null,{"style":{"color":"#ADBAC7"},"children":".values())"}]]}] 52:null