|
9 | 9 | from typing import Any |
10 | 10 |
|
11 | 11 | from weave.integrations.claude_agent_sdk.display_utils import ( |
| 12 | + text_display_name, |
| 13 | + thinking_display_name, |
12 | 14 | tool_use_display_name, |
13 | 15 | turn_display_name, |
14 | 16 | ) |
@@ -66,6 +68,7 @@ def _process_message_inline( |
66 | 68 | from claude_agent_sdk import ( |
67 | 69 | AssistantMessage, |
68 | 70 | SystemMessage, |
| 71 | + TextBlock, |
69 | 72 | ThinkingBlock, |
70 | 73 | ToolResultBlock, |
71 | 74 | ToolUseBlock, |
@@ -104,6 +107,34 @@ def _is_thinking_only(m: Any) -> bool: |
104 | 107 | history = list(accumulated) |
105 | 108 | accumulated.append(serialized) |
106 | 109 |
|
| 110 | + # Create child calls for thinking blocks |
| 111 | + thinking_blocks = [b for b in msg.content if isinstance(b, ThinkingBlock)] |
| 112 | + if thinking_blocks: |
| 113 | + thinking_text = "\n".join(b.thinking for b in thinking_blocks) |
| 114 | + thinking_call = wc.create_call( |
| 115 | + op="claude_agent_sdk.thinking", |
| 116 | + inputs={}, |
| 117 | + display_name=thinking_display_name(thinking_text), |
| 118 | + parent=root_call, |
| 119 | + attributes={"kind": "llm"}, |
| 120 | + use_stack=False, |
| 121 | + ) |
| 122 | + wc.finish_call(thinking_call, output={"thinking": thinking_text}) |
| 123 | + |
| 124 | + # Create child calls for text blocks |
| 125 | + text_blocks = [b for b in msg.content if isinstance(b, TextBlock)] |
| 126 | + if text_blocks: |
| 127 | + text_content = "\n".join(b.text for b in text_blocks) |
| 128 | + text_call = wc.create_call( |
| 129 | + op="claude_agent_sdk.text", |
| 130 | + inputs={}, |
| 131 | + display_name=text_display_name(text_content), |
| 132 | + parent=root_call, |
| 133 | + attributes={"kind": "llm"}, |
| 134 | + use_stack=False, |
| 135 | + ) |
| 136 | + wc.finish_call(text_call, output={"text": text_content, "model": msg.model}) |
| 137 | + |
107 | 138 | tool_uses = [b for b in msg.content if isinstance(b, ToolUseBlock)] |
108 | 139 |
|
109 | 140 | # Open tool calls |
|
0 commit comments