{"componentChunkName":"component---src-pages-pensieve-index-js","path":"/pensieve/","result":{"data":{"allMarkdownRemark":{"edges":[{"node":{"frontmatter":{"title":"Multi-Agent Orchestration with LangGraph — Patterns That Survive Production","description":"Supervisor routing, specialized agents, tool use, and failure modes from shipping real-estate and data-analyst multi-agent systems on LangGraph and DeepAgents.","slug":"/pensieve/multi-agent-orchestration","date":"2026-03-15","tags":["Multi-Agent","LangGraph","DeepAgents","LLM","Production"],"draft":false},"html":"<h2>One model is not a product</h2>\n<p>A single chat completion can draft text. Production workflows need <strong>routing</strong>, <strong>tools</strong>, <strong>memory</strong>, and <strong>clear ownership of failure</strong>. Multi-agent systems earn their complexity when the work naturally splits: search vs finance vs market research; plan vs code vs execute.</p>\n<p>This post captures patterns from shipping:</p>\n<ul>\n<li>a <strong>real-estate deep-agents</strong> stack (LangGraph + specialized agents + RAG)</li>\n<li>an <strong>agentic data analyst</strong> that turns natural language into sandboxed Python</li>\n</ul>\n<h2>Prefer a graph of steps over a pile of prompts</h2>\n<p><strong>LangGraph</strong>-style orchestration gives you:</p>\n<ul>\n<li>explicit nodes (agents / tools / validators)</li>\n<li>edges with conditions (route, retry, escalate, stop)</li>\n<li><strong>checkpointed state</strong> so long jobs can resume and audits can replay</li>\n</ul>\n<p>That beats an unbounded “agent loop” that mutates a blob of chat history until tokens run out.</p>\n<p>A durable shape:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">User → Supervisor / orchestrator\n          ├─ Specialist A (tools)\n          ├─ Specialist B (tools)\n          └─ Synthesizer → final artifact</code></pre></div>\n<p>Keep the supervisor thin: classify intent, pick agents, merge results, enforce budgets (steps, tokens, wall clock).</p>\n<h2>Specialist agents beat mega-prompts</h2>\n<p>In the real-estate platform, separate agents for <strong>search</strong>, <strong>finance</strong>, and <strong>market</strong> work better than one prompt that tries to do everything:</p>\n<ul>\n<li>clearer tool permissions</li>\n<li>smaller context per call</li>\n<li>independent evaluation</li>\n<li>easier rollback when one skill regresses</li>\n</ul>\n<p>The <strong>Agentic Data Analyst</strong> follows the same idea along a pipeline: understand query → generate code → <strong>sandbox execute</strong> → present in Streamlit. Code execution is a different trust boundary than “write an answer”; isolate it.</p>\n<h2>Tool use is where systems actually fail</h2>\n<p>Common failure modes (and mitigations):</p>\n<table>\n<thead>\n<tr>\n<th>Failure</th>\n<th>Symptom</th>\n<th>Mitigation</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Tool hallucination</td>\n<td>Invented APIs / paths</td>\n<td>Strict tool schemas; reject unknown names</td>\n</tr>\n<tr>\n<td>Infinite loops</td>\n<td>Same node retries forever</td>\n<td>Max steps; circuit breakers; escalate to human</td>\n</tr>\n<tr>\n<td>Context bloat</td>\n<td>Latency and cost explode</td>\n<td>Summarize intermediate state; pass IDs not dumps</td>\n</tr>\n<tr>\n<td>Unsafe code</td>\n<td>Arbitrary exec in analyst flows</td>\n<td>Docker/host sandbox (e.g. patterns like <strong>codibox</strong>); no network by default</td>\n</tr>\n<tr>\n<td>Silent wrong answers</td>\n<td>Confident nonsense</td>\n<td>Critic / grader node; require citations or tests</td>\n</tr>\n</tbody>\n</table>\n<p>Design the graph so <strong>failure is a first-class edge</strong>, not an exception you only see in logs.</p>\n<h2>State, checkpoints, and auditability</h2>\n<p>Financial and analytical users ask “how did you get this?” Checkpointed graphs let you:</p>\n<ul>\n<li>resume after timeouts</li>\n<li>inspect which agent produced which claim</li>\n<li>A/B route models (OpenAI, Anthropic, Gemini, Bedrock, …) behind the same graph contract</li>\n</ul>\n<p>Multi-LLM routing belongs in the orchestrator, not scattered inside each agent.</p>\n<h2>When not to use multi-agent</h2>\n<p>Skip the swarm if:</p>\n<ul>\n<li>one retrieval + one generation pass solves 90% of queries</li>\n<li>you cannot define clear agent responsibilities</li>\n<li>you lack evals for the end-to-end path</li>\n</ul>\n<p>Start with a <strong>single agent + tools</strong>. Promote to multi-agent when handoffs and specialization show up in the eval set, not in a slide deck.</p>\n<h2>Practical checklist before production</h2>\n<ol>\n<li>Hard caps on steps, tokens, and wall time</li>\n<li>Typed state and validated tool I/O</li>\n<li>Sandboxed execution for any generated code</li>\n<li>Observability per node (latency, error rate, retry count)</li>\n<li>Human-readable traces for support and compliance</li>\n<li>A graceful degrade path (partial answer + uncertainty)</li>\n</ol>\n<p>Multi-agent orchestration is software architecture with LLMs in the loop — treat it like distributed systems, not magic.</p>"}},{"node":{"frontmatter":{"title":"GraphRAG in Production — Hybrid Retrieval That Auditors Can Trust","description":"How Neo4j knowledge graphs plus vector and full-text retrieval produce explainable answers for financial due diligence — patterns from building a GraphRAG knowledge engine.","slug":"/pensieve/graphrag-production","date":"2026-03-01","tags":["GraphRAG","Neo4j","RAG","LLM","Production"],"draft":false},"html":"<h2>Why plain RAG fails on financial documents</h2>\n<p>Vector-only RAG is great at “find something that sounds like this.” Due diligence and compliance need something sharper: <strong>who owns what</strong>, <strong>which clause constrains which entity</strong>, and <strong>why</strong> an answer is grounded in a specific filing.</p>\n<p>Embeddings alone blur those edges. Entities collapse into similar neighborhoods; cross-document relationships disappear; citations become soft suggestions instead of audit trails. That is the gap GraphRAG is meant to close.</p>\n<h2>The production shape: graph + hybrid retrieval + LLM reasoning</h2>\n<p>A practical GraphRAG stack for financial and compliance corpora looks like this:</p>\n<ol>\n<li><strong>Ingest</strong> multi-format documents (filings, policies, contracts).</li>\n<li><strong>Chunk and embed</strong> for semantic recall.</li>\n<li><strong>Extract entities and relations</strong> into a <strong>Neo4j</strong> knowledge graph.</li>\n<li><strong>Retrieve with hybrid fusion</strong> — vector similarity <strong>and</strong> full-text / lexical search, then graph expansion around the hit set.</li>\n<li><strong>Reason with an LLM</strong> over a structured context pack (passages + graph neighborhood + provenance).</li>\n<li><strong>Return an answer with citations</strong> that map back to nodes, chunks, and source files.</li>\n</ol>\n<p>The graph is not decoration. It is the index that makes “explainable” possible: you can show the path from claim → entity → document span.</p>\n<h2>Hybrid retrieval beats single-channel retrieval</h2>\n<p>In practice, three channels complement each other:</p>\n<table>\n<thead>\n<tr>\n<th>Channel</th>\n<th>Strength</th>\n<th>Failure mode</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Vector</td>\n<td>Paraphrase and conceptual match</td>\n<td>Misses exact identifiers, clauses, ticker symbols</td>\n</tr>\n<tr>\n<td>Full-text / lexical</td>\n<td>Exact terms, IDs, regulation codes</td>\n<td>Brittle to wording changes</td>\n</tr>\n<tr>\n<td>Graph expansion</td>\n<td>Multi-hop ownership, parties, obligations</td>\n<td>Needs decent extraction quality</td>\n</tr>\n</tbody>\n</table>\n<p>A solid fusion strategy ranks candidates from vector + FT, then expands 1–2 hops in Neo4j (related entities, linked clauses, prior filings). Rerank before the LLM so the context window stays dense and cheap.</p>\n<h2>Designing for explainability</h2>\n<p>Production buyers in finance care less about flashy demos and more about:</p>\n<ul>\n<li><strong>Provenance</strong> — every sentence tied to chunk IDs and graph node IDs</li>\n<li><strong>Faithfulness</strong> — refuse or hedge when retrieval is thin</li>\n<li><strong>Deterministic scaffolding</strong> — schema-enforced extraction (e.g. Pydantic models) so the graph does not rot</li>\n<li><strong>Evaluation</strong> — faithfulness / relevance scores, plus human review loops on high-stakes queries</li>\n</ul>\n<p>Treat the LLM as a reasoner over evidence, not as the system of record.</p>\n<h2>Operational notes that matter more than model choice</h2>\n<ul>\n<li><strong>Chunking</strong> should respect document structure (sections, tables, footnotes), not only token count.</li>\n<li><strong>Entity resolution</strong> (same company across filings) is where quality is won or lost.</li>\n<li><strong>Observability</strong> on retrieval (hit rates per channel, empty-result rate, citation coverage) catches regressions before users do.</li>\n<li><strong>Cost</strong> drops when hybrid retrieval shrinks the context you send to the model — fewer tokens, better answers.</li>\n</ul>\n<h2>What I am shipping next</h2>\n<p>These patterns underpin the <strong>GraphRAG Knowledge Engine</strong> featured on this site: Neo4j knowledge graphs, hybrid vector and full-text retrieval, and LLM reasoning aimed at due diligence and risk analysis. Client-facing deployment details stay private until the customer environment is public; the architecture above is the portable part.</p>\n<p>If you are evaluating GraphRAG vs “bigger context window,” start with retrieval quality and provenance. Model upgrades are easy to swap. A trustworthy evidence layer is not.</p>"}},{"node":{"frontmatter":{"title":"Sadeeq Al-Siha Medical Chatbot","description":"Medical RAG QA with Meditron 7B, Qdrant, and PubMedBERT for evidence-grounded clinical answers","slug":"/projects/sadeeq-al-siha","date":"2024-01-15","tags":["LLM","Chatbot","Healthcare","RAG"],"draft":false},"html":"<h2>Overview</h2>\n<p>Medical RAG (Retrieval-Augmented Generation) QA application using the Meditron 7B LLM, Qdrant vector database, and PubMedBERT embeddings — designed for accurate, literature-grounded medical answers through a Chainlit interface.</p>\n<h2>Details</h2>\n<ul>\n<li><strong>Meditron 7B</strong> for medical question answering via Ollama</li>\n<li><strong>Qdrant</strong> for scalable vector search over medical embeddings</li>\n<li><strong>PubMedBERT</strong> embeddings trained on medical literature</li>\n<li><strong>Chainlit</strong> UI for interactive clinical Q&#x26;A</li>\n</ul>\n<p>Repo: <a href=\"https://github.com/oelbourki/Sadeeq-Al-Siha-Medical-Chatbot\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">oelbourki/Sadeeq-Al-Siha-Medical-Chatbot</a></p>"}},{"node":{"frontmatter":{"title":"Ads-LLM","description":"A program for matching articles with ads using advanced NLP techniques","slug":"/projects/ads-llm","date":"2023-12-01","tags":["LLM","Advertising","NLP"],"draft":false},"html":"<h2>Overview</h2>\n<p>Implemented a program for matching articles with ads, utilizing KeyBERT to pinpoint relevant article keywords and a custom LLAVA deployed on Vertex AI to extract ad-descriptive keywords.</p>\n<h2>Details</h2>\n<ul>\n<li>Ensured sensitivity and disallowed keyword compliance during the matching process.</li>\n<li>Efficiently stored keywords on Supabase for streamlined access and management.</li>\n<li>Enhanced ad-targeting accuracy through advanced natural language processing techniques.</li>\n</ul>"}}]}},"pageContext":{}},"staticQueryHashes":["1064330971","1994492073","2009693873","3298314076"]}