Phase 5 Testing: React layer instrumentation #301

Closed
opened 2026-05-18 02:37:55 +00:00 by xiaoju · 0 comments
Owner

验证目标

Reactor 执行过程记录为 react-session/turn/tool-call 节点,替换 Phase 4 的占位符。

前置

Phase 4 完成(#299, PR #300)— 需要在 Phase 4 分支上工作

工作内容

1. Instrument reactor

修改 workflow-reactor 中的 createThreadReactor(或新建 wrapper):

  • 每轮 LLM 调用:存 prompt 为 content 节点,存 response 为 content 节点,组装 react-turn
  • 每次 tool call:存 args 为 content 节点,存 result 为 content 节点,组装 react-tool-call
  • 最终组装 react-session(agent ref, role, turns[], totalTokens, durationMs)

2. 集成到 json-cas-engine

在 json-cas-engine.ts 中,agent 执行后拿到 react-session hash,填入 thread-step 的 react 字段(替换占位符)。

测试步骤

  • Step 1: 无 tool call 的简单 session
    单轮 LLM 调用 → react-session 含 1 个 turn,0 个 tool-calls

  • Step 2: 含 tool call 的 session
    LLM 返回 tool call → 执行 → 再调 LLM → react-session 含 2 个 turns,turn[0] 有 tool-calls

  • Step 3: content 节点正确
    react-turn 的 input/output content 节点文本正确

  • Step 4: tool-call 节点正确
    react-tool-call 的 arguments/result content 节点正确

  • Step 5: tokens 和 duration 合理
    react-session.totalTokens > 0, durationMs > 0

  • Step 6: walk 从 thread-step 到 react 完整
    从 thread-step → react-session → turns → tool-calls → content 全部可达

验证完成标准

所有 checkbox 打勾
bun test 全过

Ref: #294

## 验证目标 Reactor 执行过程记录为 react-session/turn/tool-call 节点,替换 Phase 4 的占位符。 ## 前置 Phase 4 完成(#299, PR #300)— 需要在 Phase 4 分支上工作 ## 工作内容 ### 1. Instrument reactor 修改 workflow-reactor 中的 createThreadReactor(或新建 wrapper): - 每轮 LLM 调用:存 prompt 为 content 节点,存 response 为 content 节点,组装 react-turn - 每次 tool call:存 args 为 content 节点,存 result 为 content 节点,组装 react-tool-call - 最终组装 react-session(agent ref, role, turns[], totalTokens, durationMs) ### 2. 集成到 json-cas-engine 在 json-cas-engine.ts 中,agent 执行后拿到 react-session hash,填入 thread-step 的 react 字段(替换占位符)。 ## 测试步骤 - [ ] **Step 1: 无 tool call 的简单 session** 单轮 LLM 调用 → react-session 含 1 个 turn,0 个 tool-calls - [ ] **Step 2: 含 tool call 的 session** LLM 返回 tool call → 执行 → 再调 LLM → react-session 含 2 个 turns,turn[0] 有 tool-calls - [ ] **Step 3: content 节点正确** react-turn 的 input/output content 节点文本正确 - [ ] **Step 4: tool-call 节点正确** react-tool-call 的 arguments/result content 节点正确 - [ ] **Step 5: tokens 和 duration 合理** react-session.totalTokens > 0, durationMs > 0 - [ ] **Step 6: walk 从 thread-step 到 react 完整** 从 thread-step → react-session → turns → tool-calls → content 全部可达 ## 验证完成标准 ✅ 所有 checkbox 打勾 ✅ `bun test` 全过 Ref: #294
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#301