return r.save()
}
+// Snapshot locks the run state, memory, and subagent logs while snapshot reads
+// the agent files. The lock order agrees with Stop, which logs under the run
+// lock.
+func (r *SubagentRuns) Snapshot(ctx context.Context, snapshot func() error) error {
+ r.mutex.Lock()
+ defer r.mutex.Unlock()
+
+ return r.memory.Snapshot(ctx, func() error {
+ return r.subagents.Snapshot(ctx, snapshot)
+ })
+}
+
// Close ends every run and waits for them. No subagent starts after Close.
func (r *SubagentRuns) Close() {
r.mutex.Lock()
input = append(input, modelUserMessage(r.state()), modelUserMessage(log))
chain := &Chain{
client: r.client,
+ images: r.agent.Images(),
tools: &Toolbox{
log: run.subagent,
chat: r.memory,
subagents: r.subagents,
workdir: run.subagent.WorkDir(),
+ images: r.agent.Images(),
},
request: ModelRequest{
Model: r.agent.config.Model,