@d3ara1n/pi-subagent 1.7.0 → 1.7.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/spawn.ts +11 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d3ara1n/pi-subagent",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "type": "module",
5
5
  "description": "Role-based subagent orchestration for pi — delegates tasks to specialized pi child processes with configurable model roles",
6
6
  "main": "src/index.ts",
package/src/spawn.ts CHANGED
@@ -367,11 +367,12 @@ export async function spawnSubagent(
367
367
  // RPC command acknowledgements ("response" lines) carry no agent state.
368
368
  if (event.type === "response") return;
369
369
 
370
- // RPC mode is a resident server: after the task completes (agent_end) the
371
- // process would idle forever waiting for more stdin commands. We run one
372
- // prompt per child, so ending our stdin side triggers its graceful
373
- // shutdown (onInputEnd runtime dispose exit).
374
- if (event.type === "agent_end") {
370
+ // RPC mode is a resident server. agent_end only marks one low-level run
371
+ // and may be followed by an automatic retry, compaction, or queued
372
+ // continuation. agent_settled is the authoritative terminal event. We run
373
+ // one prompt per child, so ending stdin there triggers graceful shutdown
374
+ // (onInputEnd runtime dispose → exit).
375
+ if (event.type === "agent_settled") {
375
376
  try {
376
377
  proc?.stdin?.end();
377
378
  } catch {
@@ -398,8 +399,11 @@ export async function spawnSubagent(
398
399
  );
399
400
  }
400
401
  if (!result.model && msg.model) result.model = msg.model;
401
- if (msg.stopReason) result.stopReason = msg.stopReason;
402
- if (msg.errorMessage) result.errorMessage = msg.errorMessage;
402
+ // message_end is authoritative for the latest assistant attempt. A
403
+ // successful native retry must clear the transient error left by the
404
+ // failed attempt instead of triggering a redundant whole-run fallback.
405
+ result.stopReason = msg.stopReason;
406
+ result.errorMessage = msg.errorMessage;
403
407
 
404
408
  // Track last assistant text
405
409
  for (const part of msg.content) {