<?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: Belal Shafiq</title>
    <description>The latest articles on DEV Community by Belal Shafiq (@belalshafeq).</description>
    <link>https://dev.to/belalshafeq</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%2F4186769%2Fb3872f1a-9241-47b4-933d-11a079062486.jpg</url>
      <title>DEV Community: Belal Shafiq</title>
      <link>https://dev.to/belalshafeq</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/belalshafeq"/>
    <language>en</language>
    <item>
      <title>The Coder Agent and the Reviewer Agent Have Been Arguing for Three Days</title>
      <dc:creator>Belal Shafiq</dc:creator>
      <pubDate>Fri, 16 Oct 2026 08:11:53 +0000</pubDate>
      <link>https://dev.to/belalshafeq/the-coder-agent-and-the-reviewer-agent-have-been-arguing-for-three-days-51k8</link>
      <guid>https://dev.to/belalshafeq/the-coder-agent-and-the-reviewer-agent-have-been-arguing-for-three-days-51k8</guid>
      <description>&lt;p&gt;I set up a Coder agent and a Reviewer agent last week. Simple loop. Coder writes code, Reviewer gives feedback, Coder fixes it. I went to bed at midnight.&lt;/p&gt;

&lt;p&gt;They were still going when I woke up.&lt;/p&gt;

&lt;p&gt;Not crashed. Not erroring. Just talking. Coder kept fixing the same thing. Reviewer kept asking for the same change. Both doing exactly what I told them to.&lt;/p&gt;

&lt;p&gt;The only thing that stopped them was me killing the process.&lt;/p&gt;

&lt;p&gt;Here's what nobody tells you.&lt;/p&gt;

&lt;p&gt;Every framework has a step limit. LangGraph, CrewAI, all of them. Mine did too. It didn't help.&lt;/p&gt;

&lt;p&gt;Because from the step counter's point of view, message 47 is a brand new step. Message 46 was different. It ran. It produced output. The counter ticked up.&lt;/p&gt;

&lt;p&gt;It has no way of knowing that message 47 is byte-for-byte identical to message 45.&lt;/p&gt;

&lt;p&gt;Step limits catch agents that never stop. They don't catch agents that stop every single time, then immediately start again with the same message.&lt;/p&gt;

&lt;p&gt;The shift that fixed it&lt;br&gt;
A loop isn't repeated steps. It's repeated content.&lt;/p&gt;

&lt;p&gt;So I stopped counting steps and started counting fingerprints.&lt;/p&gt;

&lt;p&gt;Every message gets hashed. Store the hashes in a small window per session. Same hash showing up too many times? Loop. Short pattern cycling? A→B→A→B ping-pong.&lt;/p&gt;

&lt;p&gt;The whole thing is about fifteen lines of code.&lt;/p&gt;

&lt;p&gt;The bug that almost killed it&lt;br&gt;
One thing will silently break this if you're not careful.&lt;/p&gt;

&lt;p&gt;If you serialize a payload to a string before hashing it (and you have to), the order of the keys matters.&lt;/p&gt;

&lt;p&gt;{"a": 1, "b": 2} and {"b": 2, "a": 1} are the same dict. But json.dumps gives you two different strings. Two different hashes. As far as your detector knows, two different messages.&lt;/p&gt;

&lt;p&gt;Your loop detector fires zero times. Ever. And you never notice, because on the surface everything looks fine.&lt;/p&gt;

&lt;p&gt;The fix is sort_keys=True. That's it. But if you don't know to add it, you write the whole thing, ship it, and it does nothing.&lt;/p&gt;

&lt;p&gt;What I still can't catch&lt;br&gt;
Honest list:&lt;/p&gt;

&lt;p&gt;Different words, same meaning. Hashes don't see that. Needs embeddings.&lt;/p&gt;

&lt;p&gt;Genuinely new message every round. That's a step limit problem, not a loop problem.&lt;/p&gt;

&lt;p&gt;One malformed message crashing the next agent. Schema problem.&lt;/p&gt;

&lt;p&gt;The fingerprinting catches one specific thing — two agents saying the same thing to each other until someone notices. That's the one that costs the most money.&lt;/p&gt;

&lt;p&gt;Takeaway&lt;br&gt;
If you're running agents in production without payload fingerprinting, you don't have loop detection. You have a step limit, or you have a bill.&lt;/p&gt;

&lt;p&gt;Hash the payload. Watch for repeats. Watch for cycles. Trip early.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>agents</category>
      <category>python</category>
    </item>
  </channel>
</rss>
