Commit 8dcebaf
feat(agent-tracing): collect assistant messages into root run outputs (#421)
## Summary
- Automatically collect assistant text responses during message
processing into `outputs.messages`
- Aligns with LangGraph convention where root run `outputs` contains
business data (messages)
## Changes
- `core/agent-tracing/src/ClaudeAgentTracer.ts`
- Add `outputMessages` array to `Trace` class to accumulate assistant
text
- Collect text from assistant messages in `handleAssistant`
- Include `messages` in root run `outputs` in `handleResult`
- `core/agent-tracing/test/ClaudeAgentTracer.test.ts`
- New test: multi-turn assistant text collected into `outputs.messages`
- New test: empty messages array when no assistant text
## Root Run outputs (before → after)
```diff
outputs: {
+ messages: [{ role: 'assistant', content: '...' }, ...],
result: '...',
is_error: false,
num_turns: 1,
llmOutput: { promptTokens, completionTokens, ... },
}
```
## Test plan
- [x] All 58 tests pass (56 existing + 2 new)
- [x] Verified locally in chair-sandbox-ai-use project
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Assistant text content is now collected per trace and exposed in trace
outputs as a messages array.
* Mixed content blocks (text and tool-use) are preserved in the recorded
messages.
* **Tests**
* Added tests verifying message collection for multi-part assistant
outputs and the empty messages case when no assistant text appears.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 5471bda commit 8dcebaf
File tree
2 files changed
+56
-0
lines changed- core/agent-tracing
- src
- test
2 files changed
+56
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
90 | 96 | | |
91 | 97 | | |
92 | 98 | | |
| |||
164 | 170 | | |
165 | 171 | | |
166 | 172 | | |
| 173 | + | |
167 | 174 | | |
168 | 175 | | |
169 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
331 | 380 | | |
332 | 381 | | |
333 | 382 | | |
| |||
0 commit comments