HandlesToolApprovals
trait HandlesToolApprovals
Methods
Get the unresolved tool calls in the latest assistant turn, plus the ids already answered.
Append a resume's tool results, merging into the pause turn's partial results so one assistant turn keeps one answering message.
Settle unresolved historical tool calls so the history remains replayable, optionally leaving the latest assistant turn for a resume to decide.
Find the index of the latest assistant message, or the message count when there is none.
Build pending approval requests for the given tool calls.
Details
at line 24
protected array
pendingToolCalls(array $messages)
Get the unresolved tool calls in the latest assistant turn, plus the ids already answered.
at line 57
protected array
appendApprovalResults(array $messages, array $toolResults)
Append a resume's tool results, merging into the pause turn's partial results so one assistant turn keeps one answering message.
at line 80
protected array
settleAbandonedToolCalls(array $messages, bool $exceptLatestAssistantTurn = false)
Settle unresolved historical tool calls so the history remains replayable, optionally leaving the latest assistant turn for a resume to decide.
at line 140
protected int
latestAssistantTurnIndex(array $messages)
Find the index of the latest assistant message, or the message count when there is none.
at line 158
protected Collection
pendingApprovalsFor(Collection $toolCalls, Collection $approvals)
Build pending approval requests for the given tool calls.