<?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: Aman Tebriwal</title>
    <description>The latest articles on DEV Community by Aman Tebriwal (@aman_tebriwal).</description>
    <link>https://dev.to/aman_tebriwal</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3934393%2Ff2a51e8d-c142-4c42-936c-1828ff11c9c4.png</url>
      <title>DEV Community: Aman Tebriwal</title>
      <link>https://dev.to/aman_tebriwal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aman_tebriwal"/>
    <language>en</language>
    <item>
      <title>Building Stateful Agricultural AI: The Power of Hindsight Memory and CascadeFlow Routing</title>
      <dc:creator>Aman Tebriwal</dc:creator>
      <pubDate>Sat, 16 May 2026 13:55:03 +0000</pubDate>
      <link>https://dev.to/aman_tebriwal/building-stateful-agricultural-ai-the-power-of-hindsight-memory-and-cascadeflow-routing-207n</link>
      <guid>https://dev.to/aman_tebriwal/building-stateful-agricultural-ai-the-power-of-hindsight-memory-and-cascadeflow-routing-207n</guid>
      <description>&lt;h2&gt;
  
  
  Giving 50,000 Farmers a 14-Month Farm Memory using Hindsight and CascadeFlow
&lt;/h2&gt;

&lt;p&gt;Indian farmers lose 30% of their crops every year to diseases that repeat: the same ones, on the same farms, every monsoon season. Yet, every agricultural AI tool on the market treats each outbreak like it's the first time. They give textbook answers that are technically correct, but practically useless because they ignore the farm's unique history. The farmer losing their harvest doesn't need an encyclopedia; they need an advisor who remembers what worked last time.&lt;/p&gt;

&lt;p&gt;We realized stateless AI is actively harmful for agriculture. So, we built AgroShield AI, a crop disease detection platform powered by Google Gemini, but with a critical difference: it remembers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/amantebriwal4321/Agreshield/raw/main/docs/Recording.mp4" rel="noopener noreferrer"&gt;&lt;br&gt;
    &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Famantebriwal4321%2FAgreoshield%2Fmain%2Fdocs%2Fscreenshots%2Fhome.png" width="800" alt="Watch Demo Video" title="Click to watch demo" height="404"&gt;&lt;br&gt;
  &lt;/a&gt;&lt;br&gt;
  &lt;br&gt;&lt;br&gt;
  Click the image above to watch the 15-second Demo Video&lt;/p&gt;

&lt;h2&gt;
  
  
  The Core Technical Story: Hindsight
&lt;/h2&gt;

&lt;p&gt;To solve the memory problem, we integrated &lt;strong&gt;Hindsight&lt;/strong&gt;, a persistent memory engine that allows the AI to retain, recall, and reflect on past sessions. &lt;/p&gt;

&lt;p&gt;Instead of just returning a diagnosis, every scan is logged into the farm's memory schema:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Famantebriwal4321%2FAgreoshield%2Fmain%2Fdocs%2Fscreenshots%2FScreenshot%25202026-05-16%2520160805.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Famantebriwal4321%2FAgreoshield%2Fmain%2Fdocs%2Fscreenshots%2FScreenshot%25202026-05-16%2520160805.png" width="800" alt="AI Disease Analysis Results" height="408"&gt;&lt;/a&gt;&lt;br&gt;
  &lt;br&gt;&lt;br&gt;
  Detailed Computer Vision analysis with Hindsight memory integration&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Detection events:&lt;/strong&gt; Disease type, confidence score, crop, and date&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Outcomes:&lt;/strong&gt; Applied treatments and recovery rates&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context:&lt;/strong&gt; Seasonal and weather-correlated data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When a farmer uploads a new photo, Hindsight queries this 14-month history. The recall logic fundamentally changes how the AI responds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// When a disease is detected, recall similar farm history&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;similarCases&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;hindsight&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;recall&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;disease&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; on &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;crop&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; during &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;season&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// The AI response changes based on what Hindsight returns&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;insight&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;similarCases&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
  &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;`Recurring pattern: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;similarCases&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; similar outbreaks detected`&lt;/span&gt;
  &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`First occurrence of &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;disease&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; on this farm`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The Before and After is striking:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Session 1:&lt;/strong&gt; &lt;em&gt;"Early Blight detected. Apply copper fungicide."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Session 8:&lt;/strong&gt; &lt;em&gt;"Third early blight recurrence detected on your tomato crop. This matches your August 2024 and July 2023 patterns. Copper oxychloride at 0.25% resolved it in 12 days last time. Pre-treatment in June reduces your risk by 73%."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Famantebriwal4321%2FAgreoshield%2Fmain%2Fdocs%2Fscreenshots%2FScreenshot%25202026-05-16%2520160846.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Famantebriwal4321%2FAgreoshield%2Fmain%2Fdocs%2Fscreenshots%2FScreenshot%25202026-05-16%2520160846.png" width="800" alt="Hindsight Timeline in Hindi" height="406"&gt;&lt;/a&gt;&lt;br&gt;
  &lt;br&gt;&lt;br&gt;
  Multilingual support: Hindsight memory tracking outbreaks in Hindi&lt;/p&gt;

&lt;h2&gt;
  
  
  The Secondary Story: CascadeFlow
&lt;/h2&gt;

&lt;p&gt;While Hindsight made the AI smart, we needed it to be production-ready. Running complex vision models on every simple query burns API budget fast. &lt;/p&gt;

&lt;p&gt;We implemented &lt;strong&gt;CascadeFlow&lt;/strong&gt; as our intelligent routing layer. Every AI call passes through this router before hitting the model:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Famantebriwal4321%2FAgreoshield%2Fmain%2Fdocs%2Fscreenshots%2FScreenshot%25202026-05-16%2520160904.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Famantebriwal4321%2FAgreoshield%2Fmain%2Fdocs%2Fscreenshots%2FScreenshot%25202026-05-16%2520160904.png" width="800" alt="CascadeFlow Routing Dashboard" height="408"&gt;&lt;/a&gt;&lt;br&gt;
  &lt;br&gt;&lt;br&gt;
  CascadeFlow: Optimizing runtime by routing queries based on confidence and complexity&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;latencyMs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;estimatedCost&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;selectModel&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;queryType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;image_analysis&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;confidenceScore&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;initialEstimate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;imageSizeBytes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="c1"&gt;// High confidence → Flash (0.8s, ₹0.002)&lt;/span&gt;
&lt;span class="c1"&gt;// Low confidence → Pro (3.2s, ₹0.018) with logged escalation reason&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The Real Impact:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Avg response time&lt;/td&gt;
&lt;td&gt;1.2s (↓40% from baseline)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Model escalation rate&lt;/td&gt;
&lt;td&gt;12% of requests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost per analysis&lt;/td&gt;
&lt;td&gt;₹0.002 avg vs ₹0.018 without routing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Monthly savings&lt;/td&gt;
&lt;td&gt;₹2,340 (~$28)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;By routing 88% of our queries to the faster &lt;code&gt;gemini-1.5-flash&lt;/code&gt; model and only escalating complex multi-disease scenarios to &lt;code&gt;gemini-1.5-pro&lt;/code&gt;, we achieved a &lt;strong&gt;61% cost reduction&lt;/strong&gt; with zero drop in diagnostic quality.&lt;/p&gt;

&lt;h2&gt;
  
  
  Breaking Language Barriers
&lt;/h2&gt;

&lt;p&gt;AgroShield isn't just for English speakers. We built full multilingual support for 9 Indian languages. Our AI Chat and voice advisor adjust their context and output based on the farmer's preferred language, all while maintaining the same persistent memory across language switches.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Famantebriwal4321%2FAgreoshield%2Fmain%2Fdocs%2Fscreenshots%2FScreenshot%25202026-05-16%2520161530.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Famantebriwal4321%2FAgreoshield%2Fmain%2Fdocs%2Fscreenshots%2FScreenshot%25202026-05-16%2520161530.png" width="800" alt="Multilingual AI Chat" height="409"&gt;&lt;/a&gt;&lt;br&gt;
  &lt;br&gt;&lt;br&gt;
  AI Voice Chat with support for Hindi, Kannada, Telugu, and more&lt;/p&gt;

&lt;h2&gt;
  
  
  What Surprised Us
&lt;/h2&gt;

&lt;p&gt;The biggest surprise was how the combination of Hindsight and CascadeFlow affected user trust. When the AI explicitly stated &lt;em&gt;why&lt;/em&gt; it was recommending a specific dosage ("Because this exact dosage worked for your tomato crop last August"), farmers were significantly more likely to follow the advice. Transparency in both memory recall and routing logic proved to be a massive UX feature, not just a backend optimization.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons Learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stateless AI is a toy; stateful AI is a product:&lt;/strong&gt; Without memory, you are building a generic wrapper. With memory, you are building a personalized tool.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Routing is mandatory for scale:&lt;/strong&gt; Don't use your heaviest model for everything. Intelligent escalation saves your budget.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Show your work:&lt;/strong&gt; Exposing the memory logic directly to the user builds trust faster than accurate textbook answers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AgroShield AI Repo:&lt;/strong&gt; &lt;a href="https://github.com/amantebriwal4321/Agreoshield" rel="noopener noreferrer"&gt;https://github.com/amantebriwal4321/Agreoshield&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Live Demo:&lt;/strong&gt; &lt;a href="https://agroshield-ai-beta.vercel.app" rel="noopener noreferrer"&gt;https://agroshield-ai-beta.vercel.app&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hindsight GitHub:&lt;/strong&gt; &lt;a href="https://github.com/vectorize-io/hindsight" rel="noopener noreferrer"&gt;https://github.com/vectorize-io/hindsight&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CascadeFlow GitHub:&lt;/strong&gt; &lt;a href="https://github.com/lemony-ai/cascadeflow" rel="noopener noreferrer"&gt;https://github.com/lemony-ai/cascadeflow&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>agriculture</category>
    </item>
    <item>
      <title>Hello</title>
      <dc:creator>Aman Tebriwal</dc:creator>
      <pubDate>Sat, 16 May 2026 13:49:04 +0000</pubDate>
      <link>https://dev.to/aman_tebriwal/hello-2blf</link>
      <guid>https://dev.to/aman_tebriwal/hello-2blf</guid>
      <description>&lt;p&gt;first post&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
