Commit 10d73a0
committed
fix(#82961): surface cleanup-step diagnostic state on agent cleanup timeout
`pi-trajectory-flush` (and any other step routed through
`runAgentCleanupStep`) currently warns with only the envelope on timeout:
agent cleanup timed out: runId=... sessionId=... step=pi-trajectory-flush timeoutMs=10000
This tells operators nothing about what the flush is waiting on
(queued writer work, event-loop yield, or file append IO). The issue
asks for "bounded, non-secret state" alongside the timeout.
Add an optional `getCleanupDiagnostic?: () => string | undefined`
parameter to `runAgentCleanupStep`. If provided, the callback is
evaluated on timeout (inside a try/catch so a misbehaving probe cannot
break the warning itself) and its return value is appended to the
existing warning line.
Wire the trajectory caller in
`src/agents/pi-embedded-runner/run/attempt.ts` to pass a probe that
reports whether the trajectory recorder was constructed for the
attempt. The probe is deliberately minimal at this stage — full queued
writer stats (queuedWrites / queuedBytes / activeOp / appendSize)
require the `TrajectoryRuntimeRecorder` interface to expose those
counters, which is a separate refactor. The scaffold here lets that
follow-up plug in trivially.
Behaviour:
* No diagnostic callback → byte-identical warning to before this PR.
* Callback returns string → appended after `timeoutMs=...`.
* Callback throws → message is captured as `diagnosticError=...`; the
timeout warning itself never fails.
* Success path unchanged.1 parent 37806af commit 10d73a0
2 files changed
Lines changed: 30 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4490 | 4490 | | |
4491 | 4491 | | |
4492 | 4492 | | |
| 4493 | + | |
| 4494 | + | |
| 4495 | + | |
| 4496 | + | |
| 4497 | + | |
| 4498 | + | |
| 4499 | + | |
| 4500 | + | |
| 4501 | + | |
| 4502 | + | |
| 4503 | + | |
| 4504 | + | |
| 4505 | + | |
| 4506 | + | |
4493 | 4507 | | |
4494 | 4508 | | |
4495 | 4509 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
60 | 67 | | |
61 | 68 | | |
62 | 69 | | |
| |||
88 | 95 | | |
89 | 96 | | |
90 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
91 | 106 | | |
92 | | - | |
| 107 | + | |
93 | 108 | | |
94 | 109 | | |
95 | 110 | | |
| |||
0 commit comments