Deliver classic (non-durable) tool approvals across server instances…#3403
Merged
Conversation
* fix: deliver classic tool approvals across server instances Classic (non-durable) agents kept a pending tool approval in the memory of the single instance running the agent. In multi-instance production the approval response often hit a different instance with no record of it, so it was dropped and the agent timed out after 10 minutes. When an approval lands on an instance that isn't holding it, persist the decision to a new tool_approval_decisions table; the instance running the agent polls and consumes it. Same-instance approvals still resolve in memory. Includes the table, migration, cleanup, and a cross-instance test. * fix: harden cross-instance tool approval per review feedback - Guard the approval poll with an in-flight flag so DB latency can't stack one query per second per approval and exhaust the connection pool. - Use Promise.allSettled for the approval batch so one failed DB write reports per-toolCallId instead of 500-ing the whole batch. - Add a settled flag set synchronously on resolve, checked before the destructive DB consume, and re-record the decision if it was consumed after the approval already settled (closes the timeout/poll TOCTOU). - Pass an empty conversationId instead of 'unknown' so the poll guard disables rather than querying an id that never matches. - Convert waitForApproval to a single options argument (7 positional params). - Log full error objects in the poll catch to preserve stack traces. - Run the two cron cleanups independently so one failure doesn't skip the other. - Add a cross-instance denial test covering reason propagation. * fix: distinct log for approval re-record failure The re-record after a post-settle consume shared the poll's outer catch, so a re-record (write) failure was logged as a poll (read) failure. Wrap it in its own try/catch with a distinct error log. * chore: add conversationId to cross-instance delivery log Makes the delivery log self-contained for triage correlation by conversationId. GitOrigin-RevId: 1f0279996b4055a67695b1fbc5e875f8e1ed6a9d
Contributor
There was a problem hiding this comment.
Automated approval from agents-private public-mirror-sync (run: https://github.com/inkeep/agents-private/actions/runs/27981387577). Source of truth is the monorepo; direct edits on inkeep/agents are overwritten on next sync.
🦋 Changeset detectedLatest commit: bb8e61b The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Deliver classic (non-durable) tool approvals across server instances via a shared decision store, fixing approvals lost when the response lands on a different instance than the one running the agent