Skip to content

fix: persist startRun and stopRunByError events for failed delegations#741

Merged
FL4TLiN3 merged 1 commit intomainfrom
fix/persist-failed-delegation-events
Mar 11, 2026
Merged

fix: persist startRun and stopRunByError events for failed delegations#741
FL4TLiN3 merged 1 commit intomainfrom
fix/persist-failed-delegation-events

Conversation

@FL4TLiN3
Copy link
Contributor

Summary

  • When a delegate's subprocess failed to start before the state machine initialized (e.g., MCP connection failure, npx not found in PATH), no events were persisted — the error was silently converted to a tool result text and returned to the parent expert
  • The catch block in DelegationExecutor.executeSingleDelegation() now emits startRun + stopRunByError events via the parent's storeEvent and eventListener callbacks, ensuring failed delegations are recorded in the event store

Root cause

The child run() calls CoordinatorExecutor.execute()SkillManager.fromExpert() → MCP adapter connect. If this fails, the error propagates before the state machine starts, so no startRun event is ever emitted and no run directory is created. The existing catch block only returned a text error to the parent — no structured failure record was persisted.

Evidence

Confirmed with real data from a create-expert job where 10 delegations (4× find-skill, 3× logic-engineer/tui-engineer/cli-engineer × 2) silently vanished. The parent's resumeFromStop checkpoint contained partialToolResults with "Delegation to X failed: Executable not found in $PATH: \"npx\"" — but no run directories or events existed for these delegations.

Test plan

  • Existing delegation-executor.test.ts passes (16 tests)
  • Typecheck passes for @perstack/runtime
  • Verify with a real job that failed delegations now produce run directories with startRun + stopRunByError event files

🤖 Generated with Claude Code

When a delegate's subprocess failed to start (e.g., MCP connection
failure, executable not found), no events were persisted because the
state machine never started. The error was silently converted to a
tool result text and returned to the parent expert.

Now the catch block in DelegationExecutor.executeSingleDelegation()
emits startRun + stopRunByError events via the parent's storeEvent
and eventListener callbacks, ensuring failed delegations are recorded
in the event store and visible in log viewers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@FL4TLiN3 FL4TLiN3 merged commit 356fa58 into main Mar 11, 2026
11 checks passed
@FL4TLiN3 FL4TLiN3 deleted the fix/persist-failed-delegation-events branch March 11, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant