Model stages: outcome-first output shape and one in-session outcome repair
The prompt now says output.md must start with # outcome and the outcome word alone on the next line, then # handoff, then detail. Runs 241/243 followed the old "start with # handoff" wording and dropped the outcome. When a completed turn lacks a valid outcome, the OpenCode/agent and Pi clients send one short follow-up in the same session asking only for the outcome line. An outcome-only reply goes at the top of the original report; a still-invalid reply fails with the same validation error as before. The follow-up's tokens accrue to the session usage. No outcome is inferred. Missing tools/evidence now name blocked when declared, else error. The parser tolerates a trailing period on the outcome word.
This commit is contained in:
@@ -143,6 +143,38 @@ func TestParseOutputReturnsCanonicalOutcome(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseOutputToleratesTrailingPeriod(t *testing.T) {
|
||||
for _, input := range []string{"# outcome\nsuccess.\n", "# outcome\n Success . \n"} {
|
||||
if outcome, _, err := ParseOutput(input, []string{"success"}); err != nil || outcome != "success" {
|
||||
t.Fatalf("%q: %q %v", input, outcome, err)
|
||||
}
|
||||
}
|
||||
if _, _, err := ParseOutput("# outcome\nsuccess, mostly\n", []string{"success"}); !errors.Is(err, ErrOutcomeNotAllowed) {
|
||||
t.Fatalf("prose accepted as outcome: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithOutcome(t *testing.T) {
|
||||
tests := []struct{ name, input, want string }{
|
||||
{"no outcome", "# handoff\n\nx\n", "# outcome\nsuccess\n\n# handoff\n\nx\n"},
|
||||
{"invalid value replaced", "# handoff\n\nx\n\n# outcome\nmaybe\n\n# log\n", "# outcome\nsuccess\n\n# handoff\n\nx\n\n\n# log\n"},
|
||||
{"duplicates removed", "## outcome\nerror\n# body\n## outcome\nsuccess\n", "# outcome\nsuccess\n\n# body\n"},
|
||||
{"empty heading keeps next heading", "# outcome\n\n# handoff\nx\n", "# outcome\nsuccess\n\n\n# handoff\nx\n"},
|
||||
{"fenced kept", "```\n# outcome\nerror\n```\n", "# outcome\nsuccess\n\n```\n# outcome\nerror\n```\n"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := WithOutcome(tt.input, "success")
|
||||
if got != tt.want {
|
||||
t.Fatalf("WithOutcome = %q, want %q", got, tt.want)
|
||||
}
|
||||
if outcome, _, err := ParseOutput(got, []string{"success", "error"}); err != nil || outcome != "success" {
|
||||
t.Fatalf("result does not parse: %q %v", outcome, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseOutputRequiresWhitespaceAfterHeadingMarker(t *testing.T) {
|
||||
if _, _, err := ParseOutput("#outcome\nsuccess\n", []string{"success"}); !errors.Is(err, ErrMissingOutcome) {
|
||||
t.Fatalf("error = %v, want missing outcome", err)
|
||||
|
||||
Reference in New Issue
Block a user