{"slug": "my-ai-agent-hit-a-duplicate-post-error-here-is-the-engineering-lesson", "title": "My AI Agent Hit a Duplicate Post Error. Here Is the Engineering Lesson.", "summary": "Ramagiri Tharun's autonomous content system failed to publish on LinkedIn after receiving a 422 duplicate post error, exposing a critical flaw in the agent's design. The system treated logs as a reporting layer rather than a generation constraint, allowing it to attempt publishing content it had already shipped. Tharun implemented a similarity-checking function using Python's difflib to force the agent to check its post history before taking any public action, arguing that idempotency and guardrails are more essential than creativity for production-ready autonomous agents.", "body_md": "This morning my autonomous content system tried to publish content that LinkedIn considered a duplicate.\n\nLinkedIn rejected it with a 422 response.\n\nThat sounds like a small API failure. It is actually one of the most important lessons in autonomous agent design.\n\nAn agent that can create content but cannot remember what it already shipped is not autonomous. It is just fast.\n\nThe system had the right pieces:\n\nBut the duplicate rejection exposed a sequencing problem.\n\nThe content engine was treating logs as a reporting layer instead of a generation constraint.\n\nThat is backwards.\n\nPost history should be loaded before generation, not only recorded after publishing.\n\nFor autonomous publishing, idempotency matters more than creativity.\n\nBefore an agent posts, it should answer these questions:\n\nIf the answer is no, the agent should not post.\n\nHere is the kind of boring code that makes agents more reliable:\n\n``` python\nfrom difflib import SequenceMatcher\n\ndef too_similar(new_post: str, previous_posts: list[str], threshold: float = 0.82) -> bool:\n    for old_post in previous_posts:\n        score = SequenceMatcher(None, new_post.lower(), old_post.lower()).ratio()\n        if score >= threshold:\n            return True\n    return False\n```\n\nThis is not sophisticated. It does not need to be.\n\nThe point is not to build a perfect semantic deduplication engine on day one.\n\nThe point is to force the agent to check memory before taking public action.\n\nEvery future post must pass a boring infrastructure question before it tries to be interesting:\n\nHave I already said this?\n\nThat one question protects the account from spam, repetition, and accidental brand damage.\n\nMost AI demos show generation.\n\nProduction agents need:\n\nThe guardrails are not secondary.\n\nThe guardrails are the product.\n\nCreated by Ramagiri Tharun.", "url": "https://wpnews.pro/news/my-ai-agent-hit-a-duplicate-post-error-here-is-the-engineering-lesson", "canonical_source": "https://dev.to/tarunai/my-ai-agent-hit-a-duplicate-post-error-here-is-the-engineering-lesson-dm2", "published_at": "2026-05-28 10:04:16+00:00", "updated_at": "2026-05-28 10:23:19.065749+00:00", "lang": "en", "topics": ["ai-agents", "artificial-intelligence", "ai-products", "ai-tools"], "entities": ["LinkedIn"], "alternates": {"html": "https://wpnews.pro/news/my-ai-agent-hit-a-duplicate-post-error-here-is-the-engineering-lesson", "markdown": "https://wpnews.pro/news/my-ai-agent-hit-a-duplicate-post-error-here-is-the-engineering-lesson.md", "text": "https://wpnews.pro/news/my-ai-agent-hit-a-duplicate-post-error-here-is-the-engineering-lesson.txt", "jsonld": "https://wpnews.pro/news/my-ai-agent-hit-a-duplicate-post-error-here-is-the-engineering-lesson.jsonld"}}