Skip to content

fix(roadmap): keep tool events in the trace of a long run - #4436

Merged
dan-petty merged 2 commits into
mainfrom
fix/4393-keep-tool-events-in-long-run-trace
Nov 11, 2026
Merged

dan-petty merged 2 commits into
mainfrom
fix/4393-keep-tool-events-in-long-run-trace

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The trace of a long implement run kept only model events, so a reader could not see the tool calls and the checks of a run that stopped. The step added the model events of a turn after the turn, and the bound dropped the oldest events first. Now the step adds a model event when its reply comes, so the events stand in the order of the run. When the trace does not fit CONST_ROADMAP_IMPLEMENT_TRACE_CHARS, it drops the oldest model events first and only then the oldest other events. The tool, check, retry and attempt events show what the run did, and implement.spend keeps the tokens of the run. A shell call holds the exit status of its command, and explain --trace shows it. An event holds no argument, no output and no secret.

Closes #4393

Change: openspec/changes/archive/2026-11-10-4393-keep-tool-events-in-the-trace/

The step added the model events of a turn after the turn, and the bound of the trace dropped the oldest events first, so a long run lost all its tool and check events. A model event now stands where its reply came, and the bound drops the oldest model events before any other event. A shell call holds its exit status. Part of #4393.
@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 marked this pull request as ready for review November 11, 2026 00:31
@dan-petty
dan-petty merged commit 50839d7 into main Nov 11, 2026
32 checks passed
@dan-petty
dan-petty deleted the fix/4393-keep-tool-events-in-long-run-trace branch November 11, 2026 00:31
dan-petty pushed a commit that referenced this pull request Nov 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.109.1](v0.109.0...v0.109.1)
(2026-11-11)


### Bug Fixes

* **roadmap:** keep tool events in the trace of a long run
([#4436](#4436))
([50839d7](50839d7))

---
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>
@dan-petty

Copy link
Copy Markdown
Owner Author

Test results and measure (#4393)

This comment records the evidence of the change. The owner merged it at 2026-11-11 00:31 UTC, before the work posted this comment.

Fail-to-pass

uv run devops ci fail-to-pass --base origin/main (base 1ca0133, head 776d32c): 7 tests fail on the base and pass on the head. 59 other tests pass on both. 0 errors. Scope: tests/roadmap/implement/test_roadmap_implement_step_trace.py, tests/roadmap/implement/test_roadmap_implement_trace.py, tests/roadmap/test_roadmap_explain.py.

Test that fails on the base Failure on the base
test_roadmap_implement_trace::test_the_bound_drops_the_oldest_model_events_before_any_other_event the bound dropped the tool and check events
test_roadmap_implement_trace::test_the_bound_drops_the_oldest_other_events_when_no_model_event_is_left model events stayed, tool events went
test_roadmap_implement_step_trace::test_the_events_of_a_run_are_in_the_order_of_the_run kinds were tool, tool, tool, model, ..., not model, tool, model, ...
test_roadmap_implement_step_trace::test_a_long_run_keeps_its_tool_events_in_the_trace the encoded trace held only model events
test_roadmap_implement_step_trace::test_a_shell_call_has_the_exit_status_that_the_shell_reports[zero] None == 0
test_roadmap_implement_step_trace::test_a_shell_call_has_the_exit_status_that_the_shell_reports[failed] None == 128
test_roadmap_explain::test_a_shell_call_with_an_exit_status_shows_it_in_the_line no exit status in the line

Full local CI

flock .data/agent/ci.lock uv run devops ci on the branch (2026-11-10 17:05 UTC): 22,431 passed, 2 skipped. The only failures are 4 failures and 4 errors in tests/commands/test_scan.py (a host tool path or a process edge with no fake). These are known and not related: #4288, #4321. All GitHub checks of this pull request passed.

Before and after: a synthetic long run

The script makes the events of a run with ImplementTrace and encodes them with the bound of 8,192 characters. "Base" adds the model events of the turn after the turn, as _trace_replies did. "Order fix only" adds a model event when its reply comes and keeps the old bound. "This change" is the order fix and the bound that drops the oldest model events first.

Run Version Events Encoded characters dropped Kept events by kind
100 requests, 150 shell calls, 1 attempt Base 251 8,168 183 model 67, attempt 1, tool 0
100 requests, 150 shell calls, 1 attempt Order fix only 251 8,086 183 model 26, tool 41, attempt 1
100 requests, 150 shell calls, 1 attempt This change 251 8,151 182 tool 68, attempt 1
200 requests, 3 tool calls, 2 checks, 1 attempt Base 206 8,168 138 model 67, attempt 1, tool 0, check 0
200 requests, 3 tool calls, 2 checks, 1 attempt Order fix only 206 8,168 138 model 67, attempt 1, tool 0, check 0
200 requests, 3 tool calls, 2 checks, 1 attempt This change 206 8,098 138 tool 3, check 2, model 62, attempt 1

The base result is the same as the failure in the issue: devops roadmap explain 3443 --trace showed 66 model events, 1 attempt event and no tool or check event. With this change, every tool, check, retry and attempt event stays before the bound drops any of them, the kept events stay in the order of the run, and each kept model event keeps its tokens. The events hold counts, digests, names, outcomes and exit statuses only: no argument, no output and no secret.

Gap after the merge

The acceptance criterion "Render tool and check details" of #4393 also asks that explain --trace shows the digest of the argument of a tool call. The trace holds the digest, but the line does not show it. A check of the merged change against the criteria found this after the merge. It is filed as #4444.

@dan-petty

Copy link
Copy Markdown
Owner Author

Review of this pull request after the merge. The pull request is merged, so no commit goes to its branch. Each finding is filed as an issue.

Severity Finding Check Action
blocking explain --trace does not show the argument digest of a tool event. The criterion "Render tool and check details" of #4393 is not delivered, but this pull request closed #4393. Confirmed on main at 6cf78e73. tool_call keeps the field digest. _event_line in src/devops_cli/roadmap/explain.py does not read it, and explain_trace_tool in src/devops_cli/lang/en/messages.py has no digest part. The open issue #4444 already covers it. I added a comment to #4444 with the evidence and the correct field name (digest, not argument_digest). No new issue.
major The bound now drops model events first, so explain and explain --json report 0 tokens and 0 seconds for a long run. trace_totals adds only the model events that the trace keeps. Confirmed on main. A trace of 100 model events (20,000 and 300 tokens, 4 s each), 150 shell calls and 1 attempt gives tokens_total=2030000, seconds_total=400.0 in full and tokens_total=0, seconds_total=0, dropped=180 after encode and decode. The decoded trace keeps 70 tool events, 1 attempt event and no model event. The encode before this pull request kept 79 model events (1,603,700 tokens, 316 s). No matching issue existed. Filed as #4457 with devops roadmap intake.

The task gave no minor findings.

No code changed, so no fail-to-pass run applies.

dan-petty added a commit that referenced this pull request Nov 11, 2026
The trace of an implement run holds the digest of the argument of each
tool call, but devops roadmap explain --trace did not show it. So a
reader could not see that the model made the same call two or more
times. Issue #4393 asked for this, and #4436 left it out. Now the line
of a tool event shows the digest after the program, as in `group 1: tool
shell (program git) [argument abc123abc123], ok (exit status 0)`. A tool
event with no digest shows no argument part, so an older trace still
prints. The digest is 12 hexadecimal characters of the SHA-256 of the
masked argument, so the line holds no argument and no secret.

Closes #4444

Change:
`openspec/changes/archive/2026-11-11-4444-explain-trace-shows-the-argument-digest/`
dan-petty added a commit that referenced this pull request Nov 11, 2026
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/`
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): keep tool events in the trace of a long run

1 participant