Merge: short essential memory per stage; full history on demand

This commit is contained in:
2026-11-04 13:01:16 +00:00
27 changed files with 912 additions and 128 deletions
+5 -5
View File
@@ -972,7 +972,7 @@ type runState struct {
artifactDirs []string
// prompt is the original run prompt; lastOutput is the previous visit's
// markdown and turns is every completed turn in order. Together they render
// the next model visit's input.md and memory.md.
// the next model visit's input.md, memory.md and history.md.
prompt string
lastOutput string
turns []turn.MemoryEntry
@@ -1018,7 +1018,7 @@ func rebuildRunState(detail *protocol.RunDetail, decided protocol.RunStep) *runS
state.memory[step.Stage] = memoryValue{output: values, sequence: step.Sequence}
}
state.completed++
state.turns = append(state.turns, turn.MemoryEntry{Stage: step.Stage, Visit: state.visits[step.Stage], Output: turnOutput(step.Output), PublicFiles: added})
state.turns = append(state.turns, turn.MemoryEntry{Stage: step.Stage, Visit: state.visits[step.Stage], Outcome: step.Outcome, Output: turnOutput(step.Output), PublicFiles: added})
state.lastOutput = turnOutput(step.Output)
}
// Seed the UI-surface accumulator from the persisted evidence so a
@@ -1062,7 +1062,7 @@ func rebuildRetryState(detail *protocol.RunDetail, failed protocol.RunStep, hand
state.memory[step.Stage] = memoryValue{output: values, sequence: step.Sequence}
}
state.completed++
state.turns = append(state.turns, turn.MemoryEntry{Stage: step.Stage, Visit: state.visits[step.Stage], Output: turnOutput(step.Output), PublicFiles: added})
state.turns = append(state.turns, turn.MemoryEntry{Stage: step.Stage, Visit: state.visits[step.Stage], Outcome: step.Outcome, Output: turnOutput(step.Output), PublicFiles: added})
state.lastOutput = turnOutput(step.Output)
}
state.recordPersistedStep(step)
@@ -1735,8 +1735,8 @@ func (r *runner) runLoop(ctx context.Context, id int64, graph protocol.Graph, na
return
}
useAgent := stage.EffectiveType(def.Type) == stage.ModelType && (len(tools) > 0 || !explicitTools)
// Every model visit gets a file-based turn: input.md and memory.md are
// written before execution, output.md after it. Creation is part of the
// Every model visit gets a file-based turn: input.md, memory.md and
// history.md are written before execution, output.md after it. Creation is part of the
// protocol, so an unusable turn directory fails the run instead of
// silently degrading to the retired JSON envelope.
artifactsDir := ""