<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: rishabh jain</title>
    <description>The latest articles on DEV Community by rishabh jain (@rishabh_jain_4d7dd020e595).</description>
    <link>https://dev.to/rishabh_jain_4d7dd020e595</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3986071%2Fcdff2f9d-ad6b-4356-9e47-718f3b405d90.png</url>
      <title>DEV Community: rishabh jain</title>
      <link>https://dev.to/rishabh_jain_4d7dd020e595</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rishabh_jain_4d7dd020e595"/>
    <language>en</language>
    <item>
      <title>The hardest LLM bugs are contract failures, not hallucinations</title>
      <dc:creator>rishabh jain</dc:creator>
      <pubDate>Sat, 20 Jun 2026 03:43:11 +0000</pubDate>
      <link>https://dev.to/rishabh_jain_4d7dd020e595/the-hardest-llm-bugs-are-contract-failures-not-hallucinations-7g2</link>
      <guid>https://dev.to/rishabh_jain_4d7dd020e595/the-hardest-llm-bugs-are-contract-failures-not-hallucinations-7g2</guid>
      <description>&lt;p&gt;When people talk about LLM failures, the default word is usually "hallucination."&lt;/p&gt;

&lt;p&gt;But after building and testing LLM apps, I think many production bugs are better described as contract failures.&lt;/p&gt;

&lt;p&gt;A hallucination is when the model makes something up. That matters, but it is not the only failure mode.&lt;/p&gt;

&lt;p&gt;The subtler bugs happen when the model had enough context, but violated the surrounding system contract.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It skipped a required tool call.&lt;/li&gt;
&lt;li&gt;It returned JSON that looked valid but broke the downstream schema.&lt;/li&gt;
&lt;li&gt;It made a claim without the evidence artifact the workflow expected.&lt;/li&gt;
&lt;li&gt;It ignored a tool result.&lt;/li&gt;
&lt;li&gt;It answered before satisfying a validation step.&lt;/li&gt;
&lt;li&gt;It followed one instruction while violating another.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Retrieval failures are usually easier to notice. You can compare the answer against the retrieved chunks and see that the grounding is weak.&lt;/p&gt;

&lt;p&gt;Contract failures are harder because the answer may look plausible. The text might even be correct in isolation. But the system still failed because the model did not do the thing the application required.&lt;/p&gt;

&lt;p&gt;For example, in a support agent, the problem may not be that the model gave a bad refund answer. The problem may be that it answered without first calling the refund eligibility tool.&lt;/p&gt;

&lt;p&gt;In a data extraction app, the problem may not be that the model misunderstood the document. The problem may be that it returned almost-correct JSON that fails validation in the next service.&lt;/p&gt;

&lt;p&gt;In a RAG workflow, the problem may not be missing context. The problem may be that the answer made a claim without attaching the citation or artifact that proves it.&lt;/p&gt;

&lt;p&gt;This changed how I think about LLM debugging.&lt;/p&gt;

&lt;p&gt;Prompt and response logs are useful, but they are not enough. A debugger should also inspect the contracts around the model call:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Was the required tool called?&lt;/li&gt;
&lt;li&gt;Were the tool arguments valid?&lt;/li&gt;
&lt;li&gt;Was the tool result used?&lt;/li&gt;
&lt;li&gt;Did the output match the schema?&lt;/li&gt;
&lt;li&gt;Was each claim supported by evidence?&lt;/li&gt;
&lt;li&gt;Did the model satisfy the approval or safety preconditions?&lt;/li&gt;
&lt;li&gt;Is this failure reproducible as a regression case?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the direction I am taking with DebugAI, a Python SDK I have been building.&lt;/p&gt;

&lt;p&gt;The goal is to take a bad LLM response and return a structured debug artifact:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;failure type&lt;/li&gt;
&lt;li&gt;evidence&lt;/li&gt;
&lt;li&gt;likely root cause&lt;/li&gt;
&lt;li&gt;suggested fix&lt;/li&gt;
&lt;li&gt;regression-testable case&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, instead of only saying "bad answer," the diagnosis should say something like:&lt;/p&gt;

&lt;p&gt;{&lt;br&gt;
  "failure": "tool_call_failure",&lt;br&gt;
  "evidence": [&lt;br&gt;
    "Expected refund_order tool before answering",&lt;br&gt;
    "No tool call was made"&lt;br&gt;
  ],&lt;br&gt;
  "fix": "Require tool execution before final answer and reject responses without tool evidence."&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;I think this framing is more useful than treating every LLM bug as a hallucination.&lt;/p&gt;

&lt;p&gt;Some bugs are grounding failures.&lt;br&gt;
Some are retrieval failures.&lt;br&gt;
Some are instruction failures.&lt;br&gt;
Some are output validation failures.&lt;br&gt;
Some are tool contract failures.&lt;/p&gt;

&lt;p&gt;The more specific the failure class, the easier it is to fix and test.&lt;/p&gt;

&lt;p&gt;Repo is public here if useful: &lt;a href="https://github.com/civicRJ/DebugAI" rel="noopener noreferrer"&gt;https://github.com/civicRJ/DebugAI&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>softwareengineering</category>
      <category>testing</category>
    </item>
    <item>
      <title>How I debug RAG failures with deterministic signals</title>
      <dc:creator>rishabh jain</dc:creator>
      <pubDate>Mon, 15 Jun 2026 18:24:59 +0000</pubDate>
      <link>https://dev.to/rishabh_jain_4d7dd020e595/how-i-debug-rag-failures-with-deterministic-signals-2dk0</link>
      <guid>https://dev.to/rishabh_jain_4d7dd020e595/how-i-debug-rag-failures-with-deterministic-signals-2dk0</guid>
      <description>&lt;p&gt;When building LLM apps, one frustrating problem is that a response can be wrong for many different reasons.&lt;/p&gt;

&lt;p&gt;The model may have hallucinated. The retriever may have pulled the wrong chunks. The answer may not be grounded in the provided context. A tool call may be missing. A JSON schema may have failed. Or the prompt may simply be brittle.&lt;/p&gt;

&lt;p&gt;I started experimenting with a more structured way to debug these failures.&lt;/p&gt;

&lt;p&gt;Instead of only asking another LLM "is this answer good?", I wanted to compute signals from the request and response itself.&lt;/p&gt;

&lt;p&gt;The inputs I care about are usually:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;prompt&lt;/li&gt;
&lt;li&gt;model output&lt;/li&gt;
&lt;li&gt;retrieved chunks&lt;/li&gt;
&lt;li&gt;similarity scores&lt;/li&gt;
&lt;li&gt;tool calls&lt;/li&gt;
&lt;li&gt;expected tools&lt;/li&gt;
&lt;li&gt;response schema&lt;/li&gt;
&lt;li&gt;latency&lt;/li&gt;
&lt;li&gt;model settings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From these, I try to classify the failure into categories like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;retrieval failure&lt;/li&gt;
&lt;li&gt;RAG hallucination&lt;/li&gt;
&lt;li&gt;schema violation&lt;/li&gt;
&lt;li&gt;missing tool call&lt;/li&gt;
&lt;li&gt;citation failure&lt;/li&gt;
&lt;li&gt;prompt brittleness&lt;/li&gt;
&lt;li&gt;ambiguous prompt&lt;/li&gt;
&lt;li&gt;instruction-following issue&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, if the retriever returns chunks with low similarity and the output answers confidently anyway, that points toward a retrieval or grounding problem.&lt;/p&gt;

&lt;p&gt;If the chunks are relevant but the output introduces unsupported claims, that looks more like hallucination.&lt;/p&gt;

&lt;p&gt;If a tool was expected but no tool call happened, that is a different failure mode entirely.&lt;/p&gt;

&lt;p&gt;A simple example:&lt;/p&gt;

&lt;p&gt;from debugai import analyze&lt;/p&gt;

&lt;p&gt;result = analyze(&lt;br&gt;
    prompt="What is the refund policy?",&lt;br&gt;
    output="You can get a full refund after 90 days.",&lt;br&gt;
    chunks=["Electronics can be returned within 30 days with receipt."],&lt;br&gt;
    similarity_scores=[0.82],&lt;br&gt;
)&lt;/p&gt;

&lt;p&gt;print(result["primary"])&lt;/p&gt;

&lt;p&gt;I’m building this into a small Python SDK called DebugAI.&lt;/p&gt;

&lt;p&gt;Install:&lt;/p&gt;

&lt;p&gt;pip install debugerai&lt;/p&gt;

&lt;p&gt;The SDK can run locally without logging into a website. I also have a hosted dashboard for saving traces and diagnoses, but local usage is the main thing I’m testing right now.&lt;/p&gt;

&lt;p&gt;The goal is not to magically solve LLM reliability. It is to make failures easier to name and inspect.&lt;/p&gt;

&lt;p&gt;I’m still early, so I’m mainly looking for feedback from people building LLM/RAG apps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Are these the right failure categories?&lt;/li&gt;
&lt;li&gt;What signals would you want to see?&lt;/li&gt;
&lt;li&gt;Do you debug this another way?&lt;/li&gt;
&lt;li&gt;Should tools like this be local-first by default?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Link: &lt;a href="https://debugai-5lb2.onrender.com" rel="noopener noreferrer"&gt;https://debugai-5lb2.onrender.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>machinelearning</category>
      <category>devtools</category>
    </item>
  </channel>
</rss>
