feat(ingest): stamp model-call usage buckets and the llm-call marker - #1143
Merged
Merged
Maple Review Bot / Maple / review
succeeded
Sep 29, 2026 in 2m 57s
Confidence 4/5 · No issues found
🟢 Confidence 4/5 · likely safe to merge
The read path (list, detail page and summary SQL) now derives every verdict from the same gateway stamp, and tests cover the stamped and pre-stamp paths.
quality 100/100 · no findings · tests covered · risk medium
This slice makes the Agent Sessions read path follow the ingest gateway's stamps: span usage, cost, classification, failure and tool-call counting all read maple_ai.* on a stamped span, keeping the pre-stamp heuristics for older rows. The changes are consistent between the page, the list and the summary query, and safe to merge.
spanTokenBuckets/spanCostread the gateway'smaple_ai.usage.*on a stamped spanclassifyAiSpan,isLlmCall,spanFailedand the newisCountedToolCallfollow the stamps- The session summary SQL reads stamps for
llmCalls,toolCalls,failed, model and buckets mapAiSpanlifts the stampedmaple_ai.agent.nameintoagentName
Fixed since the last review
- ✅
F1 · Paused tool-call copy still counts as failed on the detail page
What was checked
spanTokenBucketsreturnsundefinedonly when all five gateway buckets are absent, so a stamped agent span reports nothing (session-summary.ts:448)- The gateway writes
maple_ai.tool_call0/1 only on a tool call andmaple_ai.llm_callon every stamped span (apps/ingest/src/ai_session/usage.rs:149, facts.rs:350), which is whatisCountedToolCall… - Counts, tool findings and read coverage all go through
isCountedToolCall; the summary'sinputTokens/outputTokenssum to the same total as the page's buckets
fb0e9c8 · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple to ask about one.
Loading