Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/strands/telemetry/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def end_model_invoke_span(
[
{
"role": message["role"],
"parts": [{"type": "text", "content": serialize(message["content"])}],
"parts": [{"type": "text", "content": message["content"]}],
"finish_reason": str(stop_reason),
}
]
Expand Down Expand Up @@ -362,7 +362,7 @@ def start_tool_call_span(self, tool: ToolUse, parent_span: Optional[Span] = None
"type": "tool_call",
"name": tool["name"],
"id": tool["toolUseId"],
"arguments": [{"content": serialize(tool["input"])}],
"arguments": [{"content": tool["input"]}],
}
],
}
Expand Down Expand Up @@ -417,7 +417,7 @@ def end_tool_call_span(
{
"type": "tool_call_response",
"id": tool_result.get("toolUseId", ""),
"result": serialize(tool_result.get("content")),
"result": tool_result.get("content"),
}
],
}
Expand Down Expand Up @@ -504,7 +504,7 @@ def end_event_loop_cycle_span(
[
{
"role": tool_result_message["role"],
"parts": [{"type": "text", "content": serialize(tool_result_message["content"])}],
"parts": [{"type": "text", "content": tool_result_message["content"]}],
}
]
)
Expand Down Expand Up @@ -640,11 +640,7 @@ def start_multiagent_span(
self._add_event(
span,
"gen_ai.client.inference.operation.details",
{
"gen_ai.input.messages": serialize(
[{"role": "user", "parts": [{"type": "text", "content": content}]}]
)
},
{"gen_ai.input.messages": serialize([{"role": "user", "parts": [{"type": "text", "content": task}]}])},
)
else:
self._add_event(
Expand Down Expand Up @@ -722,7 +718,7 @@ def _add_event_messages(self, span: Span, messages: Messages) -> None:
input_messages: list = []
for message in messages:
input_messages.append(
{"role": message["role"], "parts": [{"type": "text", "content": serialize(message["content"])}]}
{"role": message["role"], "parts": [{"type": "text", "content": message["content"]}]}
)
self._add_event(
span, "gen_ai.client.inference.operation.details", {"gen_ai.input.messages": serialize(input_messages)}
Expand Down
16 changes: 8 additions & 8 deletions tests/strands/telemetry/test_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def test_start_model_invoke_span_latest_conventions(mock_tracer):
[
{
"role": messages[0]["role"],
"parts": [{"type": "text", "content": serialize(messages[0]["content"])}],
"parts": [{"type": "text", "content": messages[0]["content"]}],
}
]
)
Expand Down Expand Up @@ -249,7 +249,7 @@ def test_end_model_invoke_span_latest_conventions(mock_span):
[
{
"role": "assistant",
"parts": [{"type": "text", "content": serialize(message["content"])}],
"parts": [{"type": "text", "content": message["content"]}],
"finish_reason": "end_turn",
}
]
Expand Down Expand Up @@ -318,7 +318,7 @@ def test_start_tool_call_span_latest_conventions(mock_tracer):
"type": "tool_call",
"name": tool["name"],
"id": tool["toolUseId"],
"arguments": [{"content": serialize(tool["input"])}],
"arguments": [{"content": tool["input"]}],
}
],
}
Expand Down Expand Up @@ -398,7 +398,7 @@ def test_start_swarm_span_with_contentblock_task_latest_conventions(mock_tracer)
"gen_ai.client.inference.operation.details",
attributes={
"gen_ai.input.messages": serialize(
[{"role": "user", "parts": [{"type": "text", "content": '[{"text": "Original Task: foo bar"}]'}]}]
[{"role": "user", "parts": [{"type": "text", "content": [{"text": "Original Task: foo bar"}]}]}]
)
},
)
Expand Down Expand Up @@ -502,7 +502,7 @@ def test_end_tool_call_span_latest_conventions(mock_span):
{
"type": "tool_call_response",
"id": tool_result.get("toolUseId", ""),
"result": serialize(tool_result.get("content")),
"result": tool_result.get("content"),
}
],
}
Expand Down Expand Up @@ -559,7 +559,7 @@ def test_start_event_loop_cycle_span_latest_conventions(mock_tracer):
"gen_ai.client.inference.operation.details",
attributes={
"gen_ai.input.messages": serialize(
[{"role": "user", "parts": [{"type": "text", "content": serialize(messages[0]["content"])}]}]
[{"role": "user", "parts": [{"type": "text", "content": messages[0]["content"]}]}]
)
},
)
Expand Down Expand Up @@ -601,7 +601,7 @@ def test_end_event_loop_cycle_span_latest_conventions(mock_span):
[
{
"role": "assistant",
"parts": [{"type": "text", "content": serialize(tool_result_message["content"])}],
"parts": [{"type": "text", "content": tool_result_message["content"]}],
}
]
)
Expand Down Expand Up @@ -676,7 +676,7 @@ def test_start_agent_span_latest_conventions(mock_tracer):
"gen_ai.client.inference.operation.details",
attributes={
"gen_ai.input.messages": serialize(
[{"role": "user", "parts": [{"type": "text", "content": '[{"text": "test prompt"}]'}]}]
[{"role": "user", "parts": [{"type": "text", "content": [{"text": "test prompt"}]}]}]
)
},
)
Expand Down
Loading