feat: close Gap 1 — per-task agent (multi-stage batch execution)

HandleMessage now supports two modes:
- Single-stage (Request only): backward compatible, no Workflow set
- Per-task batch (Workflow + Stages): runs all stages sequentially,
  accumulates tokens/iterations/notes, sets TaskCompleted on success

New fields:
- AgentRequestMessage.Stages []Request — batch of agent stages
- AgentResponseEnvelope.TaskCompleted bool — true when batch done

RunnerFactory injection for testability — HandleMessage accepts a
factory function. DefaultRunnerFactory creates InProcessRunner.
Tests use mockRunner.

runStages() executes each stage, stops on first failure, aggregates
results. Combined summary uses "[stage] summary" format.
This commit is contained in:
sam committed 2026-07-22 03:20:37 +10:00
1 parent e8ffa20b33
commit ce9ce050ed
4 files changed
+169 -57

No files matched your search

+1 -1
View File
@@ -155,7 +155,7 @@ func handle(ctx context.Context, msg jetstream.Msg, nc *nats.Conn, log *slog.Log
"reply_to", replyTo,
)
resp, err := agentexec.HandleMessage(ctx, req, log)
resp, err := agentexec.HandleMessage(ctx, req, log, agentexec.DefaultRunnerFactory)
if err != nil {
return fmt.Errorf("handle: %w", err)
}