feat(agentexec,workflow): surface tool calls on the task timeline

archie-core-467 wired tool-call visibility into the interactive chat
gateway, but a workflow task's own transcript never showed what its
tools actually did -- only stage/agent-finish events existed, so
there was no way to confirm an agent's summary matched what it really
ran.

Adds a ToolCallReporter, invoked once per completed call from
toolExecute (the single choke point every tool call passes through
before reaching a model), reported via a new ToolSetOptions.OnToolCall
hook. Runner.Run grows a report parameter to carry it in: InProcessRunner
wires it through, since it executes in the same process as its tools;
SubprocessRunner and NATSRunner accept and ignore it, since their tool
calls happen in a different process with nothing here to observe them.

The workflow engine turns each report into a tool_call event on the
task's own Bus (agent.go, implement.go), riding the same NATS
event-forwarding archie-core-518 already built to get container
events onto the daemon's timeline.

Scoped to the central tool registry (read/write/edit/grep/shell/...)
built via BuildToolSet; capture tools (structured finish output) and
run_go_script build their ToolSet entries directly and are not yet
covered.
This commit is contained in:
sam committed 2026-08-15 12:53:41 +10:00
1 parent 8f73c1febb
commit 39d8b067ec
18 files changed
+250 -42

No files matched your search

+8 -3
View File
@@ -19,7 +19,10 @@ import (
// Runner executes one autonomous stage against an already prepared workspace.
type Runner interface {
Run(ctx context.Context, workspace string, req Request) (Result, error)
// report, when non-nil, is notified once per completed tool call. Only
// a runner executing in the same process as its tools (InProcessRunner)
// can populate it; others accept and ignore it.
Run(ctx context.Context, workspace string, req Request, report ToolCallReporter) (Result, error)
}
type loopFunc func(context.Context, agentloop.Config) (agentloop.Result, error)
@@ -62,7 +65,7 @@ func NewInProcessRunner(
// it is not configurable.
const workspaceToolset = "workspace"
func (r *InProcessRunner) Run(ctx context.Context, workspace string, req Request) (Result, error) {
func (r *InProcessRunner) Run(ctx context.Context, workspace string, req Request, report ToolCallReporter) (Result, error) {
if err := req.Validate(); err != nil {
return Result{}, err
}
@@ -75,7 +78,9 @@ func (r *InProcessRunner) Run(ctx context.Context, workspace string, req Request
notes := &memoryNotes{initial: req.Notes}
captures := make(map[string][]json.RawMessage)
centralTools, err := BuildToolSet(r.tools, r.Limits.Options(workspaceToolset))
toolOpts := r.Limits.Options(workspaceToolset)
toolOpts.OnToolCall = report
centralTools, err := BuildToolSet(r.tools, toolOpts)
if err != nil {
return Result{}, fmt.Errorf("build central tool set: %w", err)
}