···198198 }
199199200200 if (!terminalSeen) {
201201+ const lastEventType =
202202+ decodedLines.length > 0
203203+ ? readString(decodedLines[decodedLines.length - 1]!, "type")
204204+ : undefined;
205205+201206 return yield* Effect.fail(
202207 new PiCodecError({
203203- message: "Missing terminal agent_end line from pi process output.",
208208+ message: `Missing terminal agent_end line from pi process output (lines=${String(decodedLines.length)}, lastType=${lastEventType ?? "unknown"}). Process may have been interrupted or stalled.`,
204209 }),
205210 );
206211 }