fix: persist startRun and stopRunByError events for failed delegations#741
Merged
fix: persist startRun and stopRunByError events for failed delegations#741
Conversation
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>
This was referenced Mar 11, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
npxnot found in PATH), no events were persisted — the error was silently converted to a tool result text and returned to the parent expertDelegationExecutor.executeSingleDelegation()now emitsstartRun+stopRunByErrorevents via the parent'sstoreEventandeventListenercallbacks, ensuring failed delegations are recorded in the event storeRoot cause
The child
run()callsCoordinatorExecutor.execute()→SkillManager.fromExpert()→ MCP adapter connect. If this fails, the error propagates before the state machine starts, so nostartRunevent 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-expertjob where 10 delegations (4×find-skill, 3×logic-engineer/tui-engineer/cli-engineer× 2) silently vanished. The parent'sresumeFromStopcheckpoint containedpartialToolResultswith"Delegation to X failed: Executable not found in $PATH: \"npx\""— but no run directories or events existed for these delegations.Test plan
delegation-executor.test.tspasses (16 tests)@perstack/runtimestartRun+stopRunByErrorevent files🤖 Generated with Claude Code