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:
@@ -136,6 +136,13 @@ var reasons = map[string]bool{"threshold": true, "milestone": true, "thrash": tr
|
||||
|
||||
const maxAuthoredLine = 200
|
||||
|
||||
// Action is not one authored line. parseHandoffAnswer joins the agent's NEXT
|
||||
// and WHY answers with " — ", and the prompt asks for a sentence each without
|
||||
// naming any budget. Two ordinary sentences cleared 200 characters and every
|
||||
// rotation on workpc failed at "prose smuggled into list" (F31). Budget the
|
||||
// joined field for the two lines it is actually made of.
|
||||
const maxAuthoredAction = 2*maxAuthoredLine + len(" — ")
|
||||
|
||||
var circularAction = regexp.MustCompile(`(?i)handoff|report\.md|^continue the task`)
|
||||
var circularCommand = regexp.MustCompile(`(?i)\.orchestra-handoff|handoff-report|report\.md`)
|
||||
|
||||
@@ -149,7 +156,7 @@ func (h Handoff) Validate() error {
|
||||
if circularAction.MatchString(h.Action) {
|
||||
return errors.New("invalid handoff action: must name concrete next work, not a handoff")
|
||||
}
|
||||
if err := validateAuthoredLine(h.Action); err != nil {
|
||||
if err := validateAuthored(h.Action, maxAuthoredAction); err != nil {
|
||||
return err
|
||||
}
|
||||
if circularCommand.MatchString(h.Command) {
|
||||
@@ -180,12 +187,22 @@ func (h Handoff) Validate() error {
|
||||
}
|
||||
|
||||
func validateAuthoredLine(s string) error {
|
||||
return validateAuthored(s, maxAuthoredLine)
|
||||
}
|
||||
|
||||
// The two rejections used to share one message, which named the cause the
|
||||
// agent had not hit. An answer over budget was reported as smuggled prose, so
|
||||
// the agent could not tell what to shorten and retried the same text.
|
||||
func validateAuthored(s string, limit int) error {
|
||||
if strings.TrimSpace(s) == "" {
|
||||
return errors.New("invalid handoff authored field: empty item")
|
||||
}
|
||||
if strings.Contains(s, "\n#") || len(s) > maxAuthoredLine {
|
||||
if strings.Contains(s, "\n#") {
|
||||
return errors.New("invalid handoff authored field: prose smuggled into list")
|
||||
}
|
||||
if len(s) > limit {
|
||||
return fmt.Errorf("invalid handoff authored field: %d characters, limit %d", len(s), limit)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func Encode(h Handoff) ([]byte, error) {
|
||||
|
||||
Reference in New Issue
Block a user