Skip to content

fix: recover interrupted approval-gated MCP actions - #155

Open
Twil3akine wants to merge 1 commit into
CopilotKit:mainfrom
Twil3akine:fix/issue-134-interrupted-connection-actions
Open

Twil3akine wants to merge 1 commit into
CopilotKit:mainfrom
Twil3akine:fix/issue-134-interrupted-connection-actions

Conversation

@Twil3akine

Copy link
Copy Markdown
Contributor

Fixes #134.

Summary

Recover approval-gated MCP actions that were claimed but interrupted before their result was saved.

A stale result-less claim is now surfaced as interrupted and can be retried by the same approval and tool call. Fresh claims remain protected against duplicate execution.

Cause

mcp_actions persisted a running row as soon as an approved action was claimed.

If the server stopped after that claim but before finishAction saved the result, the row remained running indefinitely. Every later attempt therefore returned 409 This action is already running., while the UI continued to hide the approval controls.

Fix

  • Track the most recent claim time separately from the original action creation time.
  • Treat a result-less claim older than five minutes as interrupted.
  • Allow only the same approval and tool call ID to reclaim an interrupted action.
  • Use a conditional database update so concurrent retries cannot both reclaim the same action.
  • Preserve the existing guard for fresh running claims.
  • Preserve saved results and their original approval ownership.
  • Show interrupted actions explicitly in the UI with a Retry & run action.
  • Warn that retrying can repeat an external side effect if the service completed the original action before the server interruption.

The five-minute recovery threshold leaves a margin above the existing 60-second MCP call timeout before a claim can be retried.

Validation

  • NODE_USE_ENV_PROXY=0 npm test: 54 files, 346 tests passed.
  • npm run build: passed.
  • npm run typecheck: passed.
  • npm run lint: passed.
  • npm run check-format: passed.

Regression coverage includes stale-claim recovery, approval ownership, concurrent retry protection, fresh-claim rejection, saved-result handling, and the interrupted-action retry UI.

The environment had NODE_USE_ENV_PROXY=1, which routed existing loopback HTTP tests through a proxy, so the full suite was run with environment proxy routing disabled.

Prepared with AI assistance using gwitg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Approval-gated action interrupted before its result is saved can never be retried

1 participant