Skip to content

Commit 3c1bde0

Browse files
authored
fix: anthropic response data should include tool call id (#1636)
1 parent 906a34f commit 3c1bde0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

logfire/_internal/integrations/llm_providers/anthropic.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,11 @@ def on_response(response: ResponseT, span: LogfireSpan) -> ResponseT:
120120
elif block.type == 'tool_use': # pragma: no branch
121121
message.setdefault('tool_calls', []).append(
122122
{
123+
'id': block.id,
123124
'function': {
124125
'arguments': block.model_dump_json(include={'input'}),
125126
'name': block.name,
126-
}
127+
},
127128
}
128129
)
129130
span.set_attribute('response_data', {'message': message, 'usage': response.usage})

tests/otel_integrations/test_anthropic.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,9 @@ def test_tool_messages(instrumented_client: anthropic.Anthropic, exporter: TestE
545545
'response_data': {
546546
'message': {
547547
'role': 'assistant',
548-
'tool_calls': [{'function': {'arguments': '{"input":{"param":"param"}}', 'name': 'tool'}}],
548+
'tool_calls': [
549+
{'id': 'id', 'function': {'arguments': '{"input":{"param":"param"}}', 'name': 'tool'}}
550+
],
549551
},
550552
'usage': IsPartialDict(
551553
{

0 commit comments

Comments
 (0)