Skip to content

Commit 3d89081

Browse files
committed
agent name
1 parent 6cf6f9d commit 3d89081

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sentry_sdk/integrations/langchain.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,11 @@ def new_stream(self, *args, **kwargs):
778778
return f(self, *args, **kwargs)
779779

780780
try:
781-
agent_name = self.agent.runnable.config.get("run_name")
781+
agent_name = None
782+
if len(args) > 1:
783+
agent_name = args[1].get("run_name")
784+
if agent_name is None:
785+
agent_name = self.agent.runnable.config.get("run_name")
782786
except Exception:
783787
agent_name = ""
784788

@@ -793,6 +797,9 @@ def new_stream(self, *args, **kwargs):
793797
span.set_data(SPANDATA.GEN_AI_OPERATION_NAME, "invoke_agent")
794798
span.set_data(SPANDATA.GEN_AI_RESPONSE_STREAMING, True)
795799

800+
if agent_name != "":
801+
span.set_data(SPANDATA.GEN_AI_AGENT_NAME, agent_name)
802+
796803
input = args[0].get("input") if len(args) > 1 else None
797804
if input is not None:
798805
set_data_normalized(

0 commit comments

Comments
 (0)