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

@@ -39,6 +39,7 @@ type (
handoffs []*Handoff
mcpServers []*MCPServer
maxTurns int
maxToolDepth int
client *llm.Client
logger *log.Logger
hooks []RunHooks
@@ -60,6 +61,7 @@ func New(name string, client *llm.Client, opts ...Option) *Agent {
name: name,
client: client,
maxTurns: DefaultMaxTurns,
maxToolDepth: DefaultMaxToolDepth,
toolUseBehavior: RunLLMAgain(),
resetToolChoice: true,
logger: log.NewLogger(log.WithOutput(io.Discard)),
@@ -196,6 +198,15 @@ func WithMaxTurns(n int) Option {
}
}
func WithMaxToolDepth(n int) Option {
return func(a *Agent) {
if n < 1 {
n = 1
}
a.maxToolDepth = n
}
}
func WithTemperature(t float64) Option {
return func(a *Agent) {
a.modelSettings.Temperature = &t