mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-14 16:17:25 +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
@@ -412,6 +412,26 @@ func RunMediaNamesFromCtx(ctx context.Context) map[string]string {
|
||||
return v
|
||||
}
|
||||
|
||||
// --- Iteration progress (loop → tools) ---
|
||||
|
||||
const ctxIterProgress toolContextKey = "tool_iter_progress"
|
||||
|
||||
// IterationProgress carries the agent loop's current iteration state
|
||||
// so tools can adapt behaviour (e.g. reduce output size) as the budget shrinks.
|
||||
type IterationProgress struct {
|
||||
Current int
|
||||
Max int
|
||||
}
|
||||
|
||||
func WithIterationProgress(ctx context.Context, p IterationProgress) context.Context {
|
||||
return context.WithValue(ctx, ctxIterProgress, p)
|
||||
}
|
||||
|
||||
func IterationProgressFromCtx(ctx context.Context) (IterationProgress, bool) {
|
||||
v, ok := ctx.Value(ctxIterProgress).(IterationProgress)
|
||||
return v, ok
|
||||
}
|
||||
|
||||
// --- Per-agent sandbox config override ---
|
||||
|
||||
const ctxSandboxCfg toolContextKey = "tool_sandbox_config"
|
||||
|
||||
Reference in new issue
Block a user