Commit 3528e67
authored
Fix persisted run error rendering (#4573)
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`:
```ts
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
```bash
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.1 parent d8af425 commit 3528e67
3 files changed
Lines changed: 69 additions & 9 deletions
File tree
- .changeset
- packages
- agents-runtime/src
- agents-server-ui/src/components
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
149 | 157 | | |
150 | 158 | | |
151 | 159 | | |
| |||
2158 | 2166 | | |
2159 | 2167 | | |
2160 | 2168 | | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
2161 | 2172 | | |
2162 | 2173 | | |
2163 | 2174 | | |
| |||
2208 | 2219 | | |
2209 | 2220 | | |
2210 | 2221 | | |
| 2222 | + | |
2211 | 2223 | | |
2212 | 2224 | | |
2213 | 2225 | | |
2214 | 2226 | | |
2215 | 2227 | | |
2216 | 2228 | | |
| 2229 | + | |
2217 | 2230 | | |
2218 | 2231 | | |
2219 | 2232 | | |
| |||
Lines changed: 50 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
373 | 375 | | |
374 | 376 | | |
375 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
376 | 413 | | |
377 | 414 | | |
378 | 415 | | |
| |||
658 | 695 | | |
659 | 696 | | |
660 | 697 | | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
661 | 702 | | |
662 | 703 | | |
663 | 704 | | |
| |||
667 | 708 | | |
668 | 709 | | |
669 | 710 | | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
| 711 | + | |
| 712 | + | |
674 | 713 | | |
675 | 714 | | |
676 | 715 | | |
| |||
896 | 935 | | |
897 | 936 | | |
898 | 937 | | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
899 | 942 | | |
900 | 943 | | |
901 | 944 | | |
| |||
905 | 948 | | |
906 | 949 | | |
907 | 950 | | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
| 951 | + | |
| 952 | + | |
912 | 953 | | |
913 | 954 | | |
914 | 955 | | |
| |||
0 commit comments