@@ -1297,65 +1297,6 @@ async def test_invoke_agent_with_instructions(
12971297 assert SPANDATA .GEN_AI_SYSTEM_INSTRUCTIONS not in chat_span ["data" ]
12981298
12991299
1300- @pytest .mark .asyncio
1301- @pytest .mark .parametrize (
1302- "send_default_pii, include_prompts" ,
1303- [
1304- (True , True ),
1305- (True , False ),
1306- (False , True ),
1307- (False , False ),
1308- ],
1309- )
1310- async def test_invoke_agent_streaming_with_instructions (
1311- sentry_init , capture_events , send_default_pii , include_prompts
1312- ):
1313- """
1314- Test that invoke_agent span handles instructions correctly.
1315- """
1316- from pydantic_ai import Agent
1317-
1318- # Create agent with instructions (can be string or list)
1319- agent = Agent (
1320- "test" ,
1321- name = "test_instructions" ,
1322- )
1323-
1324- # Add instructions via _instructions attribute (internal API)
1325- agent ._instructions = ["Instruction 1" , "Instruction 2" ]
1326- agent ._system_prompts = ["System prompt" ]
1327-
1328- sentry_init (
1329- integrations = [PydanticAIIntegration (include_prompts = include_prompts )],
1330- traces_sample_rate = 1.0 ,
1331- send_default_pii = send_default_pii ,
1332- )
1333-
1334- events = capture_events ()
1335-
1336- async with agent .run_stream ("Test input" ) as result :
1337- async for _ in result .stream_output ():
1338- pass
1339-
1340- (transaction ,) = events
1341- spans = transaction ["spans" ]
1342-
1343- # The transaction IS the invoke_agent span, check for messages in chat spans instead
1344- chat_spans = [s for s in spans if s ["op" ] == "gen_ai.chat" ]
1345- assert len (chat_spans ) >= 1
1346-
1347- chat_span = chat_spans [0 ]
1348-
1349- if send_default_pii and include_prompts :
1350- system_instructions = chat_span ["data" ][SPANDATA .GEN_AI_SYSTEM_INSTRUCTIONS ]
1351- assert json .loads (system_instructions ) == [
1352- {"type" : "text" , "content" : "System prompt" },
1353- {"type" : "text" , "content" : "Instruction 1\n Instruction 2" },
1354- ]
1355- else :
1356- assert SPANDATA .GEN_AI_SYSTEM_INSTRUCTIONS not in chat_span ["data" ]
1357-
1358-
13591300@pytest .mark .asyncio
13601301async def test_model_name_extraction_with_callable (sentry_init , capture_events ):
13611302 """
0 commit comments