Skip to content

Commit 2fc7151

Browse files
jsonbaileyclaude
andcommitted
fix: Address remaining PR review feedback
- Cache node trackers in langgraph_callback_handler flush() to avoid creating multiple trackers per node with different runIds - Read graph key directly from config instead of instantiating a tracker just for debug logging in langgraph_agent_graph_runner - Simplify redundant except (json.JSONDecodeError, Exception) to except Exception in tracker.py from_resumption_token Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent edd1690 commit 2fc7151

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

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

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

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

263-
tracker = self._graph.create_tracker() if self._graph.create_tracker is not None else None
264-
graph_key_str = tracker.graph_key if tracker else 'unknown'
263+
graph_key_str = self._graph._agent_graph.key or 'unknown'
265264
log.debug(
266265
f"LangGraphAgentGraphRunner: graph='{graph_key_str}', root='{root_key}', "
267266
f"structure: {' | '.join(graph_structure)}"

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,17 @@ def flush(self, graph: AgentGraphDefinition) -> None:
196196
197197
:param graph: The AgentGraphDefinition whose nodes hold the LD config trackers.
198198
"""
199+
node_trackers: Dict[str, Any] = {}
199200
for node_key in self._path:
201+
if node_key in node_trackers:
202+
continue
200203
node = graph.get_node(node_key)
201204
if not node:
202205
continue
203206
config_tracker = node.get_config().create_tracker()
204207
if not config_tracker:
205208
continue
209+
node_trackers[node_key] = config_tracker
206210

207211
usage = self._node_tokens.get(node_key)
208212
if usage:

packages/sdk/server-ai/src/ldai/tracker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def from_resumption_token(cls, token: str, ld_client: LDClient, context: Context
153153
payload = json.loads(
154154
base64.urlsafe_b64decode(padded.encode("utf-8")).decode("utf-8")
155155
)
156-
except (json.JSONDecodeError, Exception) as e:
156+
except Exception as e:
157157
return Result.fail(f"Invalid resumption token: {e}", e)
158158

159159
for field in ("runId", "configKey", "version"):

0 commit comments

Comments
 (0)