Repository navigation
fix(agent): restore Turn timing in conversation history - #6787
Merged
Merged
Conversation
#6713 removed the event-log transcript index that supplied each history row's Turn timing and left the new projection writing `timing: None`. The Workbench then lost every duration: a running Turn read "Working…" forever and a finished one showed only its activity counts, without "Worked for", "Stopped after" or "Failed after". Timing is now derived from the canonical facts both history sources already hold: a Turn starts at its Run's admission and ends at its RunTerminated fact, whose Terminal gives the outcome. Live history finds that fact through the existing run/kind index; snapshots scan the Run's step-less facts, since their fact_kind column may not be backfilled. The row projection caches the result with the Run source, so a page costs one extra lookup per Run and never replays a Run's facts. The history service tests now assert timing for running, completed and failed Turns and that a frozen snapshot reports the same timing as live history, so dropping it again fails CI. Generated-by: Claude Code (Claude Opus 5.5)
Turn timing describes the whole Turn at the page's fence, not a text offset, but `fragment_metadata` cleared it on every fragment after the first. The Workbench takes each fragment's timing as the row's, so a long answer read from its tail, or extended by later fragments, still lost its duration. Every fragment now keeps it, as before #6713. A snapshot found a Run's termination by decoding each of its step-less facts, which include every executor output delta, so a page could decode a long Run's whole output. Every readable snapshot has passed `ensure_metrics_metadata`, so `fact_kind` is always set; the lookup now seeks `run_terminated` through the existing per-attempt index and decodes one fact. The completed and failed Turn test now also freezes a snapshot after termination and expects the same timing as live history. Generated-by: Claude Code (Claude Opus 5.5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#6713 removed the event-log transcript index that supplied each history row's Turn timing (
platform/event-log/src/transcript/timing.rs) and left the new history projection writingtiming: None. Since then the Workbench has had no Turn boundaries: a running Turn readsWorking…however long it runs, and a finished Turn shows only its activity counts (7 thoughts · 25 tools) instead ofWorked for 5m 12s · …,Stopped after …orFailed after ….Timing is now derived from canonical facts that both history sources already hold. A Turn is one Run: it starts at the Run's admission and ends at its
RunTerminatedfact, whoseTerminalgives the outcome.agent_session_historyrun/kind index.run_terminatedentry through the existingagent_history_snapshot_metrics_attemptindex. Every readable snapshot has passedensure_metrics_metadata, sofact_kindis set.fragment_metadatahad started clearing it after the first fragment, and the Workbench takes each fragment's timing as the row's, so a long answer read from its tail still lost its duration.No new table, index or migration, and the wire contract and the Workbench are unchanged.
Verification
cargo nextest run -p maka-agent-native -E 'test(history_shows_only_the_final_model_failure) | test(named_cell_tools_survive_receipt_only_pages_and_frozen_history)': 2 passed.cargo clippy -p maka-agent-state -p maka-agent-native --tests --no-deps -- -D warningsandcargo fmt --all -- --check: clean.Completed Turn in the native desktop test renderer (
desktop_lists_a_scripts_tool_calls_in_place_of_the_script), 960×640 dark, same tree with the base'splugins/agenton the left and this PR on the right:AI use
Select exactly one:
Tool(s) and scope: Claude Code (Claude Opus 5.5) traced the regression to #6713, implemented the fix and the test assertions, and ran the checks above. An adversarial review by GPT-6.1-Sol (Codex CLI) found the fragment clearing and the snapshot scan, both fixed here. The commits carry a
Generated-bytrailer.Checklist
Does this PR entail a change in behavior?