Commit 5471bda
feat(agent-tracing): rename TraceSession to Trace and support inputs in createTrace (#420)
## Summary
- Rename `TraceSession` → `Trace`, `createSession()` → `createTrace()`,
`CreateSessionOptions` → `CreateTraceOptions` for clearer semantics
- Add `inputs` option to `CreateTraceOptions`, allowing callers to
inject user messages into root run's `inputs` field
- Move config fields (tools, model, mcp_servers, agents, slash_commands,
session_id) from `inputs` to `extra`, aligning with LangGraph convention
where `inputs` only contains user business data
## Changes
- `core/agent-tracing/src/types.ts` - Rename type and add `inputs` field
- `core/agent-tracing/src/ClaudeAgentTracer.ts` - Rename class/method,
merge inputs in `handleInit`, move config fields to `extra`
- `core/agent-tracing/claude.ts` - Update export
- `core/agent-tracing/test/ClaudeAgentTracer.test.ts` - Update all
references + 2 new test cases for inputs
## Root Run structure (before → after)
```diff
// inputs
- tools, model, session_id, mcp_servers, agents, slash_commands
+ {} (empty by default, populated via CreateTraceOptions.inputs)
// extra
metadata: { thread_id },
+ tools, model, session_id, mcp_servers, agents, slash_commands,
apiKeySource, claude_code_version, output_style, permissionMode
```
## Usage
```typescript
const trace = claudeTracer.createTrace({
traceId: ctx.tracer.traceId,
threadId,
inputs: { messages: [{ role: 'user', content: prompt }] },
});
for await (const msg of query({ prompt, options })) {
await trace.processMessage(msg);
}
```
## Test plan
- [x] All 56 existing tests pass
- [x] New test: inputs are merged into root run when provided via
`createTrace`
- [x] New test: config fields are in `extra`, not `inputs`
- [x] New test: no extra inputs when not provided
🤖 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**
* Added support for passing custom inputs during trace initialization to
populate trace configuration.
* **API Changes**
* Renamed `createSession()` method to `createTrace()` for improved
semantic clarity.
* Renamed `CreateSessionOptions` type to `CreateTraceOptions`.
* Enhanced trace initialization options with new `inputs` parameter.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 8a7eacc commit 5471bda
File tree
4 files changed
+107
-55
lines changed- core/agent-tracing
- src
- test
4 files changed
+107
-55
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
| |||
192 | 197 | | |
193 | 198 | | |
194 | 199 | | |
195 | | - | |
| 200 | + | |
196 | 201 | | |
197 | 202 | | |
198 | 203 | | |
| |||
216 | 221 | | |
217 | 222 | | |
218 | 223 | | |
219 | | - | |
220 | | - | |
| 224 | + | |
| 225 | + | |
221 | 226 | | |
222 | 227 | | |
223 | | - | |
| 228 | + | |
| 229 | + | |
224 | 230 | | |
225 | 231 | | |
226 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
227 | 237 | | |
228 | | - | |
| 238 | + | |
229 | 239 | | |
230 | 240 | | |
231 | | - | |
232 | | - | |
| 241 | + | |
| 242 | + | |
233 | 243 | | |
234 | 244 | | |
235 | 245 | | |
236 | 246 | | |
237 | 247 | | |
238 | | - | |
| 248 | + | |
239 | 249 | | |
240 | 250 | | |
241 | 251 | | |
| |||
246 | 256 | | |
247 | 257 | | |
248 | 258 | | |
249 | | - | |
| 259 | + | |
250 | 260 | | |
251 | 261 | | |
252 | 262 | | |
253 | 263 | | |
254 | 264 | | |
255 | 265 | | |
256 | | - | |
257 | | - | |
| 266 | + | |
| 267 | + | |
258 | 268 | | |
259 | | - | |
| 269 | + | |
260 | 270 | | |
261 | 271 | | |
262 | 272 | | |
| |||
322 | 332 | | |
323 | 333 | | |
324 | 334 | | |
325 | | - | |
| 335 | + | |
326 | 336 | | |
327 | 337 | | |
328 | 338 | | |
| |||
332 | 342 | | |
333 | 343 | | |
334 | 344 | | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
| 345 | + | |
343 | 346 | | |
344 | 347 | | |
345 | 348 | | |
| |||
354 | 357 | | |
355 | 358 | | |
356 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
357 | 366 | | |
358 | 367 | | |
359 | 368 | | |
| |||
364 | 373 | | |
365 | 374 | | |
366 | 375 | | |
367 | | - | |
| 376 | + | |
368 | 377 | | |
369 | 378 | | |
370 | 379 | | |
| |||
422 | 431 | | |
423 | 432 | | |
424 | 433 | | |
425 | | - | |
| 434 | + | |
426 | 435 | | |
427 | 436 | | |
428 | 437 | | |
| |||
460 | 469 | | |
461 | 470 | | |
462 | 471 | | |
463 | | - | |
| 472 | + | |
464 | 473 | | |
465 | 474 | | |
466 | 475 | | |
| |||
503 | 512 | | |
504 | 513 | | |
505 | 514 | | |
506 | | - | |
| 515 | + | |
507 | 516 | | |
508 | 517 | | |
509 | 518 | | |
| |||
517 | 526 | | |
518 | 527 | | |
519 | 528 | | |
520 | | - | |
| 529 | + | |
521 | 530 | | |
522 | 531 | | |
523 | 532 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
136 | | - | |
| 135 | + | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
141 | 143 | | |
142 | 144 | | |
143 | 145 | | |
| |||
0 commit comments