Propagate nested agent approval interruptions through tool pipeline

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-13 18:01:36 +01:00
parent 74f1d44119
commit a0ed50a908
3 changed files with 625 additions and 0 deletions

View File

@@ -42,12 +42,37 @@ type (
Messages []llm.Message
Usage llm.Usage
Turns int
outerState *outerLoopState
}
needsApprovalError struct {
allToolCalls []llm.ToolCall
pendingApprovals []llm.ToolCall
}
nestedInterruptionError struct {
inner *InterruptedError
toolCallID string
allToolCalls []llm.ToolCall
completedCalls []completedCall
}
outerLoopState struct {
agent *Agent
messages []llm.Message
usage llm.Usage
turns int
allToolCalls []llm.ToolCall
toolCallID string
completedCalls []completedCall
innerInterrupt *InterruptedError
}
completedCall struct {
toolCallID string
result ToolResult
}
)
func (e *MaxTurnsExceededError) Error() string {
@@ -69,3 +94,7 @@ func (e *InterruptedError) Error() string {
func (e *needsApprovalError) Error() string {
return fmt.Sprintf("%d tool call(s) require approval", len(e.pendingApprovals))
}
func (e *nestedInterruptionError) Error() string {
return fmt.Sprintf("nested agent interrupted: %s", e.inner.Error())
}