Skip to content

The agent engineering platform.

fix: don't trace conditional edges and no todos in input state (#33842)

Sydney Runkle9a09ed065996
diff --git a/libs/langchain_v1/langchain/agents/factory.py b/libs/langchain_v1/langchain/agents/factory.py
index c81d3c5d4f..9bc18ea943 100644
--- a/libs/langchain_v1/langchain/agents/factory.py
+++ b/libs/langchain_v1/langchain/agents/factory.py
@@ -1268,11 +1268,14 @@ def create_agent( # noqa: PLR0915
graph.add_conditional_edges(
"tools",
- _make_tools_to_model_edge(
- tool_node=tool_node,
- model_destination=loop_entry_node,
- structured_output_tools=structured_output_tools,
- end_destination=exit_node,
+ RunnableCallable(
+ _make_tools_to_model_edge(
+ tool_node=tool_node,
+ model_destination=loop_entry_node,
+ structured_output_tools=structured_output_tools,
+ end_destination=exit_node,
+ ),
+ trace=False,
),
tools_to_model_destinations,
)
@@ -1289,19 +1292,25 @@ def create_agent( # noqa: PLR0915
graph.add_conditional_edges(
loop_exit_node,
- _make_model_to_tools_edge(
- model_destination=loop_entry_node,
- structured_output_tools=structured_output_tools,
- end_destination=exit_node,
+ RunnableCallable(
+ _make_model_to_tools_edge(
+ model_destination=loop_entry_node,
+ structured_output_tools=structured_output_tools,
+ end_destination=exit_node,
+ ),
+ trace=False,
),
model_to_tools_destinations,
)
elif len(structured_output_tools) > 0:
graph.add_conditional_edges(
loop_exit_node,
- _make_model_to_model_edge(
- model_destination=loop_entry_node,
- end_destination=exit_node,
+ RunnableCallable(
+ _make_model_to_model_edge(
+ model_destination=loop_entry_node,
+ end_destination=exit_node,
+ ),
+ trace=False,
),
[loop_entry_node, exit_node],
)
@@ -1602,7 +1611,7 @@ def _add_middleware_edge(
if "model" in can_jump_to and name != model_destination:
destinations.append(model_destination)
- graph.add_conditional_edges(name, jump_edge, destinations)
+ graph.add_conditional_edges(name, RunnableCallable(jump_edge, trace=False), destinations)
else:
graph.add_edge(name, default_destination)
diff --git a/libs/langchain_v1/langchain/agents/middleware/todo.py b/libs/langchain_v1/langchain/agents/middleware/todo.py
index beeee6350f..5ec0215efc 100644
--- a/libs/langchain_v1/langchain/agents/middleware/todo.py
+++ b/libs/langchain_v1/langchain/agents/middleware/todo.py
@@ -19,6 +19,7 @@ from langchain.agents.middleware.types import (
ModelCallResult,
ModelRequest,
ModelResponse,
+ OmitFromInput,
)
from langchain.tools import InjectedToolCallId
@@ -36,7 +37,7 @@ class Todo(TypedDict):
class PlanningState(AgentState):
"""State schema for the todo middleware."""
- todos: NotRequired[list[Todo]]
+ todos: Annotated[NotRequired[list[Todo]], OmitFromInput]
"""List of todo items for tracking task progress."""