Skip to content

feat(backend): surface toolResult isError, duration, and raw payload - #92

Merged
bubbleptr merged 1 commit into
mainfrom
feat/trace-parser-fields-82
Aug 9, 2026
Merged

bubbleptr merged 1 commit into
mainfrom
feat/trace-parser-fields-82

Conversation

@bubbleptr

Copy link
Copy Markdown
Owner

#82 的第一个切片(解析器切片,TDD 先行)。

根因与改动

Pi 的 session JSONL 源数据本就带 isError(每条 toolResult 都有)和逐事件 timestamp,但 sessions.ts 的 tryMergeToolResult 在合并时把它们全丢了,payload 还硬编码成 null——导致 #82 台账的 ✓/✕ 状态列和时长列无数据可用。修在源头:

  • 保留 isError,透传到 SessionContentPart。
  • 推导 durationMs:上游没有 duration 字段,用 toolCall 所在 assistant 事件与 toolResult 事件的时间戳差值(对真实数据验证过口径)。
  • payload 保留原始记录对象,不再置 null。
  • packages/core/src/session.ts 的 SessionContentPart 相应扩展(可选字段,不破坏现有消费方)。

验证

  • 新用例先红后绿:成功/失败两种 toolResult、71ms 与 2500ms 时长推导、payload 结构。
  • 全量 bun run test:63 文件 516 用例全绿;bun run typecheck 干净。

后续切片:PR 2 pi-trace-ledger 组件 + session-detail 替换;PR 3 会话列表台账化 + 整页布局。

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.
@bubbleptr
bubbleptr merged commit 8f0f9cb into main Aug 9, 2026
@bubbleptr
bubbleptr deleted the feat/trace-parser-fields-82 branch August 9, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant