Fail started agent runs on handler errors#4640
Open
KyleAMathews wants to merge 2 commits into
Open
Conversation
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4640 +/- ##
==========================================
- Coverage 59.46% 58.00% -1.46%
==========================================
Files 385 342 -43
Lines 43039 40351 -2688
Branches 12383 11779 -604
==========================================
- Hits 25591 23404 -2187
+ Misses 17371 16909 -462
+ Partials 77 38 -39
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Electric Agents Mobile BuildLocal mobile checks ran for commit The EAS Android preview build was skipped because the |
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.
Executive Summary
Mark newly-started agent runs as failed when a wake handler errors before ending them. This prevents the chat UI from showing "Thinking" indefinitely for runtime failure paths where the run start was persisted but no terminal run status was written.
Root Cause
The UI treats the latest run with
status: startedas actively streaming. When a handler created a run and then threw before calling the run's end path,processWakewrote an error event but did not also update that newly-started run to a terminal status. If the run was not yet visible through the local run collection, the existing failure association logic could not find it either.Approach
processWakeduring the current wake.started:The failure path deliberately checks that DB-visible runs are still
started, so a run that already completed successfully is not regressed to failed if later cleanup throws.Key Invariants
Non-goals
Trade-offs
The runtime keeps small per-wake bookkeeping of run status events in addition to querying the local collection. This is intentionally narrow: it only covers events emitted in the current wake and avoids broader persisted lease/heartbeat semantics, which need a separate design for crash recovery.
Verification
pnpm --dir packages/agents-runtime test process-wake.test.ts --run --reporter=dotFiles changed
packages/agents-runtime/src/process-wake.ts: fail the latest new still-started run when handler errors escape, with produced-event fallback for unmaterialized local writes.packages/agents-runtime/test/process-wake.test.ts: add regression coverage for failing newly-started runs and for not regressing completed runs to failed..changeset/fail-started-agent-runs.md: patch changeset for@electric-ax/agents-runtime.Refs #4633