Skip to content

Commit a0cdcef

Browse files
Miyamura80claude
andcommitted
🐛 address PR review feedback: use as_type="tool" for tool observations
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7d07eb7 commit a0cdcef

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

utils/llm/dspy_langfuse.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from dspy.adapters import Image as dspy_Image
55
from dspy.signatures import Signature as dspy_Signature
66
from dspy.utils.callback import BaseCallback
7-
from langfuse import Langfuse, LangfuseGeneration, LangfuseSpan, get_client
7+
from langfuse import Langfuse, LangfuseGeneration, LangfuseTool, get_client
88
from langfuse.types import TraceContext
99
from litellm.cost_calculator import completion_cost
1010
from loguru import logger as log
@@ -61,7 +61,7 @@ def __init__(self, signature: type[dspy_Signature]) -> None:
6161
self.input_field_values = contextvars.ContextVar[dict[str, Any]](
6262
"input_field_values"
6363
)
64-
self.current_tool_span = contextvars.ContextVar[LangfuseSpan | None]("current_tool_span")
64+
self.current_tool_span = contextvars.ContextVar[LangfuseTool | None]("current_tool_span")
6565
# Initialize Langfuse client
6666
self.langfuse: Langfuse = Langfuse()
6767
self.input_field_names = signature.input_fields.keys()
@@ -404,7 +404,7 @@ def on_tool_start( # noqa
404404
trace_context["parent_span_id"] = parent_observation_id
405405
tool_span = self.langfuse.start_observation(
406406
name=f"tool:{tool_name}",
407-
as_type="span",
407+
as_type="tool",
408408
input=tool_args,
409409
trace_context=trace_context,
410410
metadata={

0 commit comments

Comments
 (0)