Repository navigation
Commit f14c96a
committed
Announce what is about to happen, so the status line stops guessing
Reported: during the LLM generation the status line said "正在判定 · 已
等待 9s". The label was wrong for the whole generation.
Every event was a record of **finished** work - `decision` carries
latencyMs, `generate` carries token counts. So the UI could only infer
"what is happening now" from "what finished last", and that inference is
wrong for longest exactly where it matters most:
decision(isDone -> finish) label becomes "正在判定"
... two seconds of generation, label still "正在判定" ...
generate label becomes "正在生成回答" (already over)
decision(canDeliver) label becomes "正在判定" (a flash later)
`tool:call` was already emitted before the tool ran, which is why the tool
phase was always right. Decisions and generation were missing their
"starting" half.
## The event
| { type: 'phase'; step: number; kind: 'decide' | 'generate'; id?: string }
`id` carries the decision node, so "which decision is slow" is answerable
from the stream. It deliberately does **not** go into the UI's `EVENT_META`
table: that table describes finished work, and every row in it has a
duration and a lane. A start has neither, and would only add an empty row.
The trace already guards on `EVENT_META`, so the event stays out of the
ledger and the timeline on its own.
In `agent.ts` the eight `record(await decider.decide(...))` call sites are
now one `ask(spec, ctx)` helper, which emits the phase and then records.
`resolveInput` used to receive `decider` and `record` separately, which is
why it could not have announced anything even if someone had remembered -
it receives `ask` now, so there is one way to ask and one place to emit.
The two `generator.generate` calls announce before they run.
## The UI
`setWaiting` did two jobs, and they answer different questions, so they are
two functions now: `setPhase` changes the label (called only by start
signals - `phase` and `tool:call`), `touch` restarts the seconds counter
(called by anything). Only start signals change the label; that is the fix.
The stall threshold is per phase rather than one number for all three.
Hosted Jev is ~390ms per decision while a generation starts at two seconds
and can run for tens; a single 6s both called normal generations slow and
was far too patient with a stuck decision. Now 6s for decisions and tools,
30s for generation - both derived from measured numbers, and the generation
one stays inside the generator's own 60s timeout, which is why the wording
is "longer than usual" and not "failed".
## Verification
Three tests: every `decision` and `generate` must be immediately preceded
by its matching `phase`, and the phase must carry a real node id. In a real
browser, sampling the status line every 120ms, the check that matters is
latency-independent: **while the label says it is generating, the `generate`
event must not have arrived yet** - 11 to 14 samples per run, 0 out of
place. Reverting to the old behaviour fails it.
Two latency-dependent assertions I wrote first were removed: one assumed a
decision never exceeds 5s (the first hosted call took 5.8s) and one assumed
generation exceeds 1.5s (one run took 1.2s). Both were flaky, and a check
that fails on a slow machine is not a check.
Verified: tsc clean, check 44 files, 161/161 tests, demo `agent_done` at
14:1, browser 4/4 across three consecutive runs.1 parent 7ff6a8b commit f14c96a
4 files changed
Lines changed: 212 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
106 | 120 | | |
107 | 121 | | |
108 | 122 | | |
| |||
247 | 261 | | |
248 | 262 | | |
249 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
250 | 285 | | |
251 | 286 | | |
252 | 287 | | |
253 | 288 | | |
254 | 289 | | |
255 | 290 | | |
256 | | - | |
| 291 | + | |
257 | 292 | | |
258 | 293 | | |
259 | 294 | | |
260 | 295 | | |
261 | 296 | | |
262 | 297 | | |
263 | 298 | | |
264 | | - | |
| 299 | + | |
265 | 300 | | |
266 | 301 | | |
267 | 302 | | |
| |||
289 | 324 | | |
290 | 325 | | |
291 | 326 | | |
292 | | - | |
| 327 | + | |
293 | 328 | | |
294 | 329 | | |
295 | 330 | | |
| |||
300 | 335 | | |
301 | 336 | | |
302 | 337 | | |
303 | | - | |
| 338 | + | |
304 | 339 | | |
305 | 340 | | |
306 | 341 | | |
| |||
351 | 386 | | |
352 | 387 | | |
353 | 388 | | |
354 | | - | |
| 389 | + | |
355 | 390 | | |
356 | 391 | | |
357 | 392 | | |
358 | 393 | | |
359 | 394 | | |
360 | 395 | | |
361 | 396 | | |
362 | | - | |
| 397 | + | |
363 | 398 | | |
364 | 399 | | |
365 | 400 | | |
| |||
454 | 489 | | |
455 | 490 | | |
456 | 491 | | |
| 492 | + | |
457 | 493 | | |
458 | 494 | | |
459 | 495 | | |
| |||
484 | 520 | | |
485 | 521 | | |
486 | 522 | | |
487 | | - | |
| 523 | + | |
488 | 524 | | |
489 | 525 | | |
490 | 526 | | |
| |||
493 | 529 | | |
494 | 530 | | |
495 | 531 | | |
| 532 | + | |
496 | 533 | | |
497 | 534 | | |
498 | 535 | | |
| |||
517 | 554 | | |
518 | 555 | | |
519 | 556 | | |
520 | | - | |
| 557 | + | |
521 | 558 | | |
522 | 559 | | |
523 | 560 | | |
| |||
647 | 684 | | |
648 | 685 | | |
649 | 686 | | |
650 | | - | |
| 687 | + | |
651 | 688 | | |
652 | 689 | | |
653 | 690 | | |
654 | 691 | | |
655 | 692 | | |
656 | 693 | | |
657 | | - | |
658 | | - | |
| 694 | + | |
659 | 695 | | |
660 | 696 | | |
661 | 697 | | |
| |||
668 | 704 | | |
669 | 705 | | |
670 | 706 | | |
671 | | - | |
| 707 | + | |
672 | 708 | | |
673 | 709 | | |
674 | 710 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 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 | + | |
38 | 69 | | |
39 | 70 | | |
40 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
785 | 785 | | |
786 | 786 | | |
787 | 787 | | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
422 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
423 | 434 | | |
424 | 435 | | |
425 | 436 | | |
| |||
428 | 439 | | |
429 | 440 | | |
430 | 441 | | |
431 | | - | |
| 442 | + | |
432 | 443 | | |
433 | 444 | | |
434 | 445 | | |
| |||
444 | 455 | | |
445 | 456 | | |
446 | 457 | | |
447 | | - | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
448 | 465 | | |
449 | 466 | | |
| 467 | + | |
450 | 468 | | |
451 | 469 | | |
452 | 470 | | |
453 | 471 | | |
454 | 472 | | |
455 | 473 | | |
456 | 474 | | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
457 | 490 | | |
458 | 491 | | |
459 | 492 | | |
| |||
1100 | 1133 | | |
1101 | 1134 | | |
1102 | 1135 | | |
1103 | | - | |
1104 | | - | |
1105 | | - | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
1106 | 1143 | | |
1107 | 1144 | | |
1108 | 1145 | | |
| |||
0 commit comments