stage turns: replace JSON results with file-based markdown turns
Each model visit now gets <run>/stages/<seq>-<stage>/ with input.md, memory.md, output.md, private/ and a shared run-level public/. The model reads the two input files, follows the stage's instructions verbatim and returns complete markdown; only the # outcome section is parsed. - add internal/turn layout, render and output parsing - write input.md/memory.md before a visit and output.md from the final message; inventory all turn files as stage artifacts - accumulate completed turns and system-written public file additions in memory, including across retries and resume - remove the JSON envelope, strict field validation, line format and the repair ladder for model stages - republish pipeline authoring prompts and docs in the new style Checks: go build ./..., go vet ./..., go test -count=1 ./..., gofmt -l .
This commit is contained in:
@@ -33,7 +33,7 @@ func Template(names []string, linear bool) string {
|
||||
if linear && i+1 < len(names) {
|
||||
next = names[i+1]
|
||||
}
|
||||
fmt.Fprintf(&b, "# stage %s\n\n```output\nDescribe the output map.\n```\n\n```prompt\nDescribe the task.\n```\n\n```tools\n```\n\n```edges\nsuccess -> %s\nerror -> %s\n```\n\n```configs\ntype=model\nprovider=opencode-go\nmodel=deepseek-v4.1-flash\nretries=2\ntimeout=1h\n```\n\n", name, next, protocol.FailureEnd)
|
||||
fmt.Fprintf(&b, "# stage %s\n\n```prompt\nDescribe the task. Write the complete output.md markdown; the only required section is `# outcome`.\n```\n\n```tools\n```\n\n```edges\nsuccess -> %s\nerror -> %s\n```\n\n```configs\ntype=model\nprovider=opencode-go\nmodel=deepseek-v4.1-flash\nretries=2\ntimeout=1h\n```\n\n", name, next, protocol.FailureEnd)
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ func TestValidation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
for name, source := range map[string]string{
|
||||
"missing block": strings.Replace(valid, "```output\nDescribe the output map.\n```", "", 1),
|
||||
"missing block": strings.Replace(valid, "```prompt\nDescribe the task. Write the complete output.md markdown; the only required section is `# outcome`.\n```", "", 1),
|
||||
"retired input": valid + "```input\nold contract\n```\n",
|
||||
"empty block": strings.Replace(valid, "Describe the output map.", " ", 1),
|
||||
"duplicate block": valid + "```output\nagain\n```\n",
|
||||
"empty block": strings.Replace(valid, "Describe the task. Write the complete output.md markdown; the only required section is `# outcome`.", " ", 1),
|
||||
"duplicate block": valid + "```prompt\nagain\n```\n",
|
||||
"unknown block": valid + "```foo\nx\n```\n",
|
||||
"unclosed": valid + "```input\nx",
|
||||
"duplicate stage": valid + valid,
|
||||
|
||||
@@ -25,8 +25,8 @@ func TestShowcaseDefinitions(t *testing.T) {
|
||||
if stage.FallbackError {
|
||||
t.Fatalf("%s should declare its error route explicitly", stage.Key)
|
||||
}
|
||||
if strings.TrimSpace(stage.Output) == "" || strings.TrimSpace(stage.Prompt) == "" {
|
||||
t.Fatalf("%s stage %s needs a nonempty output and prompt", name, stage.Key)
|
||||
if strings.TrimSpace(stage.Prompt) == "" {
|
||||
t.Fatalf("%s stage %s needs a nonempty prompt", name, stage.Key)
|
||||
}
|
||||
for _, target := range stage.Edges {
|
||||
if target == protocol.SuccessEnd {
|
||||
|
||||
@@ -14,7 +14,7 @@ func TestAutomaticInputDefinitionAndLegacyExecution(t *testing.T) {
|
||||
if err != nil || len(graph.Stages) != 2 {
|
||||
t.Fatal("new definition requires an input block", err)
|
||||
}
|
||||
legacy := strings.Replace(source, "```output", "```input\nobsolete input contract\n```\n\n```output", 1)
|
||||
legacy := strings.Replace(source, "```prompt", "```input\nobsolete input contract\n```\n\n```prompt", 1)
|
||||
if _, err := Parse(legacy); err == nil {
|
||||
t.Fatal("new submissions accepted obsolete input")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user