feat(agent-tracing): collect assistant messages into root run outputs#421
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughCollect assistant content blocks per-trace by adding an Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces the collection of assistant text messages into the outputs.messages field of the root run within the ClaudeAgentTracer. This is achieved by tracking text content during message processing and updating the root run's outputs upon completion. Corresponding tests were added to ensure correct message aggregation. Feedback suggests improving type safety by narrowing the role property to a literal type and using type guards instead of type assertions when filtering content.
Automatically collect complete assistant messages (text + tool_use) during message processing and include them as outputs.messages in the root run, aligning with LangGraph convention where outputs contain business data (messages). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
78685ea to
b5df79a
Compare
Summary
outputs.messagesoutputscontains business data (messages)Changes
core/agent-tracing/src/ClaudeAgentTracer.tsoutputMessagesarray toTraceclass to accumulate assistant texthandleAssistantmessagesin root runoutputsinhandleResultcore/agent-tracing/test/ClaudeAgentTracer.test.tsoutputs.messagesRoot Run outputs (before → after)
outputs: { + messages: [{ role: 'assistant', content: '...' }, ...], result: '...', is_error: false, num_turns: 1, llmOutput: { promptTokens, completionTokens, ... }, }Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests