From ed94896372686ce3a032e8f3d76144eb83e2d8cc Mon Sep 17 00:00:00 2001 From: Claudomator Agent Date: Wed, 11 Mar 2026 11:01:21 +0000 Subject: feat: require agents to write a final summary before exiting Add a mandatory '## Final Summary' section to planningPreamble instructing agents to output a 2-5 sentence summary paragraph (headed by '## Summary') as their last output before exiting. Adds three tests to verify the section and its required content are present in the preamble. Co-Authored-By: Claude Sonnet 4.6 --- internal/executor/preamble.go | 11 +++++++++++ internal/executor/preamble_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 internal/executor/preamble_test.go (limited to 'internal') diff --git a/internal/executor/preamble.go b/internal/executor/preamble.go index e50c16f..1993361 100644 --- a/internal/executor/preamble.go +++ b/internal/executor/preamble.go @@ -46,6 +46,17 @@ The sandbox is rejected if there are any uncommitted modifications. --- +## Final Summary (mandatory) + +Before exiting, write a final summary paragraph (2-5 sentences) as your last output. Start it with "## Summary" on its own line. Describe: +- What was accomplished +- Key decisions made +- Any issues or follow-ups needed + +This summary will be extracted and displayed in the task UI. + +--- + ` func withPlanningPreamble(instructions string) string { diff --git a/internal/executor/preamble_test.go b/internal/executor/preamble_test.go new file mode 100644 index 0000000..448ad3a --- /dev/null +++ b/internal/executor/preamble_test.go @@ -0,0 +1,26 @@ +package executor + +import ( + "strings" + "testing" +) + +func TestPlanningPreamble_ContainsFinalSummarySection(t *testing.T) { + if !strings.Contains(planningPreamble, "## Final Summary (mandatory)") { + t.Error("planningPreamble missing '## Final Summary (mandatory)' heading") + } +} + +func TestPlanningPreamble_SummaryRequiresMarkdownHeader(t *testing.T) { + if !strings.Contains(planningPreamble, `Start it with "## Summary"`) { + t.Error("planningPreamble does not instruct agent to start summary with '## Summary'") + } +} + +func TestPlanningPreamble_SummaryDescribesRequiredContent(t *testing.T) { + for _, phrase := range []string{"What was accomplished", "Key decisions made", "Any issues or follow-ups"} { + if !strings.Contains(planningPreamble, phrase) { + t.Errorf("planningPreamble missing required summary content description: %q", phrase) + } + } +} -- cgit v1.2.3