agent long-run phase3: remove fixed tool-iteration cap by default, keep configurable ceiling

This commit is contained in:
DBT
2026-02-28 02:02:34 +00:00
parent c71c2f0138
commit 198bc8579f

View File

@@ -544,15 +544,15 @@ func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage)
if maxAllowed < 1 {
maxAllowed = 1
}
hardCap := 24
// CLAWGO_MAX_TOOL_ITERATIONS:
// 0 or unset => no fixed cap, keep extending while tool chain progresses
// >0 => explicit ceiling
hardCap := 0
if v := os.Getenv("CLAWGO_MAX_TOOL_ITERATIONS"); v != "" {
if n, err := strconv.Atoi(v); err == nil && n > 0 {
if n, err := strconv.Atoi(v); err == nil && n >= 0 {
hardCap = n
}
}
if hardCap < maxAllowed {
hardCap = maxAllowed
}
for iteration < maxAllowed {
iteration++
@@ -680,8 +680,15 @@ func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage)
al.sessions.AddMessageFull(msg.SessionKey, assistantMsg)
hasToolActivity = true
if maxAllowed < hardCap {
maxAllowed = hardCap
if hardCap > 0 {
if maxAllowed < hardCap {
maxAllowed = hardCap
}
} else {
// No fixed cap: extend rolling window as long as tools keep chaining.
if maxAllowed < iteration+al.maxIterations {
maxAllowed = iteration + al.maxIterations
}
}
for _, tc := range response.ToolCalls {
// Log tool call with arguments preview