Ranjan Kumar (@ranjankumar) header
Ranjan Kumar (@ranjankumar) profile picture

Educating and Empowering AI Builders to Create Systems That Actually Work

Navi Mumbai, India
Joined August 2008
Photo by Ranjan Kumar (@ranjankumar)Photo by Ranjan Kumar (@ranjankumar)Photo by Ranjan Kumar (@ranjankumar)Photo by Ranjan Kumar (@ranjankumar)Photo by Ranjan Kumar (@ranjankumar)Photo by Ranjan Kumar (@ranjankumar)Photo by Ranjan Kumar (@ranjankumar)Photo by Ranjan Kumar (@ranjankumar)Photo by Ranjan Kumar (@ranjankumar)Photo by Ranjan Kumar (@ranjankumar)
๐•๐š๐ฅ๐ข๐๐š๐ญ๐ข๐จ๐ง ๐‹๐š๐ฒ๐ž๐ซ ๐ƒ๐ž๐ฌ๐ข๐ ๐ง: ๐๐ฎ๐ข๐ฅ๐๐ข๐ง๐  ๐ญ๐ก๐ž ๐‘๐ž๐Ÿ๐ฅ๐ž๐ฑ ๐“๐ก๐š๐ญ ๐‚๐š๐ญ๐œ๐ก๐ž๐ฌ ๐–๐ก๐š๐ญ ๐ญ๐ก๐ž ๐Œ๐จ๐๐ž๐ฅ ๐†๐ž๐ญ๐ฌ ๐–๐ซ๐จ๐ง๐  Your LLM returns well-formed output. That doesn't mean it's correct. Provider strict mode stops the structure from breaking - it doesn't stop the meaning from being wrong. That gap is where production systems fail silently. A team extracted legal documents for six weeks with a damage_cap field stored as a string instead of a number. Analytics coerced it to zero. Nobody noticed until a lawyer saw \$0 liability on high-value contracts. No code bug. No validation layer. The Validation Layer catches what strict mode can't: refusals, truncations, ranges that exceed business constraints, and values that are well-typed but semantically wrong. It's not about being pedantic. It's about preventing \$0 damage caps and other silent failures from reaching your database. Structure this as a cascade - schema validation first, semantic checks second, business rules third. Run cheapest-first. Detect every violation before it touches downstream systems. When validation fails, repair only shape errors (the model learns from content corrections). Let semantic and business-rule failures fail fast and observable, never silently. The model doesn't need to be perfect. It needs to be correctable. That's what this layer builds. Read the full guide covering schema validators, semantic checks, repair prompt patterns, and the fail-fast vs. repair decision: ranjankumar.in/harness-enginโ€ฆ Follow for more practitioner-focused AI systems design. #AIEngineering #LLMReliability #ValidationLayer #StructuredOutputs #Pydantic #SystemsDesign #HarnessEngineering
9
๐‹๐‹๐Œ ๐‚๐จ๐ง๐ญ๐ž๐ฑ๐ญ ๐–๐ข๐ง๐๐จ๐ฐ ๐Œ๐š๐ง๐š๐ ๐ž๐ฆ๐ž๐ง๐ญ: ๐“๐ก๐ž ๐๐จ๐ฅ๐ข๐œ๐ฒ ๐๐จ๐›๐จ๐๐ฒ ๐–๐ซ๐จ๐ญ๐ž Every fit-to-window loop runs a policy nobody wrote, and its quietest failure is a constraint summarised into a sentence that constrains nothing. At turn thirty of a long billing ticket, the refund ceiling became two words. The window had stopped fitting, so the system summarised the oldest material - which happened to be the operating constraints. Nothing raised an exception. Nothing was logged. The function returned a context that fit, which is the only thing it was asked to do. Two turns later, nothing in the window said what the model could not propose. The rule still lived in code - a gate that refused refunds over ceiling. But everything that gate depended on to work well had evaporated: the escalation rule, the limit on what the reply could promise, the proposal quality the gate needed to see. A reply promising $1,200 blocked by a gate that refuses it is still a failed ticket. Here's what framework code shows. LangChain's summarisation middleware returns a fixed string when nothing's left to compress: "Previous conversation was too long to summarize." A DeepAgents user reported the summariser itself writing empty summaries that surfaced as the assistant response - the task never completed. Content-free compaction that looks successful but preserves no task state. The fix is not a better summariser. It's a declared context budget with a floor - what the article calls the Context Floor. Spans without which the run must not happen, checked whole and before anything is evicted. If you can't meet the floor, refuse before the model is called, not after it fumbles on less information. The article argues this against its own earlier advice: that you should summarise everything older and compress more aggressively before the LLM call. The 2025 evidence doesn't hold. Position Debt - the adherence a constraint loses because of where you placed it - is how you find out what actually matters for your model. This builds on four earlier parts in the series on harness engineering. Worth reading if you've shipped context trimming that always returns something, even when it shouldn't. Read the full argument: ranjankumar.in/harness-enginโ€ฆ Follow for more on production AI systems: #HarnessEngineering #ContextEngineering #LLMReliability #AIEngineering #SystemsDesign #LangChain #ProductionAI
2
1
115
๐˜๐จ๐ฎ๐ซ ๐š๐ ๐ž๐ง๐ญ๐ฌ ๐ฐ๐จ๐ซ๐ค ๐Ÿ๐ข๐ง๐ž ๐ฎ๐ง๐ญ๐ข๐ฅ ๐ญ๐ก๐ž๐ฒ ๐œ๐š๐ฅ๐ฅ ๐š๐ง ๐š๐ ๐ž๐ง๐ญ ๐ฒ๐จ๐ฎ ๐๐จ๐ง'๐ญ ๐จ๐ฐ๐ง. Most multi-agent frameworks assume you control every agent in the system. Real systems don't work that way. Claims calls Risk, Risk calls Finance, and Finance calls an outside vendor. I call every call that crosses an ownership boundary a ๐ฌ๐ž๐š๐ฆ. Inside one deployment, five things come for free at a seam: โ†’ Contract โ†’ Authority โ†’ State โ†’ Failure handling โ†’ Accountability Across owners, you have to build each one on purpose. Skipping any of them gets expensive: โ€ข A retried call that pays a claim twice โ€ข A partner who swaps their model and quietly lowers your estimates โ€ข A forged push message that nobody validates That's why I wrote ๐…๐ž๐๐ž๐ซ๐š๐ญ๐ž๐ ๐€๐ˆ ๐€๐ ๐ž๐ง๐ญ๐ฌ: ๐‹๐š๐ง๐ ๐†๐ซ๐š๐ฉ๐ก ๐š๐ง๐ ๐€๐Ÿ๐€ ๐Ÿ๐จ๐ซ ๐€๐ ๐ž๐ง๐ญ๐ฌ ๐˜๐จ๐ฎ ๐ƒ๐จ๐ง'๐ญ ๐Ž๐ฐ๐ง. It's Book 4 of the Agentic AI Series. Inside the book: ๐Ÿ”น The Federation Test, which tells you when an A2A call is worth its cost ๐Ÿ”น Agent cards as contracts, plus trust policies and delegation chains ๐Ÿ”น Task ledgers, human approval across owners, and saga-style compensation ๐Ÿ”น Circuit breakers, behavioural drift detection, and testing against partners you can't deploy ๐Ÿ”น Cross-company audit trails and cost ledgers Every chapter ends with a code artifact, a one-line seam checklist rule, and a "cost of skipping this" story. The companion repo is MIT-licensed, and its tests run with no network, accounts, or model key. It's for engineers building on LangGraph, platform and security teams running agent gateways, and architects deciding where agent boundaries belong. ๐Ÿ“• Available on Kindle and paperback: federatedagents.ranjankumar.โ€ฆ If you're building agents that have to trust other teams' agents, I'd like to hear where your seams are. #AgenticAI #LangGraph #A2A #MultiAgentSystems #AIEngineering #LLM #AIArchitecture
57
๐„๐๐ ๐ž ๐€๐ˆ ๐€๐ง๐จ๐ฆ๐š๐ฅ๐ฒ ๐ƒ๐ž๐ญ๐ž๐œ๐ญ๐ข๐จ๐ง ๐จ๐ง ๐ˆ๐จ๐“ ๐…๐ฅ๐ž๐ž๐ญ๐ฌ ๐‹๐ž๐š๐ซ๐ง๐ฌ ๐ญ๐จ ๐†๐จ ๐’๐ข๐ฅ๐ž๐ง๐ญ Your anomaly detector is not drifting because of your model choice. It's drifting because false alarms get labelled in days, missed faults in months, and your tuning loop only sees one of them. This is verdict skew - a verification latency structure built into the maintenance process itself. Every week you retrain on resolved alerts, the evidence argues for fewer alarms. By week 36, you're silent. By week 40, the missed faults arrive all at once, and you're back to Texaco-scale alert floods. The core problem: false positives surface fast enough to tune out. True negatives and missed faults don't. So your threshold drifts toward silence by default, regardless of whether you're running a GRU, TCN, or Mamba on the device. Here's what actually decides whether your fleet works: - When each type of verdict arrives (not which model you chose) - Which data leaves the device and what can be measured after deployment - How a model reaches production and comes back with real feedback Model architecture matters less than label timing. ICLR 2026 research shows foundation models barely outperform moving-window variance on anomaly detection. A 5M-parameter CNN-FNO reaches near-parity with 120M models on oil and gas tasks. The quantization cost of exotic SSMs can destroy accuracy on microcontrollers. These tradeoffs reverse with a retrain. Verdict skew doesn't. The fix is matured-verdict gating: only tune on alerts where you've actually observed the outcome, with explicit latency thresholds per confusion-matrix cell. Wait for missed faults to surface before you change thresholds. It costs patience, but it stops you from optimizing your detector into silence. Read the full analysis on how to structure your fleet for real feedback: ranjankumar.in/edge-ai-iot-fโ€ฆ Follow for more on ML systems in production. #EdgeAI #AnomalyDetection #IoT #PredictiveMaintenance #MLOps #ConceptDrift #FleetManagement
1
1
163
๐€๐ง ๐š๐ฎ๐ญ๐จ๐ง๐จ๐ฆ๐จ๐ฎ๐ฌ ๐š๐ ๐ž๐ง๐ญ ๐œ๐จ๐ฌ๐ญ ๐Ÿ๐Ÿ”.๐Ÿ’๐Ÿ”ร— ๐ฆ๐จ๐ซ๐ž ๐ญ๐ก๐š๐ง ๐š ๐ฌ๐ข๐ง๐ ๐ฅ๐ž ๐ฉ๐ซ๐จ๐ฆ๐ฉ๐ญ ๐จ๐ง ๐ญ๐ก๐ž ๐ฌ๐š๐ฆ๐ž ๐ฉ๐ซ๐จ๐›๐ฅ๐ž๐ฆ. Same task. Same per-token price. The only thing that changed was the architecture. I see this in almost every GenAI design review. A team asks for an agent, or a multi-agent system, when a prompt with retrieval would have done the job. Nobody chose that extra complexity on purpose. It just built up over time. So I wrote a field guide about it. ๐Ÿ“˜ ๐“๐ก๐ž ๐Ÿ• ๐†๐ž๐ง๐€๐ˆ ๐€๐ซ๐œ๐ก๐ข๐ญ๐ž๐œ๐ญ๐ฎ๐ซ๐ž๐ฌ: ๐€ ๐…๐ข๐ž๐ฅ๐ ๐†๐ฎ๐ข๐๐ž ๐ญ๐จ ๐‚๐ก๐จ๐จ๐ฌ๐ข๐ง๐  ๐ญ๐ก๐ž ๐‘๐ข๐ ๐ก๐ญ ๐€๐ˆ ๐’๐ฒ๐ฌ๐ญ๐ž๐ฆ, ๐๐ž๐Ÿ๐จ๐ซ๐ž ๐˜๐จ๐ฎ ๐Ž๐ฏ๐ž๐ซ๐›๐ฎ๐ข๐ฅ๐ ๐ˆ๐ญ The book arranges every design as a rung on one escalation ladder: 0๏ธโƒฃ Deterministic code (no model at all) 1๏ธโƒฃ Prompt application 2๏ธโƒฃ RAG 3๏ธโƒฃ LLM workflow 4๏ธโƒฃ Tool-using LLM 5๏ธโƒฃ Multi-step reasoning 6๏ธโƒฃ Autonomous agent 7๏ธโƒฃ Multi-agent system The rule it argues for: ๐œ๐จ๐ฆ๐ฉ๐ฅ๐ž๐ฑ๐ข๐ญ๐ฒ ๐ก๐š๐ฌ ๐ญ๐จ ๐›๐ž ๐ž๐š๐ซ๐ง๐ž๐ ๐›๐ฒ ๐š ๐๐ž๐ฆ๐จ๐ง๐ฌ๐ญ๐ซ๐š๐ญ๐ž๐ ๐Ÿ๐š๐ข๐ฅ๐ฎ๐ซ๐ž ๐จ๐Ÿ ๐ญ๐ก๐ž ๐ฌ๐ข๐ฆ๐ฉ๐ฅ๐ž๐ซ ๐š๐ซ๐œ๐ก๐ข๐ญ๐ž๐œ๐ญ๐ฎ๐ซ๐ž. What you get: โ†’ A decision procedure that finds the simplest design that's good enough, working down from the top โ†’ Every rung measured on the same six cost and quality columns, so you can compare them directly โ†’ "Failure Receipts": reproducible cases of each rung failing, which you can bring into a design review โ†’ A companion repo whose tests run with ๐ง๐จ ๐€๐๐ˆ ๐ค๐ž๐ฒ โ†’ Chapters on costing a design before you build it, moving up without a rewrite, and scaling back a system that's already overbuilt This is not an argument against agents. It's an argument against complexity nobody decided to buy. It's written for engineers who have shipped at least one LLM feature, and for the platform and staff engineers who have to approve or push back on these proposals. Kindle (Amazon US & India) and paperback (Amazon US). 7genai.ranjankumar.in/ ๐Ÿ‘‡ Which rung is your team on, and did you have to earn it? #GenerativeAI #AIEngineering #LLM #RAG #AgenticAI #SoftwareArchitecture
1
1
64
๐‡๐จ๐ฐ ๐ญ๐จ ๐–๐ซ๐ข๐ญ๐ž ๐š ๐‚๐ก๐š๐ญ ๐“๐ž๐ฆ๐ฉ๐ฅ๐š๐ญ๐ž ๐Ÿ๐จ๐ซ ๐š ๐…๐ข๐ง๐ž-๐“๐ฎ๐ง๐ž๐ ๐Œ๐จ๐๐ž๐ฅ ๐š๐ง๐ ๐“๐ž๐ฌ๐ญ ๐ˆ๐ญ You fine-tune a model on your own chat format, but then serving it fails silently. The template you write must produce exactly the tokens your trainer taught - token for token, mask for mask, stop token for stop token. Miss any of these and your eval scores tank or the model keeps writing forever. This tutorial shows you how to build and validate a chat template for a fine-tuned model using six concrete checks, all runnable on CPU with no training. You'll transcribe your template from the exact text your model learned on, then prove it works by comparing it token-for-token against a real TRL SFTTrainer batch. The problem is real. A support model was fine-tuned on custom turn markers, but the serving template had an extra newline. The model had never seen that format during training - silent format penalty, eval scores collapsed. Then the template was fixed, but the generation_config.json forgot to list the stop token the model learned to end with. The model kept writing invented turns. Both failures are caught by the checks you'll build here. You'll end up with templatestudio/authoring.py that holds your template and proves it with six checks: - string: template renders without error - markers: role headers and separators match training text - tokens: input_ids match what SFTTrainer produced - mask: attention_mask and position_ids are correct - labels: loss labels align with model answers only - stops: generation stops on the token the model learned The tutorial runs against a 2-layer test model (20 MB), needs no GPU, no API key, and takes about 30 minutes. It's for engineers who fine-tune chat models with custom formats and need proof before serving. Read the full tutorial here: ranjankumar.in/how-to-write-โ€ฆ Follow me for more AI engineering tutorials and practitioner insights. #ChatTemplates #LLMEngineering #FineTuning #SFT #Transformers #TRL #AIEngineering
271
๐‘Œ๐‘œ๐‘ข๐‘Ÿ ๐‘Ž๐‘”๐‘’๐‘›๐‘ก ๐‘๐‘Ž๐‘ ๐‘ ๐‘’๐‘‘ ๐‘’๐‘ฃ๐‘’๐‘Ÿ๐‘ฆ ๐‘‘๐‘’๐‘š๐‘œ. ๐‘‡โ„Ž๐‘’๐‘› ๐‘–๐‘ก ๐‘–๐‘ ๐‘ ๐‘ข๐‘’๐‘‘ ๐‘Ž ๐‘Ÿ๐‘’๐‘“๐‘ข๐‘›๐‘‘ ๐‘–๐‘ก ๐‘ โ„Ž๐‘œ๐‘ข๐‘™๐‘‘๐‘›'๐‘ก โ„Ž๐‘Ž๐‘ฃ๐‘’. A better model wouldn't have fixed that. In production, the gap between demo inputs and real inputs comes from the input distribution, not from the model. What stands between a model's proposal and an irreversible action is the ๐ก๐š๐ซ๐ง๐ž๐ฌ๐ฌ, and most teams build theirs by feel. They call it "guardrails," which describes how it feels rather than what it does. My new book, ๐‘ฏ๐’‚๐’“๐’๐’†๐’”๐’” ๐‘ฌ๐’๐’ˆ๐’Š๐’๐’†๐’†๐’“๐’Š๐’๐’ˆ ๐’‡๐’๐’“ ๐‘ท๐’“๐’๐’…๐’–๐’„๐’•๐’Š๐’๐’ ๐‘จ๐‘ฐ ๐‘บ๐’š๐’”๐’•๐’†๐’Ž๐’”, treats the harness as a control system. Every component does one of four jobs: โ†’ Sensor: observes โ†’ Comparator: checks against a standard โ†’ Gate: decides whether a proposal becomes an action โ†’ Bound: caps how far the system can go If a component does none of these, it's application code, not harness. Inside: - The Demo Cliff, and why it isn't a model problem - Consequence gating for actions that have no undo - The Oracle Deficit: building reliability where you don't get a free pass/fail on every run, the way coding agents do The Silent Pass: a dead control looks just like a working one on traffic that never needed it There's one running example throughout, a billing support agent that can issue refunds. Each control is shown as a plain object, then as an artifact, then wired in LangGraph. The companion repo is MIT-licensed, has 389 passing tests and runs with no API key, no network and no model. Book 3 of my Agentic AI Series. It's on Kindle (Amazon US & India) and in paperback (Amazon US). harness.ranjankumar.in/ What's the one control you wish your system had before your first production incident? #AgenticAI #LLMOps #AIEngineering #ProductionAI #LangGraph #MLOps #AIReliability #GenerativeAI #PlatformEngineering #LLM
1
80
๐†๐š๐ญ๐ž๐ ๐„๐ฑ๐ž๐œ๐ฎ๐ญ๐ข๐จ๐ง: ๐–๐ก๐ฒ ๐˜๐จ๐ฎ๐ซ ๐€๐ ๐ž๐ง๐ญ ๐’๐ก๐จ๐ฎ๐ฅ๐ ๐๐ž๐ฏ๐ž๐ซ ๐€๐œ๐ญ ๐–๐ข๐ญ๐ก๐จ๐ฎ๐ญ ๐๐ž๐ซ๐ฆ๐ข๐ฌ๐ฌ๐ข๐จ๐ง Your agent just generated valid output. That doesn't mean it should execute. A team deployed an agent with production database access. It was supposed to delete records older than 90 days. The DELETE query was syntactically perfect. The WHERE clause looked right. Validation passed. Then it executed - and deleted 40% of the database because NULL comparisons in SQL returned falsy values, and the agent had added an OR created_at IS NULL fallback to handle edge cases. The SQL was valid. The logic was coherent. Everything passed except one critical thing - there was no gate between what the model proposed and what actually ran. Here's the gap most teams miss: Validation checks if output is well-formed. The gate checks if it should run at all. These are orthogonal concerns. A perfectly structured DELETE can be semantically catastrophic. No validator catches consequence - validators check format. For simple LLM applications this is optional. For agentic systems it's non-negotiable. Agents act with real consequences - deleted records, sent emails, API calls, infrastructure changes. These are irreversible, cascade downstream, and LLMs can't self-calibrate confidence. A model 60% sure looks identical to one 99% certain. Gated execution is your firewall. Default-deny policy. Dry-run preview of exact rows affected. Human approval as a checkpointed interrupt bound to that specific action. Nothing with side effects executes without passing through it. The gate sits where every call actually goes - not in an optional hook that auto-approved tools skip. It answers one question: given what we know about this action's consequences, should it run? Read the full breakdown of architecture, risk ordering, approval workflows, and framework primitives: ranjankumar.in/harness-enginโ€ฆ Follow my work on AI systems architecture and production patterns. #HarnessEngineering #AgenticAI #LLMSafety #AIEngineering #HumanInTheLoop #ProductionAI #AIArchitecture
1
96
๐‚๐จ๐ง๐ญ๐ž๐ฑ๐ญ ๐„๐ง๐ ๐ข๐ง๐ž๐ž๐ซ๐ข๐ง๐ : ๐–๐ก๐š๐ญ ๐ญ๐ก๐ž ๐Œ๐จ๐๐ž๐ฅ ๐’๐ž๐ž๐ฌ ๐ˆ๐ฌ ๐–๐ก๐š๐ญ ๐ญ๐ก๐ž ๐Œ๐จ๐๐ž๐ฅ ๐ƒ๐จ๐ž๐ฌ Your RAG pipeline retrieves 40 chunks. You stuff all 40 into the prompt. The model ignores the three most relevant ones, buried in the middle. You blame the retriever. You tune embeddings. You switch models. The problem persists because you're fixing the wrong thing. The real issue: context design failure. Naive context assembly treats the context window like a dump bucket. Recent research - from Liu's "Lost in the Middle" to Chroma's "context rot" studies - shows models degrade when distractors pile up and answers get lost in noise. Your 40 near-miss chunks competed with the 3 good ones. The retriever worked. The model worked. Your assembly architecture failed. Here's the core insight: the context window is the model's entire working memory. Everything it knows about the current task lives there. Every decision it makes is a function of what's in that window and how it's arranged. Context engineering is the discipline of deciding precisely what information the model sees, how it's structured, and in what order - not just retrieving documents, but curating, compressing, and assembling them as managed infrastructure. This requires three decisions naive teams skip: - ๐‘๐ž๐ซ๐š๐ง๐ค ๐š๐ง๐ ๐ฉ๐จ๐ฌ๐ข๐ญ๐ข๐จ๐ง: don't dump retrieved chunks in retrieval order. Rerank by relevance. Place critical chunks at the beginning or end, not the middle. Use recency and salience, not proximity. - ๐‚๐จ๐ฆ๐ฉ๐ซ๐ž๐ฌ๐ฌ ๐š๐ ๐ ๐ซ๐ž๐ฌ๐ฌ๐ข๐ฏ๐ž๐ฅ๐ฒ ๐ฐ๐ข๐ญ๐ก๐จ๐ฎ๐ญ ๐๐ซ๐จ๐ฉ๐ฉ๐ข๐ง๐  ๐œ๐จ๐ง๐ฌ๐ญ๐ซ๐š๐ข๐ง๐ญ๐ฌ: summarize generic content, but preserve decision-relevant facts, edge cases, and system constraints entirely. Compression that generalizes away your constraints will fail in production. - ๐Œ๐š๐ง๐š๐ ๐ž ๐œ๐จ๐ง๐ญ๐ž๐ฑ๐ญ ๐š๐ฌ ๐š ๐›๐ฎ๐๐ ๐ž๐ญ: treat tokens like a resource. Allocate slots for memory, conversation history, retrieval results, and query. Know your Dead Zone - the region where model performance drops hardest - and keep answers out of it. These aren't optimizations. They're structural engineering decisions. The difference between a system that hallucinates confidently and one that reasons over what it was actually given. Read the full analysis on context rot, position-aware assembly, compression loops, and memory architectures: ranjankumar.in/harness-enginโ€ฆ Follow my work on building systems that work in production. #ContextEngineering #RAG #LLMSystems #AIEngineering #ProductionAI #SystemsDesign #HarnessEngineering
192
๐‹๐š๐ง๐ ๐†๐ซ๐š๐ฉ๐ก ๐‚๐ก๐ž๐œ๐ค๐ฉ๐จ๐ข๐ง๐ญ๐ฌ ๐‘๐ž๐ฌ๐ญ๐จ๐ซ๐ž ๐˜๐จ๐ฎ๐ซ ๐‹๐ข๐ฆ๐ข๐ญ๐ฌ, ๐๐จ๐ญ ๐‰๐ฎ๐ฌ๐ญ ๐˜๐จ๐ฎ๐ซ ๐’๐ญ๐š๐ญ๐ž You checkpoint your agent mid-run. It hits a recursion limit, you resume from that checkpoint, and suddenly you have a fresh budget. Same thread, same state, but the guard resets like it never fired. This isn't a bugโ€”it's how the mechanism works. And it's a problem. Here's what happens under the hood: When LangGraph resumes a checkpointed run, it re-derives every bound from the restored state. The recursion limit isn't stored as "you've used 8 of 8 steps, now shut down." Instead, it's recomputed as a pure function: new_stop = current_step + recursion_limit + 1. Resume at step 8 with a limit of 8, and you get to step 18. Resume at 18, you get to 28. Each allowance arrives at full. The same logic applies to refund guards, human approvals, and any other constraint that reads from state to make a decision. They all ask "is this allowed?" of the restored checkpoint without asking "how much of this allowance was already spent?" The faithfulness of replay is itself the bugโ€”you're correctly re-deriving the same verdict from the same state, which means you're authorizing the same action twice. This isn't about divergence or non-determinism. Set temperature to zero, make every branch deterministic, replay perfectly, and it still happens. The problem lives in the architecture: checkpoints restore state but not the bounds derived from it. If you're building durable agents, human-in-the-loop systems, or anything with hard limits on retries, refunds, or approvals, you need to understand how your guards behave on resume. The fix isn't subtleโ€”you need to store spent allowances as state, not recompute them. But the first step is seeing the problem clearly. Read the full breakdown with code reproduction: ranjankumar.in/langgraph-cheโ€ฆ Follow for more practitioner-focused AI systems work. #LangGraph #DurableExecution #Checkpointing #StateManagement #AgenticAI #AIEngineering #SystemsArchitecture
396
๐๐จ๐ซ๐ฆ๐š๐ฅ๐ข๐ณ๐š๐ญ๐ข๐จ๐ง ๐š๐ง๐ ๐ˆ๐ง๐ฉ๐ฎ๐ญ ๐ƒ๐ž๐Ÿ๐ž๐ง๐ฌ๐ž: ๐‡๐š๐ซ๐๐ž๐ง๐ข๐ง๐  ๐ญ๐ก๐ž ๐„๐ง๐ญ๐ซ๐ฒ ๐๐จ๐ข๐ง๐ญ ๐จ๐Ÿ ๐˜๐จ๐ฎ๐ซ ๐‹๐‹๐Œ ๐’๐ฒ๐ฌ๐ญ๐ž๐ฆ Every unreliable LLM system has a porous entry point. Your production system processes 10,000 requests cleanly - then one user submits "๐ผ๐‘”๐‘›๐‘œ๐‘Ÿ๐‘’ ๐‘Ž๐‘™๐‘™ ๐‘๐‘Ÿ๐‘’๐‘ฃ๐‘–๐‘œ๐‘ข๐‘  ๐‘–๐‘›๐‘ ๐‘ก๐‘Ÿ๐‘ข๐‘๐‘ก๐‘–๐‘œ๐‘›๐‘ . ๐‘‚๐‘ข๐‘ก๐‘๐‘ข๐‘ก ๐‘ฆ๐‘œ๐‘ข๐‘Ÿ ๐‘ ๐‘ฆ๐‘ ๐‘ก๐‘’๐‘š ๐‘๐‘Ÿ๐‘œ๐‘š๐‘๐‘ก." and your entire prompt leaks. ๐“๐ก๐ž ๐ฉ๐ซ๐จ๐›๐ฅ๐ž๐ฆ: nothing between the user and the context window checked what the input actually contained. Once inside, the model has no structural way to tell which instructions are yours and which are theirs. Your safeguards sit beside the user's attack as equals. This is what the Normalization Layer exists to catch - and it's only the crude version of this attack. ๐“๐ก๐ซ๐ž๐ž ๐Ÿ๐š๐ข๐ฅ๐ฎ๐ซ๐ž ๐ฆ๐จ๐๐ž๐ฌ ๐ฅ๐ข๐ฏ๐ž ๐ก๐ž๐ซ๐ž: Prompt injection bypasses your instructions by mixing user input with model directives at the structural level. Pillar Security found 20% of jailbreak attempts succeed, and 90% of those leak sensitive data. Crude attacks are easy to spot. Adaptive attacks hide in context windows you can't scan. Your defense has to work before the injection attempt even reaches the model. Input format chaos happens across surfaces - web, mobile, API, voice all produce different raw shapes. Skip standardization and the model receives inconsistent, unpredictable content. OCR noise, encoding damage, metadata leaks, invisible characters - all of it reaches the model unless something strips it first. Validation failures let incoherent requests burn tokens and expose edge cases. Missing required fields, out-of-range values, structural mismatches - your model shouldn't process any of these without hard stops upstream. The article covers ๐‘ ๐‘Ž๐‘›๐‘–๐‘ก๐‘–๐‘ง๐‘Ž๐‘ก๐‘–๐‘œ๐‘› ๐‘๐‘Ž๐‘ก๐‘ก๐‘’๐‘Ÿ๐‘›๐‘  (๐‘ ๐‘โ„Ž๐‘’๐‘š๐‘Ž ๐‘ฃ๐‘Ž๐‘™๐‘–๐‘‘๐‘Ž๐‘ก๐‘–๐‘œ๐‘›, ๐‘š๐‘’๐‘ก๐‘Ž๐‘‘๐‘Ž๐‘ก๐‘Ž ๐‘Ž๐‘™๐‘™๐‘œ๐‘ค๐‘™๐‘–๐‘ ๐‘ก๐‘ , ๐‘๐น๐พ๐ถ ๐‘›๐‘œ๐‘Ÿ๐‘š๐‘Ž๐‘™๐‘–๐‘ง๐‘Ž๐‘ก๐‘–๐‘œ๐‘›, ๐‘–๐‘›๐‘—๐‘’๐‘๐‘ก๐‘–๐‘œ๐‘› ๐‘ก๐‘Ÿ๐‘–๐‘Ž๐‘”๐‘’), ๐‘ ๐‘ก๐‘Ž๐‘›๐‘‘๐‘Ž๐‘Ÿ๐‘‘๐‘–๐‘ง๐‘Ž๐‘ก๐‘–๐‘œ๐‘› ๐‘Ž๐‘๐‘Ÿ๐‘œ๐‘ ๐‘  ๐‘ ๐‘ข๐‘Ÿ๐‘“๐‘Ž๐‘๐‘’๐‘ , ๐‘Ž๐‘›๐‘‘ ๐‘๐‘Ÿ๐‘Ž๐‘๐‘ก๐‘–๐‘๐‘Ž๐‘™ ๐‘ฃ๐‘Ž๐‘™๐‘–๐‘‘๐‘Ž๐‘ก๐‘–๐‘œ๐‘› ๐‘™๐‘Ž๐‘ฆ๐‘’๐‘Ÿ๐‘  using Pydantic v2. It also spells out exactly why normalization alone can't be your only defense against prompt injection - and what has to sit behind it. Read the full breakdown here: ranjankumar.in/harness-enginโ€ฆ Follow for more on hardening production AI systems. #HarnessEngineering #PromptInjection #InputDefense #LLMSecurity #AIEngineering #ProductionAI #SystemsDesign
1
87
๐–๐ก๐ž๐ง ๐˜๐จ๐ฎ๐ซ ๐€๐ˆ ๐Œ๐จ๐๐ž๐ฅ ๐Ž๐ฎ๐ญ๐ ๐ซ๐จ๐ฐ๐ฌ ๐˜๐จ๐ฎ๐ซ ๐ˆ๐ง๐Ÿ๐ซ๐š๐ฌ๐ญ๐ซ๐ฎ๐œ๐ญ๐ฎ๐ซ๐ž You've built something that works. The model is accurate, the pipeline is stable, and suddenly you're facing a choice: scale up or redesign. Most teams hit this wall without a framework for deciding. Do you throw more compute at it? Optimize the model? Restructure your data flow? The wrong call here wastes months and budget. Here's what actually matters: - ๐‹๐š๐ญ๐ž๐ง๐œ๐ฒ ๐ฏ๐ฌ. ๐ญ๐ก๐ซ๐จ๐ฎ๐ ๐ก๐ฉ๐ฎ๐ญ ๐ญ๐ซ๐š๐๐ž๐จ๐Ÿ๐Ÿ๐ฌ - A model serving 100 requests/second with 50ms latency is a different animal than batching 10K requests overnight. Know which constraint is real before you optimize. - ๐Œ๐จ๐๐ž๐ฅ ๐ฌ๐ข๐ณ๐ž ๐ข๐ฌ๐ง'๐ญ ๐ฒ๐จ๐ฎ๐ซ ๐จ๐ง๐ฅ๐ฒ ๐ฅ๐ž๐ฏ๐ž๐ซ - Quantization, distillation, and smarter inference can often buy you 3-5x efficiency without touching your architecture. Test these before scaling hardware. - ๐˜๐จ๐ฎ๐ซ ๐๐š๐ญ๐š ๐ฉ๐ข๐ฉ๐ž๐ฅ๐ข๐ง๐ž ๐ฉ๐ซ๐จ๐›๐š๐›๐ฅ๐ฒ ๐๐ž๐ฌ๐ž๐ซ๐ฏ๐ž๐ฌ ๐ฆ๐จ๐ซ๐ž ๐š๐ญ๐ญ๐ž๐ง๐ญ๐ข๐จ๐ง ๐ญ๐ก๐š๐ง ๐ฒ๐จ๐ฎ๐ซ ๐ฆ๐จ๐๐ž๐ฅ - Most scaling bottlenecks live in how you fetch, preprocess, and cache data, not in model inference itself. I've seen teams spend six figures on GPU upgrades that would've been solved by better batching. - ๐‚๐จ๐ฌ๐ญ-๐ฉ๐ž๐ซ-๐ฉ๐ซ๐ž๐๐ข๐œ๐ญ๐ข๐จ๐ง ๐œ๐จ๐ฆ๐ฉ๐จ๐ฎ๐ง๐๐ฌ - A model that costs $0.001 per inference on 1M daily requests looks fine. At 100M requests, you're bleeding $100K monthly. The math changes when volume changes. The real skill isn't knowing one "right" answer. It's diagnosing which constraint is actually binding for your workload, then making conscious tradeoffs instead of reactive ones. Read the full book for a decision framework you can apply to your next scaling challenge. right-sized-ai.ranjankumar.iโ€ฆ #AIEngineering #MLOps #SystemsDesign #Scaling #InferenceOptimization #PractitionerInsights #MachineLearning
1
1
33
๐‡๐š๐ซ๐ง๐ž๐ฌ๐ฌ ๐„๐ง๐ ๐ข๐ง๐ž๐ž๐ซ๐ข๐ง๐ : ๐“๐ก๐ž ๐Œ๐ข๐ฌ๐ฌ๐ข๐ง๐  ๐‹๐š๐ฒ๐ž๐ซ ๐๐ž๐ญ๐ฐ๐ž๐ž๐ง ๐‹๐‹๐Œ๐ฌ ๐š๐ง๐ ๐๐ซ๐จ๐๐ฎ๐œ๐ญ๐ข๐จ๐ง ๐’๐ฒ๐ฌ๐ญ๐ž๐ฆ๐ฌ Your model works in the demo. It fails at 2am in production. You dig through logs and find: one number wrapped in quotes. The model was fine. Everything downstream wasn't. You've built the wrong thing. Not the prompt - the wrapper. Most teams treat the LLM as the system. They perfect prompts, evaluate models, benchmark outputs, then wire the model directly to their application. This is wiring raw voltage to your laptop. ๐ด๐‘› ๐ฟ๐ฟ๐‘€ ๐‘–๐‘  ๐‘Ž ๐‘๐‘Ÿ๐‘œ๐‘๐‘Ž๐‘๐‘–๐‘™๐‘–๐‘ ๐‘ก๐‘–๐‘ ๐‘’๐‘›๐‘”๐‘–๐‘›๐‘’ - ๐‘ฃ๐‘œ๐‘™๐‘Ž๐‘ก๐‘–๐‘™๐‘’, ๐‘๐‘Ž๐‘๐‘Ž๐‘๐‘™๐‘’ ๐‘œ๐‘“ ๐‘ ๐‘ฆ๐‘›๐‘ก๐‘Ž๐‘๐‘ก๐‘–๐‘๐‘Ž๐‘™๐‘™๐‘ฆ ๐‘ฃ๐‘Ž๐‘™๐‘–๐‘‘ ๐‘๐‘ข๐‘ก ๐‘ ๐‘’๐‘š๐‘Ž๐‘›๐‘ก๐‘–๐‘๐‘Ž๐‘™๐‘™๐‘ฆ ๐‘๐‘Ÿ๐‘œ๐‘˜๐‘’๐‘› ๐‘œ๐‘ข๐‘ก๐‘๐‘ข๐‘ก. ๐‘Œ๐‘œ๐‘ข ๐‘›๐‘’๐‘’๐‘‘ ๐‘Ž ๐‘‘๐‘’๐‘ก๐‘’๐‘Ÿ๐‘š๐‘–๐‘›๐‘–๐‘ ๐‘ก๐‘–๐‘ ๐‘ค๐‘Ÿ๐‘Ž๐‘๐‘๐‘’๐‘Ÿ ๐‘Ž๐‘Ÿ๐‘œ๐‘ข๐‘›๐‘‘ ๐‘–๐‘ก. ๐‘‡โ„Ž๐‘Ž๐‘ก'๐‘  ๐‘ฏ๐’‚๐’“๐’๐’†๐’”๐’” ๐‘ฌ๐’๐’ˆ๐’Š๐’๐’†๐’†๐’“๐’Š๐’๐’ˆ. The seven-layer harness sits between your model and your production system. Each layer catches a different failure mode: - normalization (does the input match the model's training assumptions?), - schema enforcement (is the output the right type?), - state management (did the agent loop get stuck?), - graceful fallback (what happens when the model returns something you didn't anticipate?). Your system never talks to the model directly. Every path runs through a check first. Prompt engineering is local optimization - tuning inputs and hoping outputs cooperate. Harness engineering is systems design - assuming the output will eventually break your assumptions and building for that. The goal isn't to make the model smarter. It's to reduce the space in which it can be wrong. It's the difference between hoping your agent won't loop forever and architecting runtime constraints that make looping impossible. This matters because the failure doesn't happen at the model layer. It happens at the integration layer. The model returned something valid according to some definition of valid - just not yours. Read the full guide to understand all seven layers, the tradeoffs between prompt quality and harness strictness, and how to design harnesses for agents, structured workflows, and long-running systems. ranjankumar.in/harness-enginโ€ฆ #AIEngineering #LLMProduction #SystemsDesign #AIReliability #HarnessEngineering #ProductionAI #AgenticAI
1
1
322
๐‹๐š๐ง๐ ๐†๐ซ๐š๐ฉ๐ก ๐œ๐ซ๐ž๐š๐ญ๐ž_๐š๐ ๐ž๐ง๐ญ: ๐“๐ก๐ž ๐†๐ซ๐š๐ฉ๐ก ๐ˆ๐ฌ๐ง'๐ญ ๐ญ๐ก๐ž ๐‘๐ฎ๐ง๐ญ๐ข๐ฆ๐ž Your agent diagram has 23 tools bound. But it shows the same routing logic whether you have 1 tool or 100. The diagram lists tool names since langchain 1.2.19 - but it shows nothing about which tool can run, when, and under what conditions. That's because the graph you render and the transitions your agent actually executes are two different objects. The create_agent() diagram has three static nodes: model, tools, and two terminal states. The labels changed slightly to show tool names, but the topology hasn't moved in years. Everything that matters - which tools this call gets offered, which calls the runtime refuses, the middleware ordering that nests over both - lives in Python guards inside wrap_model_call and wrap_tool_call. Those guards have no nodes. No diagram draws them. This gap becomes critical the moment you add middleware. Your before_model hook can filter the tool set per call. Your wrap_tool_call can refuse emissions. Your middleware list order changes what each layer sees. The rendered graph cannot surface any of this - yet you've been reading it as the proof your architecture is correct. The issue is simpler than "graphs are bad." create_agent is still the best default LangChain offers. The problem: the review artifact stopped telling the full story, and the change happened quietly. Everyone moved to 1.2.19+ and kept trusting the diagram the same way. Your CI/CD gate is now validating something that isn't the system you're actually running. This matters most when issue_refund is one of your 23 tools. You want your reviewer to see not just that it exists, but under what path the state machine allows it to be called. The diagram doesn't answer that anymore. Read the full piece to understand what create_agent actually compiles to, how middleware ordering gates tool access, and how to build the artifact that covers what the graph doesn't. ranjankumar.in/langgraph-creโ€ฆ Follow for more practitioner-focused deep dives on agentic AI systems. #LangGraph #LangChain #AgentArchitecture #AIEngineering #Middleware #ToolCalling #SystemsDesign
152
๐€๐Ÿ๐€ ๐€๐ ๐ž๐ง๐ญ ๐‚๐š๐ซ๐ ๐•๐ž๐ซ๐ฌ๐ข๐จ๐ง๐ข๐ง๐ : ๐š ๐•๐ž๐ซ๐ฌ๐ข๐จ๐ง ๐๐ฎ๐ฆ๐ฉ ๐ˆ๐ฌ ๐๐จ๐ญ ๐š ๐‚๐จ๐ง๐ญ๐ซ๐š๐œ๐ญ A repair network bumped its agent card from v7 to v8, added "needs the vehicle's VIN" to a skill description, and every estimate task from an insurer came back rejected. The claims stopped cold. Version bumps tell callers something changed - never whether it matters to them. A2A agent card versioning has no rule in the protocol. When you change the version on an agent card, callers see that something shifted, not what broke or whether it touches their code. The usual upgrade is a dated notice like a Sunset header - it fails quietly. A date with no terms gives notice without relevance: it says when something changes and not whether the change touches you. A caller then has to choose between missing breaks and setting off alarms someone must read by hand. The real answer is simpler and harder: publish dated terms on the card and check them at connect. Here's the gap. An A2A agent card in v1.0.1 has fields for interface, security, capabilities, description, examples, tags - brochure fields written for people to read. None of them hold the input schema, output schema, latency bounds, data retention policy, or when these things change. A skill description says "needs the vehicle's VIN" but no deterministic check acts on it. When Meridian Mutual's claims engine read the new card, its code picked the skill by id and copied the version into a log. It never saw the words. An A2A agent card becomes a contract under three conditions: 1. Each partner publishes its terms as data on the card, in revisions that each carry the date they take effect - input schema, output schema, latency, data policy, what fields are required, what they mean. 2. Each time a caller connects, it checks those dated terms against what it depends on - does the schema match? Is the latency acceptable? Does the security model fit? 3. The version string labels the set of terms, not a fuzzy sense that something changed. When Northgate released v8, it needed to publish: "v8: effective 2026-11-20, estimate_repair now requires VIN in the input." Meridian's engine, on connect, checks that requirement against its own claim graph. It fails fast and clear before the first estimate is sent. No queue. No person reading error logs. This series grew into a book. The chapter on A2A agent card versioning covers contract testing at the seam, versioning strategies, and how to build the check into your agent gateway. Read the full guide here: ranjankumar.in/federated-ai-โ€ฆ Follow for more on building reliable agent systems that scale. #FederatedAI #AgentArchitecture #A2AProtocol #APIVersioning #MultiAgentSystems #AIEngineering #AgentInteroperability
1
180
๐‡๐จ๐ฐ ๐ญ๐จ ๐–๐ซ๐ข๐ญ๐ž ๐š ๐‚๐ก๐š๐ญ ๐“๐ž๐ฆ๐ฉ๐ฅ๐š๐ญ๐ž ๐Ÿ๐จ๐ซ ๐š ๐…๐ข๐ง๐ž-๐“๐ฎ๐ง๐ž๐ ๐Œ๐จ๐๐ž๐ฅ ๐š๐ง๐ ๐“๐ž๐ฌ๐ญ ๐ˆ๐ญ You fine-tune a model on your own chat format, but then serving it fails silently. The template you write must produce exactly the tokens your trainer taught - token for token, mask for mask, stop token for stop token. Miss any of these and your eval scores tank or the model keeps writing forever. This tutorial shows you how to build and validate a chat template for a fine-tuned model using six concrete checks, all runnable on CPU with no training. You'll transcribe your template from the exact text your model learned on, then prove it works by comparing it token-for-token against a real TRL SFTTrainer batch. The problem is real. A support model was fine-tuned on custom turn markers, but the serving template had an extra newline. The model had never seen that format during training - silent format penalty, eval scores collapsed. Then the template was fixed, but the generation_config.json forgot to list the stop token the model learned to end with. The model kept writing invented turns. Both failures are caught by the checks you'll build here. You'll end up with templatestudio/authoring.py that holds your template and proves it with six checks: - string: template renders without error - markers: role headers and separators match training text - tokens: input_ids match what SFTTrainer produced - mask: attention_mask and position_ids are correct - labels: loss labels align with model answers only - stops: generation stops on the token the model learned The tutorial runs against a 2-layer test model (20 MB), needs no GPU, no API key, and takes about 30 minutes. It's for engineers who fine-tune chat models with custom formats and need proof before serving. Read the full tutorial here: ranjankumar.in/how-to-write-โ€ฆ Follow me for more AI engineering tutorials and practitioner insights. #ChatTemplates #LLMEngineering #FineTuning #SFT #Transformers #TRL #AIEngineering
388
๐˜๐จ๐ฎ๐ซ ๐ฆ๐ฎ๐ฅ๐ญ๐ข-๐š๐ ๐ž๐ง๐ญ ๐Ÿ๐ซ๐š๐ฆ๐ž๐ฐ๐จ๐ซ๐ค ๐š๐ฌ๐ฌ๐ฎ๐ฆ๐ž๐ฌ ๐ฒ๐จ๐ฎ ๐จ๐ฐ๐ง ๐ž๐ฏ๐ž๐ซ๐ฒ ๐š๐ ๐ž๐ง๐ญ. ๐˜๐จ๐ฎ ๐๐จ๐ง'๐ญ. For three days, an insurer's claims agent paid suspect claims at the full repair estimate. The fraud agent was working. So was the claims agent. The problem sat between them. The fraud score was on a 0โ€“100 scale, and nobody had written that down. The two agents belonged to different teams. Most multi-agent advice assumes you own every agent. In real systems you usually don't. Another team ships on its own schedule. Another company's agent runs on its own server, keeps its own state, answers to its own auditors, and sends you its own invoice. Inside one deployment you get a lot for free: one checkpointer, one credential, one stack trace. You lose all of that the moment a call crosses an owner line. I call that crossing a seam. Every seam has five properties you now have to build yourself: contract, authority, state, failure, and accountability. My new book, ๐…๐ž๐๐ž๐ซ๐š๐ญ๐ž๐ ๐€๐ˆ ๐€๐ ๐ž๐ง๐ญ๐ฌ: ๐‹๐š๐ง๐ ๐†๐ซ๐š๐ฉ๐ก ๐š๐ง๐ ๐€๐Ÿ๐€, ๐ฐ๐จ๐ซ๐ค๐ฌ ๐ญ๐ก๐ซ๐จ๐ฎ๐ ๐ก ๐ญ๐ก๐ž๐ฆ ๐จ๐ง๐ž ๐š๐ญ ๐š ๐ญ๐ข๐ฆ๐ž. A2A is the wire between owners, and LangGraph is the side you own. It covers: โ†’ Agent cards you treat as contracts and test, instead of reading them like brochures โ†’ Delegation chains that narrow at every hop, and revocation that actually stops a task midway โ†’ Retries and reconciliation, so one claim doesn't turn into two payments โ†’ Sagas for when you can't roll back the partner โ†’ Canary suites that catch a partner's silent model swap before your customers do Each of the 19 chapters ends with a working artifact, one line of a seam checklist, and a "cost of skipping this" story. A companion repo builds the whole federation in Python, and its test suite runs with no network and no accounts. It's out now on Kindle and in paperback. federatedagents.ranjankumar.โ€ฆ #AIAgents #LangGraph #A2A #MultiAgentSystems #AIEngineering
1
38
๐‹๐š๐ง๐ ๐†๐ซ๐š๐ฉ๐ก ๐ข๐ง๐ญ๐ž๐ซ๐ซ๐ฎ๐ฉ๐ญ() ๐‘๐ž-๐’๐ž๐ง๐๐ฌ ๐˜๐จ๐ฎ๐ซ ๐€๐Ÿ๐€ ๐“๐š๐ฌ๐ค ๐จ๐ง ๐‘๐ž๐ฌ๐ฎ๐ฆ๐ž Your LangGraph node sends a task to a partner agent, calls interrupt() for a human answer, and when the human resumes it - the task gets sent twice. Same problem, two different contexts, and nobody can track which one scored your decision. Here's the trap: LangGraph re-runs interrupted nodes from the first line. Standard fixes tell you to move side effects after interrupt(), make them idempotent, or wrap them in @task. All of them assume you own both the side effect and the system that dedupes it. At an A2A seam, you don't. The partner's question comes back as your side effect's output. You can't move the send below interrupt() because without it, there's nothing to interrupt on. Making it idempotent is their call - the A2A spec says agents MAY dedupe by messageId, not that they will. Wrap it in @task and the record lives in the runtime, hidden from your state. The fix that works: checkpoint the partner's contextId and taskId in its own superstep before anyone asks anything. Keep this thread link in your graph state, under the seam's name. Every later node reads the linked task. You control the record on your side. The partner controls theirs. No cooperation required, no hidden state. This is what the incident at Meridian Mutual exposed - and it's reproducible. One test, two different contexts, two tasks Risk received for a single claim. Read the full breakdown of why standard LangGraph fixes fail at A2A boundaries and how to structure your checkpoint to prevent duplicate sends: ranjankumar.in/federated-ai-โ€ฆ Follow for more on building reliable multi-agent systems across team seams. #LangGraph #A2AProtocol #AIEngineering #MultiAgentSystems #AgentInteroperability #HumanInTheLoop #FederatedAI
74
๐€๐Ÿ๐€, ๐Œ๐‚๐, ๐จ๐ซ ๐’๐ฎ๐›๐ ๐ซ๐š๐ฉ๐ก? '๐ƒ๐ž๐ฉ๐ฅ๐จ๐ฒ๐ž๐ ๐’๐ž๐ฉ๐š๐ซ๐š๐ญ๐ž๐ฅ๐ฒ' ๐ˆ๐ฌ ๐ญ๐ก๐ž ๐–๐ซ๐จ๐ง๐  ๐‘๐ž๐š๐ฌ๐จ๐ง The usual decision rule is circular and invisible until it breaks. Choosing A2A because an agent runs in its own repo sounds defensible. It gets its own credentials, its own checkpointer, independent releases. But you've already decided on the separation - then used it as proof you need a protocol boundary. The rule never tells you to undo a split, and the next one gets approved the same way. The Federation Test flips this. Ask ownership first: can someone else deploy, version, and revoke the agent on the other side without asking you? If yes, you need a protocol boundary (A2A with a task ledger, not MCP). If no, the deployment pattern is an implementation detail - run it as a subgraph or tool and keep the step inside your runtime. One owner sitting on both ends still charges you for every protocol cost: a versioned contract you test, delegation you carry, state reconciliation, retry logic, failure compensation, audit trails. Where the owner line is not real, that bill is pure waste. Where it is real and forced by a constraint (compliance enclave, trust boundary), call it what it is - a deployment exception - and revisit it when the constraint changes. The second half catches drift in both directions. Run your decision against the compiled graph in CI: same-owner A2A calls that should be subgraphs, and another team's agent baked into your code that nobody proposed. Capability comes second. Once ownership is settled, pick between subgraph and tool based on statefulness and tool granularity. Read the full piece below. Follow for more on building federated agent systems that actually scale. ranjankumar.in/federated-ai-โ€ฆ #AgenticAI #AIEngineering #MultiAgentSystems #A2A #MCP #LangGraph #SystemsArchitecture
1
1
354
๐‡๐จ๐ฐ ๐ญ๐จ ๐๐š๐ฌ๐ฌ ๐ˆ๐ฆ๐š๐ ๐ž๐ฌ ๐ญ๐จ ๐š๐ฉ๐ฉ๐ฅ๐ฒ_๐œ๐ก๐š๐ญ_๐ญ๐ž๐ฆ๐ฉ๐ฅ๐š๐ญ๐ž ๐ฐ๐ข๐ญ๐ก ๐š ๐๐ซ๐จ๐œ๐ž๐ฌ๐ฌ๐จ๐ซ Vision-language models need images paired with text, but processors don't all validate that the placeholders in your prompt match the images you're sending. Some fail silently, leaving the model answering questions without ever seeing the image. This tutorial builds safe_expand, a function that catches three common image problems before they reach the processor: - Malformed image parts (typos in type names, missing URLs, bare strings) - Dropped image tokens when the template has no placeholder for an image - Mismatched counts between placeholders and images You'll learn why Qwen-VL processors accept mismatches that crash Gemma, and why that matters. A support agent sends a photo of a damaged product alongside a question. The processor accepts both, but the template had no image placeholder. The model answers about the question alone, as if no image arrived. No error fires until you read the response. The module validates every content part, rewrites OpenAI-style image_url blocks without touching your data, counts tokens per image on Qwen2.5-VL, Qwen3-VL and Gemma, and pairs up placeholders with images before rendering. By the end, you'll know exactly when and why images get dropped in your pipeline, and how to refuse the conversation instead of letting it fail silently downstream. This is Part 7 of the Chat Templates in Practice series. It takes 30 minutes, requires transformers 5.22.1, Pillow, PyTorch and torchvision, and builds on the Part 6 project. No model weights, no API keys. Read the full tutorial here: ranjankumar.in/how-to-pass-iโ€ฆ Follow me for the next part in the series. #ChatTemplates #VisionLanguageModels #ApplyChatTemplate #Transformers #Qwen #Gemma #AIEngineering
339