File tree Expand file tree Collapse file tree
tests/integrations/langchain Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -641,6 +641,13 @@ def on_tool_start(
641641 SPANDATA .GEN_AI_AGENT_NAME , agent_metadata ["lc_agent_name" ]
642642 )
643643
644+ run_name = kwargs .get ("name" )
645+ if run_name :
646+ span .set_data (
647+ SPANDATA .GEN_AI_FUNCTION_ID ,
648+ run_name ,
649+ )
650+
644651 if should_send_default_pii () and self .include_prompts :
645652 set_data_normalized (
646653 span ,
Original file line number Diff line number Diff line change @@ -233,6 +233,33 @@ def test_langchain_chat_with_run_name(
233233 assert chat_spans [0 ]["data" ][SPANDATA .GEN_AI_FUNCTION_ID ] == "my-snazzy-pipeline"
234234
235235
236+ def test_langchain_tool_call_with_run_name (
237+ sentry_init ,
238+ capture_events ,
239+ ):
240+ sentry_init (
241+ integrations = [
242+ LangchainIntegration (
243+ include_prompts = True ,
244+ )
245+ ],
246+ traces_sample_rate = 1.0 ,
247+ send_default_pii = True ,
248+ )
249+ events = capture_events ()
250+
251+ with start_transaction ():
252+ get_word_length .invoke (
253+ {"word" : "eudca" },
254+ config = {"run_name" : "my-snazzy-pipeline" },
255+ )
256+
257+ tx = events [0 ]
258+ tool_spans = list (x for x in tx ["spans" ] if x ["op" ] == "gen_ai.execute_tool" )
259+ assert len (tool_spans ) == 1
260+ assert tool_spans [0 ]["data" ][SPANDATA .GEN_AI_FUNCTION_ID ] == "my-snazzy-pipeline"
261+
262+
236263@pytest .mark .skipif (
237264 LANGCHAIN_VERSION < (1 ,),
238265 reason = "LangChain 1.0+ required (ONE AGENT refactor)" ,
You can’t perform that action at this time.
0 commit comments