pi-better-subagents 0.26.2 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lifecycle.ts CHANGED
@@ -7,6 +7,7 @@ export type LifecycleClassification =
7
7
  | "incomplete_no_terminal_event"
8
8
  | "incomplete_open_tools"
9
9
  | "failed_exit"
10
+ | "failed_model_error"
10
11
  | "killed"
11
12
  | "timed_out"
12
13
  | "orphaned"
@@ -21,6 +22,12 @@ export interface LifecycleDiagnostics {
21
22
  unmatchedTools: string[];
22
23
  /** Process exit code when known. */
23
24
  exitCode: number | null | undefined;
25
+ /**
26
+ * Message of the last model request that failed and was not superseded by a
27
+ * later assistant turn. Present even when the run is `complete`: a provider
28
+ * error can end the loop with a zero exit and a terminal event.
29
+ */
30
+ modelError?: string;
24
31
  /** Durable run status when known. */
25
32
  status?: RunStatus | "exited";
26
33
  }
@@ -58,6 +65,7 @@ function buildDiagnostics(
58
65
  unmatchedToolCount: run.unmatchedToolCalls.length,
59
66
  unmatchedTools: unmatchedToolLabels(run),
60
67
  exitCode,
68
+ modelError: run.modelError,
61
69
  status,
62
70
  };
63
71
  }
@@ -97,6 +105,20 @@ export function classifyChildExit(code: number | null, run: ParsedRun): ChildExi
97
105
  };
98
106
  }
99
107
 
108
+ // A zero exit with terminal evidence still proves nothing about the model: Pi
109
+ // ends the loop normally when the last request could not be served, and the
110
+ // stream is coherent. Without this check such a run is reported as ✓ completed
111
+ // with whatever partial text preceded the error.
112
+ if (run.modelError) {
113
+ return {
114
+ status: "failed",
115
+ incomplete: false,
116
+ classification: "failed_model_error",
117
+ diagnostics,
118
+ verdict: "✗ failed (model error)",
119
+ };
120
+ }
121
+
100
122
  return {
101
123
  status: "completed",
102
124
  incomplete: false,
@@ -196,6 +218,8 @@ function summaryFor(classification: LifecycleClassification): string {
196
218
  return "lifecycle incomplete_open_tools — unmatched tool executions remain";
197
219
  case "failed_exit":
198
220
  return "lifecycle failed_exit";
221
+ case "failed_model_error":
222
+ return "lifecycle failed_model_error — the last model request failed";
199
223
  case "killed":
200
224
  return "lifecycle killed";
201
225
  case "timed_out":
@@ -213,9 +237,11 @@ export function formatLifecycleDiagnostics(lifecycle: LifecycleValidation): stri
213
237
  const unmatched = d.unmatchedTools.length
214
238
  ? d.unmatchedTools.join(", ")
215
239
  : "none";
240
+ const modelError = d.modelError ? [`Model error: ${d.modelError}`] : [];
216
241
  return [
217
242
  `Lifecycle: ${lifecycle.classification}`,
218
243
  `Lifecycle diagnostics: terminal event: ${d.sawTerminalEvent ? "yes" : "no"}; unmatched tools: ${unmatched}; exit: ${d.exitCode === undefined ? "?" : String(d.exitCode)}`,
244
+ ...modelError,
219
245
  ].join("\n");
220
246
  }
221
247
 
package/navigator.mjs CHANGED
@@ -177,10 +177,19 @@ export function isNavigatorUiAvailable(ctx) {
177
177
  * @param {(m: object) => object|undefined} [deps.healthFor] - #66 HealthObservation
178
178
  * @param {number} [deps.now]
179
179
  */
180
+ export function pendingNavigatorPark(meta) {
181
+ const park = meta?.park;
182
+ return park?.version === 1 && ["parking", "waiting", "ready", "resuming", "held"].includes(park.phase) ? park : undefined;
183
+ }
184
+
185
+ function navigatorDisplayStatus(meta, status) {
186
+ return status === "running" || status === "orphaned" ? status : pendingNavigatorPark(meta)?.phase ?? status;
187
+ }
188
+
180
189
  export function buildNavigatorRows(metas, deps) {
181
190
  const now = deps.now ?? Date.now();
182
191
  return metas.map((m) => {
183
- const status = deps.effectiveStatus(m);
192
+ const status = navigatorDisplayStatus(m, deps.effectiveStatus(m));
184
193
  const health = typeof deps.healthFor === "function" ? deps.healthFor(m) : undefined;
185
194
  const effort = typeof deps.effortFor === "function" ? deps.effortFor(m) : (m.effort ?? m.modelEffort);
186
195
  const tool = typeof deps.toolFor === "function" ? (deps.toolFor(m) || "") : "";
@@ -374,7 +383,7 @@ export function buildNavigatorDetail(id, deps) {
374
383
  const now = deps.now ?? Date.now();
375
384
  const parsed = deps.parseRun(id);
376
385
  const toolCalls = parsed.toolCalls ?? [];
377
- const status = deps.effectiveStatus(meta);
386
+ const status = navigatorDisplayStatus(meta, deps.effectiveStatus(meta));
378
387
  const running = status === "running" || status === "orphaned";
379
388
  const health = typeof deps.healthFor === "function" ? deps.healthFor(meta) : undefined;
380
389
  const effortRaw = typeof deps.effortFor === "function"
@@ -384,6 +393,8 @@ export function buildNavigatorDetail(id, deps) {
384
393
  id: meta.id,
385
394
  name: meta.name,
386
395
  role: meta.catalog?.roleName || (meta.catalog?.roleId ? String(meta.catalog.roleId).replace(/^role\./, "") : undefined) || undefined,
396
+ park: pendingNavigatorPark(meta),
397
+ attemptStatus: deps.effectiveStatus(meta),
387
398
  status,
388
399
  model: deps.shortModel(meta.model),
389
400
  effort: effortRaw ? String(effortRaw) : undefined,
package/navigator.ts CHANGED
@@ -17,6 +17,7 @@ export {
17
17
  executeNavigatorClose,
18
18
  isNavigatorUiAvailable,
19
19
  buildNavigatorRows,
20
+ pendingNavigatorPark,
20
21
  buildNavigatorDetail,
21
22
  buildDetailLines,
22
23
  createNavigatorState,