Prevent infinite recursion when agents delegate to each other as tools

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-13 18:15:45 +01:00
parent a0ed50a908
commit a710a7472d
4 changed files with 146 additions and 0 deletions

View File

@@ -25,6 +25,10 @@ type (
MaxTurns int
}
MaxToolDepthExceededError struct {
MaxDepth int
}
InputGuardrailTrippedError struct {
Guardrail string
Message string
@@ -79,6 +83,10 @@ func (e *MaxTurnsExceededError) Error() string {
return fmt.Sprintf("agent exceeded maximum number of turns (%d)", e.MaxTurns)
}
func (e *MaxToolDepthExceededError) Error() string {
return fmt.Sprintf("agent-tool delegation exceeded maximum depth (%d)", e.MaxDepth)
}
func (e *InputGuardrailTrippedError) Error() string {
return fmt.Sprintf("input guardrail %q tripped: %s", e.Guardrail, e.Message)
}