diff --git a/internal/domain/workflow/agent.go b/internal/domain/workflow/agent.go index c5c26f752..6c9c8eb19 100644 --- a/internal/domain/workflow/agent.go +++ b/internal/domain/workflow/agent.go @@ -218,6 +218,10 @@ func (a AgentStage) deliverResult(tc *TaskContext, res agentrun.Result) error { if detail == "" { detail = res.Summary } + // A stage that stops short (step budget) has only its notes to show. + for _, note := range res.AppendedNotes { + detail += "\n- " + note + } return fmt.Errorf("agent %s (%s): %s", res.Status, res.StopReason, clip(detail, 2000)) } if !a.ReadOnly { diff --git a/internal/domain/workflow/agent_budget_test.go b/internal/domain/workflow/agent_budget_test.go new file mode 100644 index 000000000..3b39cacab --- /dev/null +++ b/internal/domain/workflow/agent_budget_test.go @@ -0,0 +1,27 @@ +package workflow + +import ( + "strings" + "testing" + + "github.com/samcharles93/archie-core/internal/domain/agentrun" +) + +// A stage that stops short keeps what it found: the notes it appended reach +// the error that parks the run, not only the task notes. +func TestDeliverResultNonPassedCarriesFindings(t *testing.T) { + res := agentrun.Result{ + Status: "parked", StopReason: "budget_exhausted", + Detail: "stopped after 60/60 steps, 900 tokens", + AppendedNotes: []string{"auth lives in internal/auth", "migration needs a backfill"}, + } + err := AgentStage{Name: "feasibility"}.deliverResult(&TaskContext{}, res) + if err == nil { + t.Fatal("want error for parked run") + } + for _, want := range res.AppendedNotes { + if !strings.Contains(err.Error(), want) { + t.Errorf("error %q lacks finding %q", err, want) + } + } +}