Skip to content

fix(roadmap): explain totals count dropped model events - #4543

Merged
dan-petty merged 2 commits into
mainfrom
fix/4457-explain-totals-dropped
Nov 11, 2026
Merged

dan-petty merged 2 commits into
mainfrom
fix/4457-explain-totals-dropped

Conversation

@dan-petty

@dan-petty dan-petty commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

devops roadmap explain and explain --json reported 0 tokens and 0 seconds for a long implement run. Since #4436, the bound of the trace drops the oldest model events first, and trace_totals summed only the kept events. Now the encoded trace keeps the sums of the events that the bound drops: dropped_tokens and dropped_seconds for model events, and dropped_repair_rounds and dropped_outcomes for attempt events. decode reads them, a trace with no sum decodes with sums of zero, and trace_totals adds them. One class, TraceSums, makes the sums of the kept and of the dropped events. The sums count toward the bound, and a sum of zero is not written. The line beside the totals says that the totals include the dropped events when the trace holds their sums. For a trace with no dropped sum, such as one from before this change, the line says that the totals leave them out.

Closes #4457

Change: openspec/changes/archive/2026-11-11-4457-explain-totals-count-dropped-model-events/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them labels Nov 11, 2026
@dan-petty

dan-petty commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner Author

Test results and measurements (#4457)

Fail-to-pass

uv run devops ci fail-to-pass --base origin/main (base 7234d718): 10 tests fail on the base and pass on the head. 61 other tests pass on both. 0 errors. Scope: tests/roadmap/implement/test_roadmap_implement_trace.py, tests/roadmap/test_roadmap_explain.py, tests/roadmap/test_roadmap_explain_command.py.

Test that fails on the base Failure on the base
test_roadmap_explain::test_the_totals_of_a_long_run_count_the_events_that_the_bound_dropped (0, 0, 0, {'failed': 1}) != (2030000, 400.0, 0, {'failed': 1})
test_roadmap_explain_command::test_the_json_totals_of_a_long_run_count_the_events_that_the_bound_dropped (0, 0) != (2030000, 400.0)
test_roadmap_explain::test_the_report_names_the_events_that_the_bound_dropped_beside_the_totals the line says that the totals leave the dropped events out
test_roadmap_implement_trace::test_the_bound_keeps_the_tokens_and_the_seconds_of_the_model_events_that_it_drops KeyError: 'dropped_tokens'
test_roadmap_implement_trace::test_the_bound_keeps_the_rounds_and_the_outcomes_of_the_attempts_that_it_drops KeyError: 'dropped_repair_rounds'
test_roadmap_implement_trace::test_a_decoded_trace_keeps_its_dropped_sums_once the encoded value holds only dropped
test_roadmap_implement_trace::test_text_that_is_not_a_trace_raises_one_error (4 new cases) a dropped sum that is not a number did not raise TraceDecodeError

uv run devops ci test of the three files, tests/roadmap/implement/test_roadmap_implement_job_trace.py and tests/roadmap/implement/test_roadmap_implement_step_trace.py on the head: 96 passed. The rebase onto origin/main (5f75d256) had no conflict.

Before and after: the run of the issue

100 model events of 20,000 input tokens, 300 output tokens and 4 seconds, 150 shell calls, and a failed attempt (251 events, bound 8,192 characters).

Version trace_totals(decode(trace.encode())) Kept events Encoded characters
Base 0 tokens, 0 s, dropped 180 tool 70, attempt 1 8,172
This change 2,030,000 tokens, 400.0 s, dropped 181 tool 69, attempt 1 8,107

The full trace gives 2,030,000 tokens and 400.0 s. The sums ("dropped_tokens":2030000,"dropped_seconds":400.0) take the room of one tool event. A decoded trace encodes to the same text again.

Cost of encode

Trace Base This change
The run of the issue, 251 events 2.3 ms 4.9 ms
3,000 requests and 3,000 shell calls, 6,001 events 70 ms 143 ms

The job encodes the trace with each record of a group, with a stop and with the ready mark, so the added time is a few milliseconds for each run.

Overlap

#4526 (#4444) changed the same files and merged before this push. The branch is rebased onto main after #4526 with no conflict. With #4526 merged, this change also says in docs/roadmap/implement.md that the trace keeps the sums of its dropped events. No other open pull request changes these files.

After the merge

No live step. An implement run after the new runner image writes the sums. A trace that the job wrote before has no sums, and explain gives the totals of its kept events, as before.

@dan-petty
dan-petty force-pushed the fix/4457-explain-totals-dropped branch from 4146817 to 045df93 Compare November 11, 2026 07:33
@dan-petty
dan-petty marked this pull request as ready for review November 11, 2026 08:54
@dan-petty
dan-petty marked this pull request as draft November 11, 2026 10:48
The bound of the implement trace drops the oldest model events first, so
the explain totals of a long run were 0 tokens and 0 seconds. The
encoded trace now keeps the sums of the events that the bound drops, and
trace_totals adds them.
@dan-petty
dan-petty force-pushed the fix/4457-explain-totals-dropped branch from 045df93 to d6a1925 Compare November 11, 2026 11:09
@dan-petty

Copy link
Copy Markdown
Owner Author

Review findings (review:explain-digest)

Finding 1 (minor), tests/roadmap/test_roadmap_explain.py: CONFIRMED.
Evidence: on the branch, trace_totals(decode('{"events":[],"dropped":12}')) gave TraceTotals(tokens_total=0, seconds_total=0.0, repair_rounds=0, outcomes={}, dropped=12). The line beside the totals said "12 earlier event(s) are not kept in the trace, and the totals include them." The totals did not include them, because the trace holds no dropped sum. The test asserted this wrong line on such a trace.

What I changed:

  • TraceTotals has the new field dropped_summed. It is True when the trace holds a dropped sum (trace.dropped_sums != TraceSums()).
  • The line says "the totals include them" only when dropped_summed is True. For a trace with no dropped sum, such as one from before fix(roadmap): explain totals count dropped model events #4457, the new message explain_totals_dropped_unsummed says "{count} earlier event(s) are not kept in the trace, and the totals leave them out."
  • Tests: the existing test now records a new trace ("dropped_tokens":100) and asserts the "include them" line. The new test test_the_report_of_a_trace_with_no_dropped_sums_says_that_the_totals_leave_them_out records an old trace and asserts the "leave them out" line.
  • Spec roadmap-explain, requirement "Dropped events beside the totals": the line depends on the dropped sum. A new scenario covers a trace with no dropped sum. I changed the main spec and the archived delta in the archive commit, which stays the last commit. The proposal, the tasks, docs/ROADMAP_WORKFLOW.md and the PR body now say the same.

Note: the encoder does not write a sum of zero. Thus a new trace whose dropped events all have sums of zero also gets the "leave them out" line. The totals are then the same with or without those events, so the line is not wrong.

Checks:

  • uv run devops ci fail-to-pass --base origin/main: 11 tests failed on base. Both dropped-line tests are in that list: test_the_report_names_the_events_that_the_bound_dropped_beside_the_totals and test_the_report_of_a_trace_with_no_dropped_sums_says_that_the_totals_leave_them_out.
  • tests/roadmap/test_roadmap_explain.py, tests/roadmap/test_roadmap_explain_command.py and tests/roadmap/implement/test_roadmap_implement_trace.py: 73 passed. ruff and mypy are clean, and the pre-push hook passed.

@dan-petty
dan-petty marked this pull request as ready for review November 11, 2026 11:21
@dan-petty
dan-petty merged commit fe0e979 into main Nov 11, 2026
34 of 35 checks passed
@dan-petty
dan-petty deleted the fix/4457-explain-totals-dropped branch November 11, 2026 11:55
dan-petty pushed a commit that referenced this pull request Nov 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.112.0](v0.111.0...v0.112.0)
(2026-11-11)


### Features

* **k8s:** export gateway spans without key metadata
([#4520](#4520))
([7234d71](7234d71))
* **k8s:** set the homelab domain in container env values
([#4608](#4608))
([a3bcf7c](a3bcf7c))
* **telemetry:** send pydantic-ai spans through the exporter seam
([#4538](#4538))
([fcf2a7a](fcf2a7a))


### Bug Fixes

* **ai:** price cached prompt tokens of chat calls
([#4584](#4584))
([f84bbe6](f84bbe6))
* **devcontainer:** stop uv noise lines in agent shells
([#4592](#4592))
([9ba375c](9ba375c))
* **k8s:** delete gateway management bodies from spans
([#4551](#4551))
([b835d3c](b835d3c))
* **k8s:** set the kube context and namespace on devops pods
([#4514](#4514))
([9087b39](9087b39))
* **roadmap:** a refused spec after the archive is a plan defect
([#4549](#4549))
([1db29f7](1db29f7))
* **roadmap:** count and log the reason of a left-out stage item
([#4541](#4541))
([5600179](5600179))
* **roadmap:** default the step ceiling to twice the budget
([#4556](#4556))
([1dfb6c8](1dfb6c8))
* **roadmap:** explain --trace shows the argument digest
([#4526](#4526))
([c92195f](c92195f))
* **roadmap:** explain totals count dropped model events
([#4543](#4543))
([fe0e979](fe0e979))
* **roadmap:** give each eval verify run its own report file
([#4534](#4534))
([ad27f2d](ad27f2d))
* **roadmap:** one event loop and a time limit for decide_all
([#4585](#4585))
([ec51e01](ec51e01))
* **roadmap:** scoped updates send requests with no row scope
([#4531](#4531))
([5f75d25](5f75d25))
* **roadmap:** the caller gate reads an added parameter span
([#4548](#4548))
([1ba07c1](1ba07c1))
* **roadmap:** the implement shell waits for its command
([#4536](#4536))
([571e044](571e044))
* **roadmap:** the module-test and caller gates read imports and calls
([#4490](#4490))
([8a22e82](8a22e82))
* **service:** put trace ids on Service JSON log lines
([#4511](#4511))
([0d7a0d2](0d7a0d2))


### Performance Improvements

* **ai:** keep intake embeddings between CLI runs
([#4546](#4546))
([812871e](812871e))
* **roadmap:** intake reads only the issues that changed
([#4552](#4552))
([7dfd155](7dfd155))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(roadmap): explain totals count dropped model events

1 participant