mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-13 09:57:29 +08:00
agent long-run phase3: remove fixed tool-iteration cap by default, keep configurable ceiling
This commit is contained in:
@@ -544,15 +544,15 @@ func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage)
|
|||||||
if maxAllowed < 1 {
|
if maxAllowed < 1 {
|
||||||
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 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
|
hardCap = n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if hardCap < maxAllowed {
|
|
||||||
hardCap = maxAllowed
|
|
||||||
}
|
|
||||||
for iteration < maxAllowed {
|
for iteration < maxAllowed {
|
||||||
iteration++
|
iteration++
|
||||||
|
|
||||||
@@ -680,8 +680,15 @@ func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage)
|
|||||||
al.sessions.AddMessageFull(msg.SessionKey, assistantMsg)
|
al.sessions.AddMessageFull(msg.SessionKey, assistantMsg)
|
||||||
|
|
||||||
hasToolActivity = true
|
hasToolActivity = true
|
||||||
if maxAllowed < hardCap {
|
if hardCap > 0 {
|
||||||
maxAllowed = hardCap
|
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 {
|
for _, tc := range response.ToolCalls {
|
||||||
// Log tool call with arguments preview
|
// Log tool call with arguments preview
|
||||||
|
|||||||
Reference in New Issue
Block a user