Skip to content

fix(roadmap): the trace gate reads only the last run #4257

Closed

Description

@dan-petty

Problem

The trace gate of the stage job compares the Feasibility claims of a plan with the tool calls of only the last agent run. After the one return of a refused reply, the planner makes a second run. The second run often calls no tool, because the plan already holds the facts. A claim that the first run made true is then refused.

Evidence: the live run of the stage job on item #4062 (2026-11-09, model Sonnet) ended with two refusals of the trace gate: "The Feasibility section names the tool read_issue, but the run did not call it." and the same for find_issues. They came with the content and citation refusals, so the plan was returned once.

Where: _Planner._trace_facts in src/devops_cli/roadmap/stage/stage.py returns TraceFacts.of(traces[-1]). ToolboxClient.chat_structured appends a new RunTrace for each planner run and each review run to the one shared list. So after a return, traces[-1] is the run of the return, and the calls of the first run are dropped. The same holds for each repair round of the review (_repaired). I read the code to check the cause; I did not run the model again.

Expected

The facts for a reply are the facts of all planner runs of the item so far (the first run and each return). The runs of the review are not planner runs: a read of the reviewer does not support a claim of the planner.

Acceptance criteria

  • A unit test makes a toolbox client that records a read_issue call in its first run and no call in its second run, and a plan whose Feasibility says read_issue returned the issue. The first reply is refused for another reason, so the planner returns it once. The second reply passes the trace gate. Command: uv run devops ci test tests/roadmap/stage/test_roadmap_stage_gates.py. It fails today: the problem says that the run did not call read_issue.
  • A unit test records a read_issue call in a review run only. A plan that claims read_issue is still refused.
  • The golden set of the stage eval still passes. Command: uv run devops roadmap eval stage --replay.

Existing tool considered

RunTrace.combined and TraceFacts.of exist and cover the join of runs. No new library and no new helper.

Cost

  • Tokens to build: low to medium (the planner must tell planner runs from review runs).
  • Tokens to keep and to fix: low.
  • Elapsed time: about 1 hour.

Related

#4204, #4170 (the trace gate), #3529. The spec requirement "Trace facts of a run" in openspec/specs/roadmap-stage/spec.md says "the facts of the run that wrote each reply".

Proposed design

Problem statement

The trace gate of the stage job reads the tool calls of only the last agent run. After a refused reply, the planner makes a second run that often calls no tool. A Feasibility claim that the first run made true is then refused. The gate must read the facts of all planner runs of the item, and never the runs of the review.

Acceptance criteria

Requirement: Facts of all planner runs

The planner SHALL pass to the trace gate the combined facts of every planner run of the item so far.

Scenario: A first run reads the issue and the second run calls no tool

  • WHEN the first run records a read_issue call, the first reply is refused for another reason, the second run records no call, and the Feasibility of the second reply says read_issue returned the issue
  • THEN the trace gate finds no problem for the second reply

Requirement: Review runs give no planner facts

The planner SHALL NOT count a call of a review run as a fact that supports a claim of the planner.

Scenario: Only a review run calls read_issue

  • WHEN a review run records a read_issue call, the planner runs record none, and the plan claims read_issue
  • THEN the trace gate refuses the claim and names read_issue

Requirement: Repair rounds keep the earlier planner facts

The planner SHALL give the gate of each repair round of the review the facts of all planner runs, the repair run included.

Scenario: A repair run calls no tool

  • WHEN the first planner run calls read_issue, a review returns the plan, and the repair run calls no tool and claims read_issue
  • THEN the trace gate finds no problem for the repaired reply

Requirement: Golden set stays green

The change MUST keep the replay of the golden set of the stage eval passing.

Scenario: Replay of the golden set

  • WHEN uv run devops roadmap eval stage --replay runs
  • THEN every case passes as before

Existing Tool Considered

No outside tool covers this. The change is a small fix of the project's own code. RunTrace.combined and TraceFacts.of already join runs and build facts, so no new library and no new helper is needed. Cost: low to medium tokens to build, low to keep, and about 1 hour.

Key questions

  • How does the planner tell planner runs from review runs in the shared trace list?: Mark the position in the shared list. _Planner records each planner run in its own list of traces, or tracks the indexes of the traces that _ask appends. The review traces stay out of that list. The gate then calls TraceFacts.of(RunTrace.combined(planner_traces)). (best practice) [sources: src/devops_cli/roadmap/stage/stage.py, src/devops_cli/roadmap/agent_run.py]
    • Chosen: Record the index range of each planner ask. Only _ask runs a planner run. The planner takes the traces that the call appended, so review runs never enter.
    • Rejected: Add a role field to RunTrace. It changes a shared type that the refine job and the MCP code also use, for a small gain.
    • Rejected: Join all traces and drop the review ones by position at read time. Review runs and planner runs interleave after repair rounds, so position alone is fragile.
  • Does a helper already join runs and build facts?: Yes. RunTrace.combined joins several traces, and TraceFacts.of builds the facts of one trace. The change only chooses which traces to join. [sources: src/devops_cli/roadmap/agent_run.py, src/devops_cli/roadmap/stage/stage.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

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

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. The bug causes false refusals of valid plans, wasting a round trip and tokens, but the system recovers.
    • Value: Medium. It removes false refusals that block valid plans and waste planner tokens on each return.
    • Effort: Low. The body states about 1 hour and notes that RunTrace.combined and TraceFacts.of already exist for the join.
    • Related: fix(roadmap): Refuse Feasibility claims the run did not support #3266, which asks for a different change. Both items work on the trace gate in the stage job, but #3266 created the gate while the candidate fixes its scope to read all planner runs.
  3. added
    priority/p2-medium
    on Nov 9, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 9, 2026
  5. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at d31717d (see proposed design in issue body).

  6. added
    owner/agent
    status/in-review
    and removed
    status/ready
    on Nov 9, 2026
  7. removed
    status/in-review
    owner/agent
    on Nov 9, 2026
  8. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-09 21:51 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/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions