Skip to content

Commit 65ff1e3

Browse files
adriangbclaude
andcommitted
Fix snapshot tests for gen_ai.conversation.id attribute
Use IsStr() matcher for non-deterministic ULID-based conversation IDs in span attribute snapshots. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e3007e3 commit 65ff1e3

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

tests/models/test_fallback.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ def test_first_failed_instrumented(capfire: CaptureLogfire) -> None:
172172
'thinking': None,
173173
},
174174
'logfire.span_type': 'span',
175+
'gen_ai.agent.name': 'agent',
176+
'gen_ai.conversation.id': IsStr(),
175177
'gen_ai.provider.name': 'function',
176178
'logfire.msg': 'chat fallback:function:failure_response:,function:success_response:',
177179
'gen_ai.system': 'function',
@@ -203,6 +205,7 @@ def test_first_failed_instrumented(capfire: CaptureLogfire) -> None:
203205
'model_name': 'fallback:function:failure_response:,function:success_response:',
204206
'agent_name': 'agent',
205207
'gen_ai.agent.name': 'agent',
208+
'gen_ai.conversation.id': IsStr(),
206209
'logfire.msg': 'agent run',
207210
'logfire.span_type': 'span',
208211
'gen_ai.usage.input_tokens': 51,
@@ -283,6 +286,8 @@ async def test_first_failed_instrumented_stream(capfire: CaptureLogfire) -> None
283286
'thinking': None,
284287
},
285288
'logfire.span_type': 'span',
289+
'gen_ai.agent.name': 'agent',
290+
'gen_ai.conversation.id': IsStr(),
286291
'gen_ai.provider.name': 'function',
287292
'logfire.msg': 'chat fallback:function::failure_response_stream,function::success_response_stream',
288293
'gen_ai.system': 'function',
@@ -314,6 +319,7 @@ async def test_first_failed_instrumented_stream(capfire: CaptureLogfire) -> None
314319
'model_name': 'fallback:function::failure_response_stream,function::success_response_stream',
315320
'agent_name': 'agent',
316321
'gen_ai.agent.name': 'agent',
322+
'gen_ai.conversation.id': IsStr(),
317323
'logfire.msg': 'agent run',
318324
'logfire.span_type': 'span',
319325
'final_result': 'hello world',
@@ -401,6 +407,8 @@ def test_all_failed_instrumented(capfire: CaptureLogfire) -> None:
401407
},
402408
'logfire.span_type': 'span',
403409
'logfire.msg': 'chat fallback:function:failure_response:,function:failure_response:',
410+
'gen_ai.agent.name': 'agent',
411+
'gen_ai.conversation.id': IsStr(),
404412
'logfire.level_num': 17,
405413
'gen_ai.response.model': 'fallback:function:failure_response:,function:failure_response:',
406414
},
@@ -427,6 +435,7 @@ def test_all_failed_instrumented(capfire: CaptureLogfire) -> None:
427435
'model_name': 'fallback:function:failure_response:,function:failure_response:',
428436
'agent_name': 'agent',
429437
'gen_ai.agent.name': 'agent',
438+
'gen_ai.conversation.id': IsStr(),
430439
'logfire.msg': 'agent run',
431440
'logfire.span_type': 'span',
432441
'logfire.exception.fingerprint': '0000000000000000000000000000000000000000000000000000000000000000',
@@ -894,6 +903,8 @@ def prompted_output_func(_: list[ModelMessage], info: AgentInfo) -> ModelRespons
894903
'thinking': None,
895904
},
896905
'logfire.span_type': 'span',
906+
'gen_ai.agent.name': 'agent',
907+
'gen_ai.conversation.id': IsStr(),
897908
'gen_ai.provider.name': 'function',
898909
'logfire.msg': 'chat fallback:function:tool_output_func:,function:prompted_output_func:',
899910
'gen_ai.system': 'function',
@@ -927,6 +938,7 @@ def prompted_output_func(_: list[ModelMessage], info: AgentInfo) -> ModelRespons
927938
'model_name': 'fallback:function:tool_output_func:,function:prompted_output_func:',
928939
'agent_name': 'agent',
929940
'gen_ai.agent.name': 'agent',
941+
'gen_ai.conversation.id': IsStr(),
930942
'logfire.msg': 'agent run',
931943
'logfire.span_type': 'span',
932944
'gen_ai.usage.input_tokens': 51,

0 commit comments

Comments
 (0)