Skip to content

fix: an approval runs its stored connection action only once - #137

Open
charan-rathore wants to merge 1 commit into
CopilotKit:mainfrom
charan-rathore:fix/approval-single-use
Open

charan-rathore wants to merge 1 commit into
CopilotKit:mainfrom
charan-rathore:fix/approval-single-use

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

What this changes

An approval-gated connection action could be executed more than once under the same approval.

claimAction keys execution claims on (threadId, toolCallId), which stops a double click or a retried request from running twice. But nothing bound the approval itself to one run: after an approved action completed, POSTing the same approvalId with a fresh toolCallId passed every check (approval found, conversation matches, inside the one-hour TTL, tool still bound) and ran the stored request again. While the first run was still in flight, a second toolCallId could even start a concurrent execution of the same approved call.

The POST path now looks up the action an approval was already claimed for and refuses a different toolCallId with a 409. Same-toolCallId retries still recover their saved result, and this composes with the interrupted-claim reclaim in #135, which reclaims under the same toolCallId.

Tests

New regression test in tests/connections.test.ts: approve once (runs, receipt done), then POST the same approvalId under a new toolCallId and expect a 409 with the send mock called exactly once. The test failed before the change (the stored request ran a second time) and passes after. Full suite: 303 passed across 48 files, tsc --noEmit and eslint clean.

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@charan-rathore

Copy link
Copy Markdown
Contributor Author

This is green on CI and conflict-free on my end. Is there anything you'd like changed before it can land? Happy to adjust.

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.

1 participant