Skip to content

Commit e1be909

Browse files
Add initial value
Signed-off-by: Luis Valdes <[email protected]>
1 parent 1c1bb28 commit e1be909

File tree

4 files changed

+18
-3
lines changed
  • typescript-sdk/integrations/langgraph/examples/python/agents

4 files changed

+18
-3
lines changed

typescript-sdk/integrations/langgraph/examples/python/agents/agentic_generative_ui/agent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,15 @@ async def start_node(state: AgentState, config: RunnableConfig): # pylint: disab
5656

5757
if "steps" not in state:
5858
state["steps"] = []
59+
if "tools" not in state:
60+
state["tools"] = []
5961

6062
return Command(
6163
goto="chat_node",
6264
update={
6365
"messages": state["messages"],
64-
"steps": state["steps"]
66+
"steps": state["steps"],
67+
"tools": state["tools"]
6568
}
6669
)
6770

typescript-sdk/integrations/langgraph/examples/python/agents/human_in_the_loop/agent.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ async def start_node(state: Dict[str, Any], config: RunnableConfig): # pylint: d
4949
# Initialize steps list if not exists
5050
if "steps" not in state:
5151
state["steps"] = []
52+
if "tools" not in state:
53+
state["tools"] = []
5254

5355
# Return command to route to chat_node
5456
return Command(
5557
goto="chat_node",
5658
update={
5759
"messages": state["messages"],
5860
"steps": state["steps"],
61+
"tools": state["tools"]
5962
}
6063
)
6164

typescript-sdk/integrations/langgraph/examples/python/agents/predictive_state_updates/agent.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ async def start_node(state: AgentState, config: RunnableConfig): # pylint: disab
4141
"""
4242
This is the entry point for the flow.
4343
"""
44+
if "tools" not in state:
45+
state["tools"] = []
46+
4447
return Command(
45-
goto="chat_node"
48+
goto="chat_node",
49+
update={
50+
"tools": state["tools"]
51+
}
4652
)
4753

4854

typescript-sdk/integrations/langgraph/examples/python/agents/shared_state/agent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ async def start_node(state: Dict[str, Any], config: RunnableConfig):
116116
"ingredients": [{"icon": "🍴", "name": "Sample Ingredient", "amount": "1 unit"}],
117117
"instructions": ["First step instruction"]
118118
}
119+
if "tools" not in state:
120+
state["tools"] = []
119121
# Emit the initial state to ensure it's properly shared with the frontend
120122
await adispatch_custom_event(
121123
"manually_emit_intermediate_state",
@@ -127,7 +129,8 @@ async def start_node(state: Dict[str, Any], config: RunnableConfig):
127129
goto="chat_node",
128130
update={
129131
"messages": state["messages"],
130-
"recipe": state["recipe"]
132+
"recipe": state["recipe"],
133+
"tools": state["tools"]
131134
}
132135
)
133136

0 commit comments

Comments
 (0)