Budget the handoff action for the two lines it is made of

parseHandoffAnswer joins the agent's NEXT and WHY answers with " — ", and the
prompt asks for a sentence each without naming any budget. Validate then held
that join to one authored line's 200 characters. Two ordinary sentences do not
fit, so every rotation failed.

The failure was invisible twice over. The message said "prose smuggled into
list", which named a branch the answer cannot reach: parseHandoffAnswer splits
on newlines and trims, so no authored field ever contains "\n#". The only
reachable cause was length, and the agent was never told what to shorten.

Seen live on two tasks, and it left the release transaction stuck at "prepared"
that pinned workpc-claude's only session slot (F30).

Give Action the budget of both lines, name the length in the error, and put the
limit in the prompt the agent actually reads.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011xsXyr5J1RACo71YeKG3Pu
This commit is contained in:
2026-08-28 01:00:04 +04:00
parent c8db659b45
commit 65230020b9
3 changed files with 62 additions and 5 deletions
+40
View File
@@ -165,3 +165,43 @@ func TestVerifyTaskFileRejectsMutation(t *testing.T) {
t.Fatal("expected immutable task check to fail")
}
}
// TestActionCarriesTheBudgetOfBothLinesItIsMadeOf guards F31. Action is not one
// authored line: parseHandoffAnswer joins the agent's NEXT and WHY answers, and
// the prompt asks for a sentence each. Holding the join to a single line's
// budget rejected two ordinary sentences, which failed every rotation on
// workpc at "prose smuggled into list" and pinned the worker slot behind it.
func TestActionCarriesTheBudgetOfBothLinesItIsMadeOf(t *testing.T) {
next := strings.Repeat("a", maxAuthoredLine)
why := strings.Repeat("b", maxAuthoredLine)
h := Handoff{
Meta: Meta{ID: "h1", Reason: "threshold"},
Anchor: Anchor{GitSHA: strings.Repeat("0", 40), Branch: "main"},
Action: next + " — " + why,
}
if err := h.Validate(); err != nil {
t.Fatalf("two full-length answers rejected: %v", err)
}
h.Action = next + " — " + why + "c"
if err := h.Validate(); err == nil {
t.Fatal("an action past both budgets was accepted")
}
}
// An over-budget field must not be reported as smuggled prose. The agent
// cannot shorten what it is not told is too long, so it retried the same text.
func TestOverBudgetFieldNamesLengthNotProse(t *testing.T) {
h := Handoff{
Meta: Meta{ID: "h1", Reason: "threshold"},
Anchor: Anchor{GitSHA: strings.Repeat("0", 40), Branch: "main"},
Action: "do the next thing",
Remaining: []string{strings.Repeat("x", maxAuthoredLine+1)},
}
err := h.Validate()
if err == nil {
t.Fatal("over-budget item accepted")
}
if !strings.Contains(err.Error(), "limit") || strings.Contains(err.Error(), "smuggled") {
t.Fatalf("error names the wrong cause: %v", err)
}
}