From 069443f322ed8b4aa079f24387b15075823ea313 Mon Sep 17 00:00:00 2001 From: Hassieb Pakzad <68423100+hassiebp@users.noreply.github.com> Date: Mon, 8 Sep 2025 13:40:12 +0200 Subject: [PATCH] fix(langchain): set cost to zero on errors --- langfuse/langchain/CallbackHandler.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/langfuse/langchain/CallbackHandler.py b/langfuse/langchain/CallbackHandler.py index 20bfa2534..b4c27c3bc 100644 --- a/langfuse/langchain/CallbackHandler.py +++ b/langfuse/langchain/CallbackHandler.py @@ -218,6 +218,7 @@ def on_retriever_error( level="ERROR", status_message=str(error), input=kwargs.get("inputs"), + cost_details={"total": 0}, ).end() except Exception as e: @@ -527,6 +528,7 @@ def on_chain_error( ), status_message=str(error) if level else None, input=kwargs.get("inputs"), + cost_details={"total": 0}, ).end() except Exception as e: @@ -733,6 +735,7 @@ def on_tool_error( status_message=str(error), level="ERROR", input=kwargs.get("inputs"), + cost_details={"total": 0}, ).end() except Exception as e: @@ -913,6 +916,7 @@ def on_llm_error( status_message=str(error), level="ERROR", input=kwargs.get("inputs"), + cost_details={"total": 0}, ).end() except Exception as e: