<?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: long hei</title>
    <description>The latest articles on DEV Community by long hei (@heilong_pcyw).</description>
    <link>https://dev.to/heilong_pcyw</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%2F4243992%2F2c394404-3d43-4f46-a3ad-a1d49bd727b8.png</url>
      <title>DEV Community: long hei</title>
      <link>https://dev.to/heilong_pcyw</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/heilong_pcyw"/>
    <language>en</language>
    <item>
      <title>A small habit that made my AI agent features less flaky</title>
      <dc:creator>long hei</dc:creator>
      <pubDate>Mon, 16 Nov 2026 09:19:02 +0000</pubDate>
      <link>https://dev.to/heilong_pcyw/a-small-habit-that-made-my-ai-agent-features-less-flaky-l9c</link>
      <guid>https://dev.to/heilong_pcyw/a-small-habit-that-made-my-ai-agent-features-less-flaky-l9c</guid>
      <description>&lt;p&gt;I've been shipping a few small AI-agent features lately, and the thing that helped most wasn't a fancy framework — it was making every tool call idempotent with a stable operation id.&lt;/p&gt;

&lt;p&gt;Early on I hit the classic problem: a request times out, the agent retries, and suddenly the same side effect happens twice (two charges, two emails, two tickets). A timeout only tells you what the caller observed — not what the server actually committed.&lt;/p&gt;

&lt;p&gt;A few practical rules I now follow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Give every meaningful operation a stable id derived from the logical intent, not from the request. If the agent retries the same intent, it maps to the same id.&lt;/li&gt;
&lt;li&gt;Treat "unknown" as a real state. Don't assume failure just because you didn't get a response.&lt;/li&gt;
&lt;li&gt;Make the write path idempotent: the second call with the same id should return the first result instead of doing the work again.&lt;/li&gt;
&lt;li&gt;Surface that unknown state in the UI so a human isn't told "failed" when it might have succeeded.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;None of this is exotic distributed-systems theory — it's the same idempotency key idea the payment world has used for years. The twist with agents is that they retry &lt;em&gt;very&lt;/em&gt; eagerly, across multiple layers, so one lost response can cascade into many duplicates.&lt;/p&gt;

&lt;p&gt;Still learning here. Curious how others handle the "retried but maybe already succeeded" case in their agent tooling — do you push idempotency into the tool framework, or leave it to the model to remember?&lt;/p&gt;

</description>
      <category>aiprogramming</category>
    </item>
  </channel>
</rss>
