Skip to content

Fix persisted run error rendering#4573

Open
KyleAMathews wants to merge 4 commits into
mainfrom
fix-run-error-rendering-worktree
Open

Fix persisted run error rendering#4573
KyleAMathews wants to merge 4 commits into
mainfrom
fix-run-error-rendering-worktree

Conversation

@KyleAMathews

@KyleAMathews KyleAMathews commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Fixes run error rendering in the agents timeline so handler failures stay attached to the failed run after a refresh. Long or multiline error messages now render using the same expandable event-card pattern as tool calls.

Root Cause

Handler failures were written to the entity errors collection without a run_id:

entityStateSchema.errors.insert({
  value: {
    error_code: errCode,
    message: errMsg,
  },
})

The live UI could briefly surface the failure while the failed run was still in memory, but after a refresh the run row only reads errors associated with that run. Without run_id, the error became a standalone stream error and disappeared from the failed run’s footer.

Separately, the UI rendered the full error text inline. Provider/runtime errors can be long or multiline, so the footer could truncate important details with no way to expand them.

Approach

  • Snapshot the set of run keys before invoking each handler pass.
  • If the handler fails, find the last run created during that pass and write the handler error with that run’s run_id.
  • Reuse InlineEventCard for long or multiline run errors so they follow the same expandable pattern as tool calls:
    • short errors stay inline and truncated in the response metadata row
    • long or multiline errors render as a collapsible run error card with the full message in the card body

Key Invariants

  • A handler error should attach only to a run created during the same handler pass.
  • Existing historical runs must not receive errors from later failed handler passes.
  • Standalone/non-run errors should remain standalone when no run was created.
  • Runtime-created run rows are appended sequentially, so the last newly-created run is the run to associate with a handler failure.
  • The UI should preserve full error text while keeping the collapsed timeline readable.

Non-goals

  • This does not change standalone entity error rows in the timeline.
  • This does not change model provider error classification or error-code generation.
  • This does not introduce a second expandable styling system for run errors.

Trade-offs

The runtime infers the failed run by comparing the pre-handler run-key snapshot to the post-failure run collection, rather than threading a current run id through every handler/agent path. That keeps the change localized to processWake and preserves existing agent/run APIs, at the cost of selecting the last newly-created run when a handler creates multiple runs before failing.

Using InlineEventCard makes long run errors visually heavier than a small inline footer, but it reuses the existing expandable UI pattern instead of adding bespoke details styling.

Verification

pnpm install
pnpm --filter @electric-ax/agents-runtime exec vitest run test/process-wake.test.ts --reporter=dot
pnpm --filter @electric-ax/agents-runtime build
pnpm --filter @electric-ax/agents-server-ui run typecheck
GITHUB_BASE_REF=main node scripts/check-changeset.mjs

Files changed

  • packages/agents-runtime/src/process-wake.ts

    • Tracks runs created during each handler pass and attaches handler errors to the last new run.
  • packages/agents-server-ui/src/components/AgentResponse.tsx

    • Adds shared run error rendering for both live and cached agent responses.
    • Uses InlineEventCard for long or multiline error messages.
  • .changeset/run-error-rendering.md

    • Adds patch changeset entries for the affected agents packages.

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Electric Agents Desktop Builds

Build artifacts for commit 65f6dcf.

Platform Status Artifact
macOS Apple Silicon Passed DMG
macOS Intel Passed DMG
Windows x64 Building Installer
Linux x64 Passed AppImage / deb

Workflow run

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 39.39394% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.67%. Comparing base (baee54e) to head (65f6dcf).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
.../agents-server-ui/src/components/AgentResponse.tsx 0.00% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4573      +/-   ##
==========================================
- Coverage   57.31%   56.67%   -0.65%     
==========================================
  Files         347      327      -20     
  Lines       39124    37978    -1146     
  Branches    11189    10954     -235     
==========================================
- Hits        22425    21525     -900     
+ Misses      16661    16417     -244     
+ Partials       38       36       -2     
Flag Coverage Δ
packages/agents 71.37% <ø> (ø)
packages/agents-mcp ?
packages/agents-mobile 75.49% <ø> (ø)
packages/agents-runtime 82.49% <100.00%> (+0.01%) ⬆️
packages/agents-server 74.86% <ø> (ø)
packages/agents-server-ui 6.24% <0.00%> (-0.01%) ⬇️
packages/electric-ax 46.42% <ø> (ø)
typescript 56.67% <39.39%> (-0.65%) ⬇️
unit-tests 56.67% <39.39%> (-0.65%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Electric Agents Mobile Build

Local mobile checks ran for commit 65f6dcf.

The EAS Android preview build was skipped because the mobile-eas-build label is not present.
Add the mobile-eas-build label to this PR to produce an installable preview build.

Workflow run

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