mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-14 04:16:06 +00:00
fix(agent): prevent "..." fallback when iteration budget exhausted
Add early detection and graceful degradation when the model exhausts its iteration budget without producing a text response: - Inject 75% budget nudge telling model to start summarizing - Strip all tool schemas on final iteration to force text-only response - Adaptive web_fetch maxChars (60K→20K→10K) via iteration progress context - Bump DefaultMaxIterations 20→30 for web-research workloads
This commit is contained in:
1 parent
84650c5c14
commit
dba3f4e4e6
4 files changed
+59
-3
No files matched your search
@@ -192,6 +192,17 @@ func (t *WebFetchTool) Execute(ctx context.Context, args map[string]any) *Result
|
||||
maxChars = int(mc)
|
||||
}
|
||||
|
||||
// Adaptive maxChars: reduce as iterations progress to prevent context bloat.
|
||||
if prog, ok := IterationProgressFromCtx(ctx); ok && prog.Max > 0 {
|
||||
ratio := float64(prog.Current) / float64(prog.Max)
|
||||
switch {
|
||||
case ratio >= 0.75:
|
||||
maxChars = min(maxChars, 10000)
|
||||
case ratio >= 0.50:
|
||||
maxChars = min(maxChars, 20000)
|
||||
}
|
||||
}
|
||||
|
||||
// Check cache (scoped per channel to prevent cross-channel cache poisoning)
|
||||
channel := ToolChannelFromCtx(ctx)
|
||||
cacheKey := fmt.Sprintf("fetch:%s:%s:%s:%d", channel, rawURL, extractMode, maxChars)
|
||||
|
||||
Reference in new issue
Block a user