Commit 130ff53
fix(timing): claude-code's windows tile across a tool result
`on_user_message` reset the generation mark to `self.clock.now()`, so the
next window opened when the tool RESULT arrived instead of tiling from the
previous emission's close. Everything in between — SDK transport, CLI
processing, next-request dispatch — fell into no bucket at all, and the
four-bucket identity stopped closing.
The live stream delivers TWO user messages per tool call, and the mark was
reset on each, so the window opened at the LAST one. Traced on
`tasks/dataset_example.yaml`:
msg2 (issues the Write) closes 27.773889 -> 28.067824
user message #1 28.080804 <- mark reset here
user message #2 30.009645 <- and again, 1.93s later
msg3 window opened at 30.009645 (should be 28.067824)
1.94 s lost from an 11.7 s turn. CI's residual gate has been failing on
exactly these two rows (16.668% and 16.325% on the runner, 21-28% locally).
Same task after the fix: 0.02%, worst turn 4.5 ms — the known
`turn_start_time`-vs-`AgentStartEvent` baseline and nothing else.
The tool's own interval is not double-counted: it is a separate bucket and
`subtract_tool_time` clips the tool union out of every window it overlaps,
once, for all five harnesses. That central subtraction is precisely what
lets the reducer leave its mark alone — the same rule pi follows with
`gen_mark`, and the one pi was explicitly fixed for.
WHY THIS SURVIVED, which is worth more than the one-line fix. Three ways to
write a test for it cannot fail, and I wrote two of them before getting one
that does:
1. A tool-heavy shape. Three concurrent `sleep 3` calls make the tool
union absorb the interval; every live probe I ran read 0.05% and I
concluded the harness was healthy. The defect needs a FAST tool.
2. A single tool result. claude-code reconstructs `execution_started_at`
by subtracting the measured duration from the resolve instant, so with
one message the discarded interval and the tool's own span are the
SAME milliseconds — `subtract_tool_time` removes them either way and
the identity closes with or without the bug. This is why the existing
`_claude_turn` case passed throughout.
3. A duplicate tool RESULT as the second message. That re-resolves the
call and stretches the tool span over the very interval being probed.
`test_a_slow_tool_result_round_trip_is_not_lost` scripts the shape that
discriminates: a 20 ms tool, then a second user message carrying no tool
result 2 s later. Mutation-checked — restoring the reset fails that case by
exactly -2000 ms and leaves the other seven green, which is the production
situation reproduced in the suite.
No golden regeneration: `_scrub.py::SCRUB_KEYS` masks every timing value, so
the corpus cannot see this class of change. That is a known property of the
goldens, not an oversight, and it is the reason the ms-exact identity
contract exists alongside them.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FpDo37ypvLjLiWXFsEkg6k1 parent 9202699 commit 130ff53
3 files changed
Lines changed: 158 additions & 6 deletions
File tree
- docs/agents
- src/coder_eval/agents
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
265 | 288 | | |
266 | 289 | | |
267 | 290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
597 | 597 | | |
598 | 598 | | |
599 | 599 | | |
600 | | - | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
601 | 622 | | |
602 | 623 | | |
603 | 624 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
457 | 463 | | |
458 | 464 | | |
459 | 465 | | |
| |||
517 | 523 | | |
518 | 524 | | |
519 | 525 | | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
520 | 618 | | |
521 | 619 | | |
522 | 620 | | |
| |||
542 | 640 | | |
543 | 641 | | |
544 | 642 | | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
545 | 653 | | |
546 | 654 | | |
547 | 655 | | |
| |||
0 commit comments