← Back to Pull requests

feat(results): record model turns separately from tool calls #10

Closed
unknown closed this pull request without merging on Aug 24, 2026 21:14 UTC
View on GitHub
unknown unknown commented on Aug 24, 2026 18:23 UTC
Author

feat(results): record model turns separately from tool calls

toolCalls was standing in for how many times the model was called, and
those are not the same number. A live openclaw run just now returned
model_turns=2 against tool_calls=1: one message issued the shell call
and a second, text-only turn wrote the answer. The reverse happens too —
an earlier run had a single assistant.message carrying two toolCall
entries.

The distinction matters because an agentic loop re-sends the whole
conversation every turn, so input tokens grow with turns, not with tool
calls. Cost-per-turn read off toolCalls is wrong by that factor, and a
model that batches its calls looks identical to one that serializes them.

Sources, per harness:

  • openclaw: count assistant.message events in the trajectory export.

  • parse_trajectory_export now returns a TrajectoryExport NamedTuple so
    the extra field does not turn the return into an anonymous 5-tuple.
  • antigravity: the conversation DB already decoded one usage record per

  • round-trip; db_token_state now returns that count alongside the
    tokens, as a DbTokenState NamedTuple.
  • gemini_cli: left None. Its stream is delta messages with no clean turn

  • boundary, and guessing one would put a fabricated number next to two
    measured ones.

    Unreported stays None, never 0 — a run that produced output cannot
    have taken zero round-trips, so 0 would be a parse miss dragging down a
    dashboard average. _positive_int_or_none also rejects bools, since
    True is an int in Python and would otherwise normalize to one turn.

    Validated live against openclaw (gemini-3-flash-preview): model_turns=2,
    tool_calls=1, clean terminal reason. Antigravity could not complete a
    live turn on this host (project permission denied), so its path is covered
    by unit tests over proto blobs captured from a real DB.

    Diff: 233 lines (+174 / -59) across 2 files Reviewer: eugeneng04 Review duration: 170m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 233 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.326
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #10"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 37.1% (MEDIUM) · Higher = larger blast radius
    37.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.6% · Safe to merge
    14.6%