Commit 06a60fa
authored
Fix reasoning section elapsed timers (#4629)
Fix reasoning-section elapsed timers so each thinking block measures
from when that block starts, not from the beginning of the run. This
prevents later “Thought for …” sections in long tool-using runs from
showing inflated durations that grow across the whole run.
## Root Cause
`ReasoningBlock` received the parent run timestamp and used it for both
the live elapsed timer and the final collapsed `Thought for …` label. In
multi-step runs, later reasoning rows can start well after the run
begins — for example after a tool call returns — so anchoring every row
to the run start made each new reasoning section inherit all prior run
time.
## Approach
- Make `ReasoningBlock` own its timing anchor locally.
- Capture the first render where that reasoning row is live.
- Use that captured timestamp for the live `ElapsedTime` display.
- Snapshot the final duration when the row transitions from `streaming`
to `completed`.
- Remove the misleading parent `timestamp` prop from the reasoning block
API.
Rows that mount already completed still render as bare `Thought`,
because the UI does not know their true start/end duration.
## Key Invariants
- A reasoning block’s elapsed time is scoped to that block, not the
whole run.
- Later reasoning blocks must not inherit time spent in previous
thinking, text, or tool-call sections.
- Historical/completed reasoning rows should not invent durations from
incomplete client-side timing data.
- The parent response timestamp remains available for response-level
metadata, but not for per-reasoning timing.
## Non-goals
- This does not persist reasoning start/end timestamps in the backend
schema.
- This does not change response-level `✓ done in …` timing.
- This does not alter reasoning ordering, markdown rendering, or
redacted reasoning behavior.
## Trade-offs
This uses the client-observed first-live-render time rather than a
persisted provider/server timestamp. That is intentionally scoped: it
fixes the live UI inflation bug without adding schema or event-model
changes. Historical rows still avoid showing made-up durations.
## Verification
```bash
cd packages/agents-server-ui
pnpm test src/components/ReasoningSection.test.tsx
pnpm typecheck
```
Also validated changeset coverage:
```bash
GITHUB_BASE_REF=main node scripts/check-changeset.mjs
```
## Files changed
- `.changeset/fix-reasoning-timers.md`
- Adds a patch changeset for `@electric-ax/agents-server-ui`.
- `packages/agents-server-ui/src/components/AgentResponse.tsx`
- Stops passing the parent run timestamp into `ReasoningBlock`.
- `packages/agents-server-ui/src/components/ReasoningSection.tsx`
- Captures per-reasoning-row live start time.
- Uses that local start time for live and settled reasoning duration
labels.
- Removes the `timestamp` prop from `ReasoningBlock`.
- `packages/agents-server-ui/src/components/ReasoningSection.test.tsx`
- Adds regression coverage proving live reasoning timers do not start
from the run timestamp.
- Adds client-rendered coverage for the live → completed transition
producing `Thought for Ns`.1 parent c14a886 commit 06a60fa
4 files changed
Lines changed: 111 additions & 19 deletions
File tree
- .changeset
- packages/agents-server-ui/src/components
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
669 | | - | |
670 | 669 | | |
671 | 670 | | |
672 | 671 | | |
| |||
Lines changed: 92 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
Lines changed: 14 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | 66 | | |
68 | 67 | | |
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
72 | | - | |
73 | 71 | | |
74 | 72 | | |
75 | 73 | | |
| |||
79 | 77 | | |
80 | 78 | | |
81 | 79 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
91 | 88 | | |
92 | 89 | | |
93 | 90 | | |
94 | 91 | | |
95 | | - | |
96 | | - | |
| 92 | + | |
97 | 93 | | |
98 | 94 | | |
99 | | - | |
| 95 | + | |
100 | 96 | | |
101 | | - | |
| 97 | + | |
102 | 98 | | |
103 | 99 | | |
104 | 100 | | |
| |||
126 | 122 | | |
127 | 123 | | |
128 | 124 | | |
129 | | - | |
| 125 | + | |
130 | 126 | | |
131 | 127 | | |
132 | 128 | | |
133 | 129 | | |
134 | | - | |
| 130 | + | |
135 | 131 | | |
136 | 132 | | |
137 | 133 | | |
| |||
0 commit comments