Repository navigation
feat(backend): surface toolResult isError, duration, and raw payload - #92
Merged
Merged
Conversation
Pi JSONL already carries isError and per-event timestamps, but the parser dropped both while merging tool results and hardcoded the payload to null. Keep isError, derive per-tool durationMs from the toolCall/toolResult event gap (no duration field exists upstream), and preserve the raw record as payload. First slice of #82 (Trace page ledger refactor): the ledger's status and duration columns need these fields.
This was referenced Aug 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#82 的第一个切片(解析器切片,TDD 先行)。
根因与改动
Pi 的 session JSONL 源数据本就带
isError(每条 toolResult 都有)和逐事件 timestamp,但sessions.ts的tryMergeToolResult在合并时把它们全丢了,payload 还硬编码成null——导致 #82 台账的 ✓/✕ 状态列和时长列无数据可用。修在源头:isError,透传到SessionContentPart。durationMs:上游没有 duration 字段,用 toolCall 所在 assistant 事件与 toolResult 事件的时间戳差值(对真实数据验证过口径)。packages/core/src/session.ts的SessionContentPart相应扩展(可选字段,不破坏现有消费方)。验证
bun run test:63 文件 516 用例全绿;bun run typecheck干净。后续切片:PR 2
pi-trace-ledger组件 + session-detail 替换;PR 3 会话列表台账化 + 整页布局。