fix(agent-sessions): decode tool-error payloads the way the session page does - #1148
Confidence 3/5 · 1 issue to address
🟡 Confidence 3/5 · needs attention
The query-engine source diffs were read at the head rather than as diffs, so only their final state was verified; the three test files I read as diffs are consistent with it.
quality 90/100 · 1 warning · tests covered · risk medium · 1/1 new units observable
Warning
This review ended early; what follows is what it established.
The tool-error payload path now hands back the span's attribute map (cut, with the true sizes of the values cut) and decodes arguments/result in TypeScript through aiToolCallPayload, instead of projecting a fixed pair of attribute keys in SQL — so the modal and MCP tool read a tool span the way the session page does. The read stays org-scoped and bounded by the page's own extent, and the three test files were updated to the new row shape.
aiToolErrorPayloadsQueryreturnsspanAttributespluscutAttributeBytesinstead ofarguments/resultaiToolErrorPayloaddecodes the payload withaiToolCallPayloadand truncates it by codepoint- The payload read is bound by the page's own first and last timestamps, not the caller's window
Still open from earlier reviews
- 🟠 Warning · F1 ·
aiToolErrorPayloadsQueryships each sampled span's full uncapped payload map ·packages/query-engine-integrations/src/ai/ai-tools.ts:973
What was checked
- Read stays org-scoped:
$.OrgId.eq(param.string("orgId"))and a(TraceId, SpanId)tupleIN, no subquery (ai-tools.ts:1017) aiToolErrorPayloadSlicetakes min/max of the page's own timestamps, so the extent never widens (ai-tools.ts:1085)truncatePayloadcuts withArray.from, so a cut never splits a codepoint (ai-tools.ts:1049)
Observability coverage: 1 of 1 changes observable
| Change | Kind | Observable | Evidence |
|---|---|---|---|
| aiToolErrorPayloadsQuery — the second warehouse read of the error-samples modal | database read | yes | runs through warehouse.compiledQuery with profile "list" and context "aiToolsErrorPayloads" (ai-session-reads.ts:740-751) |
7525624 · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.