"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
return "", fmt.Errorf("open rebuilt memory: %w", err)
}
- client.LimitCalls(buildCallLimit)
+ client.LimitCalls(rebuildCallLimit)
+
run := BuildRun{
memory: memory,
client: client,
}
var work SubagentWorkFile
+
err = json.Unmarshal(data, &work)
if err != nil {
return fmt.Errorf("decode running subagents: %w", err)
}
slices.Sort(paths)
+
var entries []DatedMessage
+
for _, path := range paths {
var day uint32
err = journalScanFile(ctx, path, day, 0, false, func(line []byte, _ Position) error {
var message Message
+
err = json.Unmarshal(line, &message)
if err != nil {
return fmt.Errorf("decode message: %w", err)
}
var date time.Time
+
date, err = time.Parse(time.RFC3339Nano, entry.Date)
if err != nil {
return nil, fmt.Errorf("parse merge date: %w", err)
}
case entry.Type().IsRegular():
var data []byte
+
data, err = os.ReadFile(path)
if err != nil {
return fmt.Errorf("read agent file: %w", err)