{
  "id": 21826424,
  "title": "What happens when a 40-second LLM call outlives Kafka's 30-second lock",
  "url": "https://urgent.news/2026/11/25/what-happens-when-a-40-second-llm-call-outlives-kafkas-30-second-lock",
  "topic": "ai",
  "section": "AI",
  "published": "2026-11-25T17:32:59.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/mostavassoli/what-happens-when-a-40-second-llm-call-outlives-kafkas-30-second-lock-2ain"
  },
  "original_language": "en",
  "account": "When an artificially intelligent agent handles a Kafka message in a share group, the agent may outlive the 30-second lock that protects the message from being consumed by another consumer. The default lock duration is 30 seconds, but when an AI agent starts working on a message, the lock can last up to 40 seconds. This longer lock duration can lead to the message being delivered again to the agent after the lock expires, potentially causing the agent to perform the same action multiple times. This can result in duplicate processing of the message and multiple side effects, which can be problematic for the system.\n\nTo address this issue, the article suggests making side effects in the application code idempotent, which means that running the same action multiple times does not produce different results. This can be achieved by using an idempotency key that ensures the same result is produced regardless of how many times the action is executed. However, this approach does not address the underlying issue of the longer lock duration.\n\nAnother solution is to increase the lock duration, but this requires knowing the worst-case scenario for the agent's processing time. If the lock duration is set too high, it may not fit within the broker's cap, which is 60 seconds by default. This means that if the agent's processing time consistently exceeds the lock duration, the message will be delivered again, and the agent will have to handle it multiple times.\n\nThe article also highlights that some frameworks have built-in renewal mechanisms for the lock, but these may not always work as expected. For example, Spring for Apache Kafka has a setting called setShareAutoRenewLocks() that can be enabled, but it is not effective in every scenario. Quarkus' Reactive Messaging framework also has an automatic renewal feature, but in the tests conducted, it failed to keep the lock when the processing time was slower than the lock duration. Therefore, it is essential to test renewal mechanisms thoroughly before relying on them.\n\nOverall, the article emphasizes the need for careful consideration when using AI agents with Kafka share groups. The longer lock duration can lead to unexpected behavior, and developers must take steps to ensure that their agents are safe to run multiple times. Making side effects idempotent, sizing the lock appropriately, and testing renewal mechanisms are all critical steps in ensuring that AI agents can safely consume and process messages in Kafka share groups.",
  "summary": "Kafka 4.2 made share groups production-ready: queue-style consumption where several consumers take records from the same partitions. Each record is locked to one consumer while it works on it. The default lock is 30 seconds. Now put an AI agent behind that consumer. One event means a model call, maybe a tool call or two, maybe a retry. Forty seconds is not unusual. So what happens when the agent…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}