You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
chatd can initiate tool calls via dispatch hooks while another such process is already ongoing #30316
IIUC when the model emits tool calls for client-provided tools, chatd record that and moves the chat to requires_action. The client side observes this through the chat stream, runs the tools itself, and calls SubmitToolResults.
an outbound HTTP call to any admin-configured hooks (EventPostToolUse) outside any transaction, and
a CompleteRequiresAction transition under the chat's exclusive row lock that records the results and returns to running.
Currently two concurrent submissions (a client retry, two tabs) for the tool work can both pass the read check for requires_action, both call the hooks, and then the second fails at commit since we check there that the status is still requires_action, so external hook side effects fire for results that were never accepted.
To resolve this, rather than holding a lock across the hook call, we could add an intermediate status processing_results.
SubmitToolResults first takes the row lock, does some validation and then flips requires_action -> processing_results and commits; then calls the hooks; then commits the results with processing_results -> running.
A second submission finds processing_results and is rejected before any hook fires. If the hook call fails, the request releases the claim back to requires_action so the client can resubmit. Additionally we could handle the server dying mid-claim; a claimed-at timestamp plus a timeout (handled by the existing requires_action_timeout task, which would also need to own processing_results chats) either releases the claim or cancels the action, as the existing requires_action_deadline_at does today; it must not re-fire the hooks.
Activity
linear-code commentedon Oct 3, 2026
ENG-3446