Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion langfuse/langchain/CallbackHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def _get_error_level_and_status_message(
if any(isinstance(error, t) for t in CONTROL_FLOW_EXCEPTION_TYPES):
return "DEFAULT", str(error) or type(error).__name__

return "ERROR", str(error)
return "ERROR", str(error) or type(error).__name__

def _get_observation_type_from_serialized(
self, serialized: Optional[Dict[str, Any]], callback_type: str, **kwargs: Any
Expand Down
26 changes: 26 additions & 0 deletions tests/unit/test_langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,32 @@ class DummyControlFlowError(RuntimeError):
)


def test_error_without_message_uses_exception_type_as_status_message(
langfuse_memory_client, get_span
):
handler = CallbackHandler()
run_id = uuid4()

handler.on_tool_start(
{"name": "failing_tool"},
"{}",
run_id=run_id,
)
handler.on_tool_error(
ValueError(),
run_id=run_id,
)

handler._langfuse_client.flush()

span = get_span("failing_tool")
assert span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_LEVEL] == "ERROR"
assert (
span.attributes[LangfuseOtelSpanAttributes.OBSERVATION_STATUS_MESSAGE]
== "ValueError"
)


def test_streamed_llm_error_cleans_only_its_completion_start_time_memo(
langfuse_memory_client,
):
Expand Down
Loading