oficina / equipo Public

Merge remote-tracking branch 'origin/main' into roster-phone-alignment

# Conflicts:
#	.rastrillo/budgets.txt
claude pushed by paul@keymail.dev 4389ca99dc28a21783a1d1f9c7c8303406c2caae parent ab8d543parent 22f5396
11 files changed, +306 −7
  • .rastrillo/budgets.txt +3 −3
  • cmd/equipo-runner/main.go +10 −1
  • cmd/equipo-runner/main_test.go +17 −0
  • internal/headless/assistant_test.go +58 −0
  • internal/runner/provider/claude/assist_policy_test.go +33 −0
  • internal/runner/provider/claude/launcher.go +10 −0
  • internal/runner/provider/codex/assist_policy_test.go +36 −0
  • internal/runner/provider/codex/launcher.go +11 −0
  • internal/runner/thin/assistant.go +2 −2
  • internal/runner/thin/assistant_test.go +98 −1
  • internal/runner/thin/engine.go +28 −0

CI passed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index dc530046..e2e3e8f1 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -38,7 +38,7 @@ time internal/runner/provider 15s Plan 3 CI repair measured 10.346s for the full
perf GET /releases/* skip Verified runner release file downloads, not browser GET screens.
perf GET /install.sh skip Mac runners: the one-line bootstrap a terminal pipes to sh, not a browser screen.
time internal/runner/containment 15s Plan 3 loaded CI measured 10.817s;
-size internal/runner/thin 25286 17727 Runner state, connections and execution share private helpers: Copy validation, job lanes and the Assistant. Measured 25286 source, 17727 test lines.
+size internal/runner/thin 25314 17824 Runner state, connections and execution share private helpers: Copy validation, job lanes and the Assistant, its turn phases log included. Measured 25314 source, 17824 test lines.
time internal/thintest 240s Thin contract and page tests, the Assistant's and the models' included, share one harness. Measured 202s on a shared 16 CPU box (2026-11-13); CI runs two lanes.
time internal/runner/mac 30s Mac runners (Darwin worker): real process groups killed after a grace and proven gone (SIGTERM, SIGKILL, the marker sweep), and the probes run end to end with fake srt and xcodebuild, P6 killing.
time internal/runner/thin 45s Thin v1 slice 4 review: real git repositories for the merge and squash checks, a stalled fetch, and a 16 MiB candidate streamed through the review diff and the checks pack (about 5s).
@@ -70,8 +70,8 @@ perf GET /api/v1/tasks/{id}/files/{file} skip Research kept images: bearer-only
perf GET /tasks/{id}/files/{file} skip Research kept images: the bytes of one image, shown on the task page; a file, not a screen.
perf GET /api/v1/runners skip Mac runners person API: bearer-only JSON for devices; the browser shows runners in the Team section.
time cmd/equipo-runner 60s TestReleaseRunnerHasNoFakeWorker builds the release runner and the thin package under testbuild (about 12s locally).
-size internal/headless - 10742 End-to-end scenarios through a real runner and instance: the Copy setting, wording flag and the Assistant's job threads. Measured 10742 test lines.
-size internal/thintest - 28593 The contract and browser tests share the instance harness; Roster adds Reply/Stop/CSRF guards and desktop/phone state captures. Measured 28593 test lines.
+size internal/headless - 10800 End-to-end scenarios through a real runner and instance: Copy setting, wording flag, the Assistant's job threads and streamed replies. Measured 10800 test lines.
+size internal/thintest - 28593 Contract and browser tests share one instance harness: Assistant hand-off, outcome and job contracts, Roster guards and captures. Measured 28469 test lines.
perf GET /api/v1/projects/{id}/merge-policy skip Merge authority person API: bearer-only JSON for devices; the browser reads the policy on /projects/{id}.
perf GET /api/v1/usage skip Thin v1 person API: bearer-only JSON for devices; the browser reads usage through /usage.
perf GET /api/v1/advice skip Thin v1 person API: bearer-only JSON for devices; the browser reads advice through /usage and /conversation.
diff --git a/cmd/equipo-runner/main.go b/cmd/equipo-runner/main.go
index bfdafd3c..6f714040 100644
--- a/cmd/equipo-runner/main.go
+++ b/cmd/equipo-runner/main.go
@@ -122,7 +122,7 @@ func run(ctx context.Context, args []string, input io.Reader, output, errorOutpu
err = runner.Reset(ctx, cfg)
case "run":
opts := thin.OptionsFromEnv(getenv)
- opts.Version, opts.Logger = rastrillo.BuildVersion, slog.New(slog.NewTextHandler(errorOutput, nil))
+ opts.Version, opts.Logger = rastrillo.BuildVersion, slog.New(slog.NewTextHandler(errorOutput, logOptions(getenv)))
logStart(opts.Logger, cfg, opts.Version, envFile)
err = thin.Run(ctx, cfg, opts)
if errors.Is(err, thin.ErrSuperseded) {
@@ -175,6 +175,15 @@ func main() {
// logStart is the runner's first line: what starts, where it connects
// (the origin's host only) and from which env file. No credential.
+// logOptions is the runner's log level: info, or debug with
+// EQUIPO_RUNNER_LOG_LEVEL=debug (an Assistant turn's phases, for one).
+func logOptions(getenv func(string) string) *slog.HandlerOptions {
+ if getenv("EQUIPO_RUNNER_LOG_LEVEL") == "debug" {
+ return &slog.HandlerOptions{Level: slog.LevelDebug}
+ }
+ return &slog.HandlerOptions{Level: slog.LevelInfo}
+}
+
func logStart(log *slog.Logger, cfg runner.Config, version, envFile string) {
role := wire.RolePrimary
if cfg.WorkerOnly || runner.ReadRole(cfg.StateDir) == wire.RoleWorker {
diff --git a/cmd/equipo-runner/main_test.go b/cmd/equipo-runner/main_test.go
index 57e7da8f..a056e12f 100644
--- a/cmd/equipo-runner/main_test.go
+++ b/cmd/equipo-runner/main_test.go
@@ -3,6 +3,7 @@ package main
import (
"bytes"
"context"
+ "log/slog"
"os"
"path/filepath"
"strings"
@@ -93,3 +94,19 @@ func TestInstallOpenCodeArguments(t *testing.T) {
}
}
}
+
+// The runner logs at info unless EQUIPO_RUNNER_LOG_LEVEL=debug asks for
+// its debug lines too (an Assistant turn's phases among them).
+func TestRunnerLogLevel(t *testing.T) {
+ for v, want := range map[string]slog.Level{"": slog.LevelInfo, "info": slog.LevelInfo, "verbose": slog.LevelInfo, "debug": slog.LevelDebug} {
+ o := logOptions(func(k string) string {
+ if k == "EQUIPO_RUNNER_LOG_LEVEL" {
+ return v
+ }
+ return ""
+ })
+ if got := o.Level.Level(); got != want {
+ t.Errorf("EQUIPO_RUNNER_LOG_LEVEL=%q: level %v, want %v", v, got, want)
+ }
+ }
+}
diff --git a/internal/headless/assistant_test.go b/internal/headless/assistant_test.go
index 1a46f4a6..424d6af6 100644
--- a/internal/headless/assistant_test.go
+++ b/internal/headless/assistant_test.go
@@ -347,6 +347,64 @@ func TestHeadlessAssistant(t *testing.T) {
// first team_update nudges it once with the person's own words, which
// the thread gets again with the Assistant's context; the work starts
// and the person hears nothing of the stop.
+ // The Assistant's reply streams on either provider: its first text
+ // reaches /api/v1/assistant/events as a delta while the turn is still
+ // running, well before the reply message that replaces the draft.
+ t.Run("streamed", func(t *testing.T) {
+ for _, provider := range []string{"claude", "codex"} {
+ t.Run(provider, func(t *testing.T) {
+ env, _, r := localEnv(t)
+ r.opts.NoMoveIn = true
+ if provider == "codex" {
+ r.addAccount(t, "codex", "codex-1", thintest.Owner)
+ r.only(t, "codex-1")
+ }
+ r.start(t)
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
+ defer cancel()
+ a := env.Client.Assistant()
+ snap, err := a.Snapshot(ctx)
+ if err != nil {
+ t.Fatal(err)
+ }
+ s, err := a.Open(ctx, snap.Cursor)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer s.Close()
+ // The fake pauses two seconds after its first words.
+ sent, err := a.Send(ctx, "Hello there. sleep:2000", key())
+ if err != nil {
+ t.Fatal(err)
+ }
+ var delta, reply time.Time
+ for reply.IsZero() {
+ select {
+ case e, ok := <-s.Events:
+ if !ok {
+ t.Fatal("the Assistant's stream ended")
+ }
+ var m wire.Message
+ switch {
+ case e.Type == wire.EventDelta && e.TurnID == sent.Turn.ID && delta.IsZero():
+ delta = time.Now()
+ case e.Type == wire.EventMessage && json.Unmarshal(e.Data, &m) == nil && m.TurnID == sent.Turn.ID && m.Role == wire.RoleAssistant:
+ reply = time.Now()
+ }
+ case <-ctx.Done():
+ t.Fatal("no reply")
+ }
+ }
+ if delta.IsZero() {
+ t.Fatalf("on %s no delta came before the reply", provider)
+ }
+ if gap := reply.Sub(delta); gap < time.Second {
+ t.Fatalf("on %s the first delta came only %v before the reply", provider, gap)
+ }
+ })
+ }
+ })
+
t.Run("nudged_through", func(t *testing.T) {
env, inst, r := localEnv(t)
r.opts.NoMoveIn = true
diff --git a/internal/runner/provider/claude/assist_policy_test.go b/internal/runner/provider/claude/assist_policy_test.go
index 204420cb..f9c3aaf8 100644
--- a/internal/runner/provider/claude/assist_policy_test.go
+++ b/internal/runner/provider/claude/assist_policy_test.go
@@ -39,3 +39,36 @@ func TestAssistLaunchPinsSixTools(t *testing.T) {
t.Fatalf("converse with use: %v", err)
}
}
+
+// The Assistant answers a person who is waiting: its launch asks for the
+// lowest effort on the connection's own model, and the team's launches
+// keep the CLI's default.
+func TestAssistLaunchLowEffort(t *testing.T) {
+ b := provider.Binding{Provider: "claude", CredentialHome: "/private/account", Home: "/private/run", RuntimeRoot: "/private/runtime"}
+ effort := func(action string) (string, []string) {
+ t.Helper()
+ profile, err := provider.Profile(action)
+ if err != nil {
+ t.Fatal(err)
+ }
+ got, err := PolicyInputs(b, provider.PolicyInputs{Action: action, Tools: profile.MCPTools()}, profile.Specialist, "claude-opus-5-5")
+ if err != nil {
+ t.Fatalf("%s: %v", action, err)
+ }
+ if i := slices.Index(got.Argv, "--model"); i < 0 || got.Argv[i+1] != "claude-opus-5-5" {
+ t.Fatalf("%s model %v", action, got.Argv)
+ }
+ if i := slices.Index(got.Argv, "--effort"); i >= 0 && i+1 < len(got.Argv) {
+ return got.Argv[i+1], got.Argv
+ }
+ return "", got.Argv
+ }
+ if got, argv := effort("assist"); got != "low" {
+ t.Fatalf("assist effort %q: %v", got, argv)
+ }
+ for _, action := range []string{"converse", "coordinate", "implement", "inspect", "answer"} {
+ if got, argv := effort(action); got != "" {
+ t.Fatalf("%s effort %q: %v", action, got, argv)
+ }
+ }
+}
diff --git a/internal/runner/provider/claude/launcher.go b/internal/runner/provider/claude/launcher.go
index a1c659f9..041198c9 100644
--- a/internal/runner/provider/claude/launcher.go
+++ b/internal/runner/provider/claude/launcher.go
@@ -100,6 +100,10 @@ func AuthStatusArgs() []string {
return []string{"/opt/claude", "--setting-sources", "", "--settings", provider.SettingsPath, "--strict-mcp-config", "--mcp-config", provider.MCPPath, "--disable-slash-commands", "auth", "status", "--json"}
}
+// AssistEffort is the Assistant's effort level (the pinned CLI's
+// --effort: low, medium, high, xhigh).
+const AssistEffort = "low"
+
func baseArgs(model, tools string) []string {
return []string{"/opt/claude", "-p", "--verbose", "--include-hook-events", "--input-format", "stream-json", "--output-format", "stream-json", "--model", model, "--setting-sources", "", "--disable-slash-commands", "--strict-mcp-config", "--mcp-config", provider.MCPPath, "--settings", provider.SettingsPath, "--permission-mode", "manual", "--permission-prompt-tool", "mcp__equipo__permission", "--tools", tools}
}
@@ -205,6 +209,12 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, specialist, mode
if provider.CoordinatorAction(in.Action) || specialist == "Coordinator" || in.Action == "answer" {
in.Argv = append(in.Argv, "--include-partial-messages")
}
+ // The Assistant answers a person who is waiting: the lowest effort
+ // on the connection's own model. Its model is the person's choice and
+ // stays as bound; the team's launches keep the CLI's default effort.
+ if in.Action == "assist" {
+ in.Argv = append(in.Argv, "--effort", AssistEffort)
+ }
return in, nil
}
func compact(v []string) []string {
diff --git a/internal/runner/provider/codex/assist_policy_test.go b/internal/runner/provider/codex/assist_policy_test.go
index ad3ef968..951e4fb2 100644
--- a/internal/runner/provider/codex/assist_policy_test.go
+++ b/internal/runner/provider/codex/assist_policy_test.go
@@ -1,6 +1,7 @@
package codex
import (
+ "encoding/json"
"errors"
"testing"
@@ -23,3 +24,38 @@ func TestAssistLaunchCodex(t *testing.T) {
t.Fatalf("a seventh tool: %v", err)
}
}
+
+// The Assistant answers a person who is waiting: each of its turns asks
+// for low reasoning effort on the connection's own model, and the team's
+// turns keep the model's default.
+func TestAssistLaunchCodexLowEffort(t *testing.T) {
+ b := provider.Binding{Provider: "codex", CredentialHome: "/private/account", Home: "/private/run", RuntimeRoot: "/private/runtime"}
+ turn := func(action string) map[string]any {
+ t.Helper()
+ profile, err := provider.Profile(action)
+ if err != nil {
+ t.Fatal(err)
+ }
+ in, err := PolicyInputs(b, provider.PolicyInputs{Action: action, Tools: profile.MCPTools(), DeniedPaths: []string{"/private/state"}}, "gpt-6-astra")
+ if err != nil {
+ t.Fatalf("%s: %v", action, err)
+ }
+ var thread struct{ Model string }
+ if json.Unmarshal(in.ThreadPolicy, &thread) != nil || thread.Model != "gpt-6-astra" {
+ t.Fatalf("%s thread %s", action, in.ThreadPolicy)
+ }
+ var params map[string]any
+ if err := json.Unmarshal(TurnParams(provider.Policy{TurnPolicy: in.TurnPolicy}, "th", "hello"), &params); err != nil {
+ t.Fatal(err)
+ }
+ return params
+ }
+ if got := turn("assist"); got["effort"] != "low" || got["threadId"] != "th" {
+ t.Fatalf("assist turn/start %v", got)
+ }
+ for _, action := range []string{"converse", "coordinate", "implement", "inspect"} {
+ if got, ok := turn(action)["effort"]; ok {
+ t.Fatalf("%s effort %v", action, got)
+ }
+ }
+}
diff --git a/internal/runner/provider/codex/launcher.go b/internal/runner/provider/codex/launcher.go
index 3e322282..0d5d094e 100644
--- a/internal/runner/provider/codex/launcher.go
+++ b/internal/runner/provider/codex/launcher.go
@@ -23,6 +23,9 @@ import (
const Version = provider.CodexVersion
const ExecutableSHA256 = "c06a67fd8ac76508dc78bd99ce20c9f317b8d568beda59485f3f4134df9962d5"
const CodeModeHostSHA256 = "522935d4392ec9674fab60b239b5495992c6a93e4deb65113a216b6f5451ccd4"
+
+// AssistEffort is the Assistant's reasoning effort (turn/start effort).
+const AssistEffort = "low"
const errNotReady provider.Error = "codex_not_ready"
const errUncertain provider.Error = "codex_turn_uncertain"
const errFailed provider.Error = "codex_process_failed"
@@ -187,6 +190,14 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, model string) (p
thread["experimentalRawEvents"] = true
in.ThreadPolicy = marshal(thread)
in.TurnPolicy = json.RawMessage(`{}`)
+ if in.Action == "assist" {
+ // The Assistant answers a person who is waiting: low reasoning
+ // effort on every turn/start, on the connection's own model (the
+ // person's choice, unchanged). The pinned app-server sends it as
+ // the request's reasoning.effort; the team's turns keep the
+ // model's default.
+ in.TurnPolicy = marshal(map[string]string{"effort": AssistEffort})
+ }
in.Argv = []string{"/opt/codex", "app-server", "--strict-config", "--listen", "stdio://"}
keys := make([]string, 0, len(settings))
for k := range settings {
diff --git a/internal/runner/thin/assistant.go b/internal/runner/thin/assistant.go
index d2864e24..e7f40b19 100644
--- a/internal/runner/thin/assistant.go
+++ b/internal/runner/thin/assistant.go
@@ -27,7 +27,7 @@ type laneProfile struct {
// assistRule versions the Assistant's opening, as houseRule does the
// coordinator's: a session started under another rule is not resumed.
-const assistRule = "assist-2026-11-13.1"
+const assistRule = "assist-2026-11-14.1"
// errLane is a lane the runner does not know.
var errLane = errors.New("thin: unknown lane")
@@ -85,7 +85,7 @@ func assistantOpening(person string, _ []wire.RepoInfo) string {
b.WriteString("You are Base, the assistant for " + person + ": a helper for their business. Answer briefly, in plain sentences; simple lists are fine. Do not use em dashes.\n")
b.WriteString("Never name Equipo, the team, the Coordinator, runners, tasks, branches, merges, checks or repositories, unless the person asks how it works.\n")
b.WriteString("Your rules, in order of weight:\n")
- b.WriteString("1. Look before answering. What exists comes from look, never from memory: call look before you say what there is or what you can do.\n")
+ b.WriteString("1. Look before you say what exists or what you can do, and before you use an operation: what exists comes from look, never from memory. For greetings and small talk, answer directly without tools.\n")
b.WriteString("2. Do what was asked with the least ceremony. Ask the person one question only when they alone can answer it.\n")
b.WriteString("3. Speak in outcomes: what you understood, what happened, what you need.\n")
b.WriteString("4. Software work (build, fix or change an app or site) is a job: hand it off with team_request through use, give it a short title (a few words, such as \"Fixing the sign-in page\"), and reply in a few words (\"On it.\"). Don't narrate progress; the person sees it on the job.\n")
diff --git a/internal/runner/thin/assistant_test.go b/internal/runner/thin/assistant_test.go
index 3a216407..eea601b2 100644
--- a/internal/runner/thin/assistant_test.go
+++ b/internal/runner/thin/assistant_test.go
@@ -4,10 +4,12 @@ import (
"context"
"database/sql"
"encoding/json"
+ "log/slog"
"os"
"path/filepath"
"slices"
"strings"
+ "sync"
"testing"
"time"
@@ -203,7 +205,19 @@ func TestAssistantOpening(t *testing.T) {
if coord.action != "converse" || coord.rule != houseRule || coord.opening("ana@example.com", catalog) != opening("ana@example.com", catalog) {
t.Fatal("the coordinator's profile changed")
}
- if a := profileFor(wire.LaneAssistant); a.action != "assist" || a.rule != "assist-2026-11-13.1" {
+ // Rule 1 looks only when it is needed: before saying what exists or
+ // what it can do, or before using an operation. A greeting or small
+ // talk is answered directly, with no tool call to wait for.
+ rule1 := o[at("1. "):at("2. ")]
+ for _, want := range []string{"Look before you say what exists or what you can do", "before you use an operation", "never from memory", "greetings and small talk", "answer directly without tools"} {
+ if !strings.Contains(rule1, want) {
+ t.Errorf("rule 1 lacks %q: %q", want, rule1)
+ }
+ }
+ if strings.Contains(rule1, "Look before answering") {
+ t.Errorf("rule 1 still looks before every answer: %q", rule1)
+ }
+ if a := profileFor(wire.LaneAssistant); a.action != "assist" || a.rule != "assist-2026-11-14.1" {
t.Fatalf("assistant profile %q %q", a.action, a.rule)
}
// A team update is the instance's news, framed for the Assistant to
@@ -521,3 +535,86 @@ func TestForgetKeepsPreview(t *testing.T) {
t.Fatal("the preview stayed up after the forget that releases it")
}
}
+
+// timedCoordinator replies with the timing a harness reports.
+type timedCoordinator struct{ timing *wire.TurnTiming }
+
+func (c *timedCoordinator) Turn(_ context.Context, _ TurnInput, emit func(string)) TurnResult {
+ emit("private words")
+ return TurnResult{Text: "private words", Timing: c.timing}
+}
+func (c *timedCoordinator) Close() {}
+
+// An Assistant turn logs its phases at debug level, with durations from
+// when the runner accepted it: the process started, the first token, the
+// reply queued. The line holds no text and no tokens; a coordinator turn
+// logs none.
+func TestAssistantTurnLogsItsPhases(t *testing.T) {
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ state, err := OpenState(ctx, t.TempDir())
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer state.Close()
+ var mu sync.Mutex
+ var out strings.Builder
+ logger := slog.New(slog.NewTextHandler(writerFunc(func(p []byte) (int, error) {
+ mu.Lock()
+ defer mu.Unlock()
+ return out.Write(p)
+ }), &slog.HandlerOptions{Level: slog.LevelDebug}))
+ coord := &timedCoordinator{timing: &wire.TurnTiming{Cold: true, StartMs: 3900, FirstToolMs: 3500, FirstTextMs: 4900, ResultMs: 5500}}
+ e := &Engine{State: state, Logger: logger, Emit: func(wire.DeltaReport) {}, Notify: func() {}, Open: func(string, string, runner.AccountBinding) (Coordinator, error) {
+ return coord, nil
+ }}
+ if err := e.Start(ctx); err != nil {
+ t.Fatal(err)
+ }
+ defer e.Wait()
+ defer cancel()
+ p := "ana@example.com"
+ for _, m := range []wire.MessageCommand{{Person: p, TurnID: "tc", Attempt: 1, Text: "private words"}, {Person: p, TurnID: "ta", Attempt: 1, Text: "private words", Lane: wire.LaneAssistant}} {
+ if err := state.Accept(ctx, "f"+m.TurnID, m); err != nil {
+ t.Fatal(err)
+ }
+ e.Wake(p, m.Lane)
+ }
+ deadline := time.Now().Add(5 * time.Second)
+ var lines []string
+ for time.Now().Before(deadline) {
+ mu.Lock()
+ lines = nil
+ for _, l := range strings.Split(out.String(), "\n") {
+ if strings.Contains(l, `msg="assistant turn"`) {
+ lines = append(lines, l)
+ }
+ }
+ mu.Unlock()
+ if len(lines) > 0 {
+ break
+ }
+ time.Sleep(20 * time.Millisecond)
+ }
+ if len(lines) != 1 {
+ t.Fatalf("phase lines %q\n%s", lines, out.String())
+ }
+ line := lines[0]
+ for _, want := range []string{"level=DEBUG", "turn=ta", "outcome=replied", "cold=true", "started_ms=3900", "first_tool_ms=7400", "first_token_ms=8800", "reply_ms="} {
+ if !strings.Contains(line, want) {
+ t.Errorf("phase line lacks %s: %s", want, line)
+ }
+ }
+ mu.Lock()
+ all := out.String()
+ mu.Unlock()
+ for _, never := range []string{"private", "turn=tc", "token=", p} {
+ if strings.Contains(all, never) {
+ t.Errorf("the log holds %q: %s", never, all)
+ }
+ }
+}
+
+type writerFunc func([]byte) (int, error)
+
+func (f writerFunc) Write(p []byte) (int, error) { return f(p) }
diff --git a/internal/runner/thin/engine.go b/internal/runner/thin/engine.go
index 493b6bb4..70514b47 100644
--- a/internal/runner/thin/engine.go
+++ b/internal/runner/thin/engine.go
@@ -220,6 +220,33 @@ func (e *Engine) log(msg string, err error) {
}
}
+// phases logs an Assistant turn's phases at debug level, each as the
+// milliseconds since the runner accepted the turn: its process started
+// (the prompt written; a cold turn includes the process's start), its
+// first tool call, its first token, and its reply queued for the
+// instance. Only the turn id, never text, tokens or the person.
+func (e *Engine) phases(r run, res TurnResult) {
+ if e.Logger == nil || r.Lane != wire.LaneAssistant || r.Received.IsZero() {
+ return
+ }
+ outcome := res.Reason
+ if outcome == "" {
+ outcome = wire.TurnReplied
+ }
+ attrs := []any{"turn", r.TurnID, "attempt", r.Attempt, "outcome", outcome}
+ if t := res.Timing; t != nil {
+ at := func(ms int64) int64 {
+ if ms == 0 {
+ return 0
+ }
+ return t.StartMs + ms
+ }
+ attrs = append(attrs, "cold", t.Cold, "started_ms", t.StartMs, "first_tool_ms", at(t.FirstToolMs), "first_token_ms", at(t.FirstTextMs))
+ }
+ attrs = append(attrs, "reply_ms", time.Since(r.Received).Milliseconds())
+ e.Logger.Debug("assistant turn", attrs...)
+}
+
func (e *Engine) loop(k workerKey, w *worker) {
defer e.wg.Done()
defer func() {
@@ -301,6 +328,7 @@ func (e *Engine) runOne(person string, w *worker, r run) {
}
e.log("runner report", err)
e.Notify()
+ e.phases(r, res)
}
if r.Cancel {
report(TurnResult{Reason: "cancelled"})