The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Don't raise error if parent not found (#6538)
Zander Chase07d802d0887f
diff --git a/langchain/callbacks/tracers/base.py b/langchain/callbacks/tracers/base.pyindex dd0c118355..6cfad4d431 100644--- a/langchain/callbacks/tracers/base.py+++ b/langchain/callbacks/tracers/base.py@@ -1,6 +1,7 @@"""Base interfaces for tracing runs."""from __future__ import annotations+import loggingfrom abc import ABC, abstractmethodfrom datetime import datetimefrom typing import Any, Dict, List, Optional, Union@@ -10,6 +11,8 @@ from langchain.callbacks.base import BaseCallbackHandlerfrom langchain.callbacks.tracers.schemas import Run, RunTypeEnumfrom langchain.schema import LLMResult+logger = logging.getLogger(__name__)+class TracerException(Exception):"""Base class for exceptions in tracers module."""@@ -41,9 +44,7 @@ class BaseTracer(BaseCallbackHandler, ABC):if parent_run:self._add_child_run(parent_run, run)else:- raise TracerException(- f"Parent run with UUID {run.parent_run_id} not found."- )+ logger.warning(f"Parent run with UUID {run.parent_run_id} not found.")self.run_map[str(run.id)] = rundef _end_trace(self, run: Run) -> None:@@ -53,10 +54,8 @@ class BaseTracer(BaseCallbackHandler, ABC):else:parent_run = self.run_map.get(str(run.parent_run_id))if parent_run is None:- raise TracerException(- f"Parent run with UUID {run.parent_run_id} not found."- )- if (+ logger.warning(f"Parent run with UUID {run.parent_run_id} not found.")+ elif (run.child_execution_order is not Noneand parent_run.child_execution_order is not Noneand run.child_execution_order > parent_run.child_execution_order@@ -71,7 +70,8 @@ class BaseTracer(BaseCallbackHandler, ABC):parent_run = self.run_map.get(parent_run_id)if parent_run is None:- raise TracerException(f"Parent run with UUID {parent_run_id} not found.")+ logger.warning(f"Parent run with UUID {parent_run_id} not found.")+ return 1if parent_run.child_execution_order is None:raise TracerException(f"Parent run with UUID {parent_run_id} has no child execution order."