X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/522d7fd117285e4e4ce3ea5ec9b5a1722521b681..5a93b6124068c2a8748fc0bfbb2a2d151815bcf0:/rebuild.go?ds=sidebyside diff --git a/rebuild.go b/rebuild.go index 52c0861..11c6bfc 100644 --- a/rebuild.go +++ b/rebuild.go @@ -7,7 +7,7 @@ import ( "fmt" "io" "io/fs" - "log" + "log/slog" "os" "path/filepath" "slices" @@ -15,6 +15,11 @@ import ( "time" ) +// rebuildCallLimit is the most model calls of a rebuild. A rebuild summarizes +// the whole merged log, which can need more calls than a probe sample, and the +// quota stop of the build run still guards the account. +const rebuildCallLimit = 1500 + // rebuild merges added messages with the log of agent, in date order, and // builds a new memory beside it. The caller holds the token lock. The model // uses the original agent prompt and cache key. A failed or stopped build @@ -50,12 +55,12 @@ func rebuild(ctx context.Context, agent *Agent, added []DatedMessage, client *Mo } }() - memory, err := openMemory(ctx, root, time.Now, summarizer, log.New(io.Discard, "", 0)) + memory, err := openMemory(ctx, root, time.Now, summarizer, slog.New(slog.DiscardHandler)) if err != nil { return "", fmt.Errorf("open rebuilt memory: %w", err) } - client.LimitCalls(buildCallLimit) + client.LimitCalls(rebuildCallLimit) run := BuildRun{ memory: memory,