fix(turns): keep the run task in every stage's input

Later visits' input.md held only the previous stage's output, so the
operator's task reached only the first stage; when a Prepare stage
summarised (paths, HEAD), Code never saw the task or its acceptance
checklist and either blocked (run #202) or did part of it (#195, #197,
#198). Later inputs now carry the run prompt under '# Run task' (headings
demoted) before '# Previous turn output'.
This commit is contained in:
2026-10-31 02:52:16 +00:00
parent ea0f22dfc7
commit 13c4035175
8 changed files with 35 additions and 23 deletions
+2 -2
View File
@@ -89,8 +89,8 @@ func TestTurnsAccumulateMemoryAndListFilesAsArtifacts(t *testing.T) {
if detail.Status != "succeeded" || len(detail.Steps) != 2 {
t.Fatalf("run = %q steps=%d: %+v", detail.Status, len(detail.Steps), detail.RunSummary)
}
if secondInput != "# Previous turn output\n\nfirst body\n" {
t.Fatalf("second input.md = %q, want the previous turn's output", secondInput)
if secondInput != "# Run task\n\noriginal task\n\n# Previous turn output\n\nfirst body\n" {
t.Fatalf("second input.md = %q, want the run task and the previous turn's output", secondInput)
}
for _, want := range []string{"## first · visit 1", "first body", "Files added to public/:\n- public/shared.txt"} {
if !strings.Contains(secondMemory, want) {
+4 -4
View File
@@ -89,16 +89,16 @@ func turnInputWithRetry(base string, retryInput stage.Values) string {
return base + "\n# Retry input\n\nThis retry was given this complete input:\n\n```json\n" + string(encoded) + "\n```\n"
}
// turnInput is the run prompt on the first visit and the previous visit's
// output afterwards.
// turnInput is the run prompt on the first visit; later visits carry the run
// prompt and the previous visit's output.
func (s *runState) turnInput() string {
if len(s.turns) == 0 && strings.TrimSpace(s.lastOutput) == "" {
return s.prompt
}
if strings.TrimSpace(s.lastOutput) == "" {
return "# Previous turn output\n\n_(no output)_\n"
return turn.RenderInput(s.prompt, "_(no output)_\n")
}
return turn.RenderInput("", s.lastOutput)
return turn.RenderInput(s.prompt, s.lastOutput)
}
// turnOutput renders a completed step for later memory. Model stages store their