Skip to content

fix(roadmap): avoid tool concurrency race in step trace digest test #7044

Done

Description

@dan-petty

Problem Description

tests/roadmap/implement/test_roadmap_implement_step_trace.py:183 (test_the_same_call_twice_has_one_digest_and_no_event_holds_the_command) passes tool_calls(same, same, other) in one model reply (tests/roadmap/implement/test_roadmap_implement_step_trace.py:193), then asserts exact positional order assert digests[0] == digests[1] != digests[2] (tests/roadmap/implement/test_roadmap_implement_step_trace.py:198).

Because pydantic_ai executes tool calls of a single reply concurrently and _note appends TraceEventKind.TOOL (src/devops_cli/roadmap/implement/implement_step.py:494) after each call awaits LocalWorkspaceBackend.run, other (8493027a96ad) can complete before the second same (2e20f17b55e7), ordering digests as ['2e20f17b55e7', '8493027a96ad', '2e20f17b55e7'].

Reproduction Steps

  1. Run Tests & Coverage (shard 2 of 5) on PR feat(roadmap): add 67 cases to the implement golden set #7041 (job/138903829621).
  2. Observe tests/roadmap/implement/test_roadmap_implement_step_trace.py:198 fail intermittently when other finishes ahead of the second same.

Expected vs Actual Behavior

Expected: Either the test executes same, same, other in separate turns (tool_calls(same), tool_calls(same), tool_calls(other)), or checks multiset counts (Counter(digests) == {same_digest: 2, other_digest: 1}).
Actual: Positional assertion assert digests[0] == digests[1] != digests[2] fails intermittently with AssertionError: assert '2e20f17b55e7' == '8493027a96ad'.

Environment Diagnostics

  • DevOps CLI Version: 0.211.6 (48998538d)
  • Execution Environment: GitHub Actions runner (Tests & Coverage (shard 2 of 5), job 138903829621)

Logs, Traces, or Terminal Output

Tool call: run_command, started: pytest tests/test_sample.py --flag=<masked>
Tool call: run_command, started: pytest tests/test_sample.py --flag=<masked>
Tool call: run_command, started: pytest tests/other_sentinel.py
FAILED tests/roadmap/implement/test_roadmap_implement_step_trace.py::test_the_same_call_twice_has_one_digest_and_no_event_holds_the_command - AssertionError: assert '2e20f17b55e7' == '8493027a96ad'

Source

Source: #7041

Proposed design

Problem statement

Replace the positional digest assertion in the step trace test with a multiset count. The test sends two identical tool calls and one different tool call in one model reply. pydantic_ai runs the calls at the same time. The completion order changes. The current positional assertion fails intermittently. The multiset assertion keeps the duplicate-call check and removes the order dependency.

Acceptance criteria

Requirement: Multiset digest assertion

The step trace test SHALL compare the tool-call digests as a multiset, not by positional order.

Scenario: Concurrent completion order

  • WHEN I run uv run pytest tests/roadmap/implement/test_roadmap_implement_step_trace.py -k same_call_twice.
  • THEN The command exits 0, and the test counts the same digest twice and the other digest once.

Requirement: No command in trace events

The step trace test MUST keep the assertion that no trace event holds the command.

Scenario: Trace event content

  • WHEN I run uv run pytest tests/roadmap/implement/test_roadmap_implement_step_trace.py -k same_call_twice.
  • THEN The command exits 0, and no trace event holds a command.

Existing Tool Considered

No alternatives check has run. pytest is the open, maintained test runner and covers test execution; it lacks a built-in multiset assertion. The standard-library collections.Counter covers the multiset comparison. The change adds no dependency and no production code.

Key questions

  • How should the test assert the digest of the repeated same call when tool calls run concurrently?: Compare the digests with collections.Counter. Assert two occurrences of the same digest and one occurrence of the other digest. Keep the assertion that no trace event holds the command. (best practice) [sources: tests/roadmap/implement/test_roadmap_implement_step_trace.py:198, src/devops_cli/roadmap/implement/implement_tool_log.py:391]
    • Rejected: Keep the positional digest assertion. The completion order is nondeterministic, so the assertion fails intermittently.
    • Rejected: Run the calls in separate model turns. It removes the concurrent duplicate-call case that the test covers.
    • Chosen: Compare digest counts with Counter. It keeps the concurrent case and makes the assertion independent of completion order.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    source/agent
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 25, 2026
  2. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor
    • Priority: P0-Critical. The test causes intermittent CI failures on the shard 2 job, which meets the P0 criterion of CI failure.
    • Related: fix(roadmap): keep tool events in the trace of a long run #4393, which asks for a different change. Both concern tool events in the implement step trace, but #4393 fixes event retention in the trace encoding while this candidate fixes a flaky test assertion on digest order.
  3. added
    priority/p0-critical
    on Nov 25, 2026
  4. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  5. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 25, 2026
  6. removed
    status/in-review
    on Nov 25, 2026
  7. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-25 04:21 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p0-criticalscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions