Skip to content

fix(agent-sessions): count a stamped tool call by the gateway's verdict on the detail page - #1141

Closed
JeremyFunk wants to merge 1 commit into
feat/ingest-usage-bucketsfrom
fix/agent-sessions-dedupe-approval-tool-copies
Closed

JeremyFunk wants to merge 1 commit into
feat/ingest-usage-bucketsfrom
fix/agent-sessions-dedupe-approval-tool-copies

fix(agent-sessions): count a stamped tool call by the gateway's verdi…

7c4c21f
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review completed Sep 29, 2026 in 3m 28s

Confidence 3/5 · 1 issue to address

🟡 Confidence 3/5 · needs attention
F3 stays open: pre-stamp rows still merge on the page and count per span on the list, and no test covers that divergence.
quality 90/100 · 1 warning · tests partial · risk medium

Makes the detail page read a gateway-stamped tool span by maple_ai.tool_call and its failure by maple_ai.error, the same verdicts the list SQL sums, leaving pre-stamp spans on the old rule. The stamped paths now agree side to side, but the page and the list still disagree for spans ingested before the stamps (F3).

  • countedToolCalls counts every gateway-stamped tool span, merging nothing
  • spanFailed reads a stamped span's maple_ai.error alone, before the status check
  • The summary SQL drops the StatusCode fallback for stamped spans, as the page does

Still open from earlier reviews

Fixed since the last review

  • ✅ F2 · Per-turn toolCalls sums to more than the session's totals row
What was checked
  • Stamped spans are tool only when maple_ai.tool_call = '1 (session-turns.ts:70), so the new shortcut cannot count a paused copy
  • The gateway stamps maple_ai.error on every stamped span that failed by status or attribute except a paused copy (apps/ingest/src/ai_session/facts.rs:317), so dropping the status fallback for stamp…
  • ai_trace_index only holds gateway-stamped spans (vendor.id is written with the stamps, ai_session.rs:176), so the list's IsToolCall matches the page for rows materialized after migration 0035

7c4c21f · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple to ask about one.