Skip to content

Commit 84a1ab1

Browse files
jsonbaileyclaude
andcommitted
fix: Type create_tracker as Optional to fix mypy errors
Change AgentGraphDefinition.create_tracker from Callable[[], AIGraphTracker] with default lambda: None to Optional[Callable[[], AIGraphTracker]] with default None. Guard call sites in both runners with `is not None` before invoking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dd44577 commit 84a1ab1

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

packages/ai-providers/server-ai-langchain/src/ldai_langchain/langgraph_agent_graph_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def route(state: WorkflowState) -> str:
260260

261261
self._graph.traverse(fn=handle_traversal)
262262

263-
tracker = self._graph.create_tracker()
263+
tracker = self._graph.create_tracker() if self._graph.create_tracker is not None else None
264264
graph_key_str = tracker.graph_key if tracker else 'unknown'
265265
log.debug(
266266
f"LangGraphAgentGraphRunner: graph='{graph_key_str}', root='{root_key}', "
@@ -281,7 +281,7 @@ async def run(self, input: Any) -> AgentGraphResult:
281281
:param input: The string prompt to send to the agent graph
282282
:return: AgentGraphResult with the final output and metrics
283283
"""
284-
tracker = self._graph.create_tracker()
284+
tracker = self._graph.create_tracker() if self._graph.create_tracker is not None else None
285285
start_ns = time.perf_counter_ns()
286286

287287
try:

packages/ai-providers/server-ai-openai/src/ldai_openai/openai_agent_graph_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async def run(self, input: Any) -> AgentGraphResult:
7070
:param input: The string prompt to send to the agent graph
7171
:return: AgentGraphResult with the final output and metrics
7272
"""
73-
tracker = self._graph.create_tracker()
73+
tracker = self._graph.create_tracker() if self._graph.create_tracker is not None else None
7474
path: List[str] = []
7575
root_node = self._graph.root()
7676
root_key = root_node.get_key() if root_node else ''

packages/sdk/server-ai/src/ldai/agent_graph/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(
5454
nodes: Dict[str, AgentGraphNode],
5555
context: Context,
5656
enabled: bool,
57-
create_tracker: Callable[[], AIGraphTracker] = lambda: None,
57+
create_tracker: Optional[Callable[[], AIGraphTracker]] = None,
5858
):
5959
self._agent_graph = agent_graph
6060
self._context = context

0 commit comments

Comments
 (0)