Skip to content

Commit e144a56

Browse files
committed
Fix langgraph double render
1 parent 2286442 commit e144a56

File tree

2 files changed

+12
-7
lines changed
  • typescript-sdk
    • apps/dojo/src/app/[integrationId]/feature/human_in_the_loop
    • integrations/langgraph/examples/agents/human_in_the_loop

2 files changed

+12
-7
lines changed

typescript-sdk/apps/dojo/src/app/[integrationId]/feature/human_in_the_loop/page.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const HumanInTheLoop: React.FC<HumanInTheLoopProps> = ({ params }) => {
2121
// agent lock to the relevant agent
2222
agent="human_in_the_loop"
2323
>
24-
<Chat />
24+
<Chat integrationId={integrationId} />
2525
</CopilotKit>
2626
);
2727
};
@@ -93,7 +93,9 @@ const InterruptHumanInTheLoop: React.FC<{
9393
);
9494
};
9595

96-
const Chat = () => {
96+
const Chat = ({ integrationId }: { integrationId: string }) => {
97+
// Langgraph uses it's own hook to handle human-in-the-loop interactions via langgraph interrupts,
98+
// This hook won't do anything for other integrations.
9799
useLangGraphInterrupt({
98100
render: ({ event, resolve }) => <InterruptHumanInTheLoop event={event} resolve={resolve} />,
99101
});
@@ -116,6 +118,9 @@ const Chat = () => {
116118
],
117119
},
118120
],
121+
// Langgraph uses it's own hook to handle human-in-the-loop interactions via langgraph interrupts,
122+
// so don't use this action for langgraph integration.
123+
available: ['langgraph', 'langgraph-fastapi'].includes(integrationId) ? 'disabled' : 'enabled',
119124
renderAndWaitForResponse: ({ args, respond, status }) => {
120125
return <StepsFeedback args={args} respond={respond} status={status} />;
121126
},

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
DEFINE_TASK_TOOL = {
2121
"type": "function",
2222
"function": {
23-
"name": "generate_task_steps",
23+
"name": "plan_execution_steps",
2424
"description": "Make up 10 steps (only a couple of words per step) that are required for a task. The step should be in imperative form (i.e. Dig hole, Open door, ...)",
2525
"parameters": {
2626
"type": "object",
@@ -80,7 +80,7 @@ async def chat_node(state: Dict[str, Any], config: RunnableConfig):
8080
"""
8181
system_prompt = """
8282
You are a helpful assistant that can perform any task.
83-
You MUST call the `generate_task_steps` function when the user asks you to perform a task.
83+
You MUST call the `plan_execution_steps` function when the user asks you to perform a task.
8484
Always make sure you will provide tasks based on the user query
8585
"""
8686

@@ -94,7 +94,7 @@ async def chat_node(state: Dict[str, Any], config: RunnableConfig):
9494
# Use "predict_state" metadata to set up streaming for the write_document tool
9595
config["metadata"]["predict_state"] = [{
9696
"state_key": "steps",
97-
"tool": "generate_task_steps",
97+
"tool": "plan_execution_steps",
9898
"tool_argument": "steps"
9999
}]
100100

@@ -131,7 +131,7 @@ async def chat_node(state: Dict[str, Any], config: RunnableConfig):
131131
args = tool_call.get("args", {})
132132
tool_call_args = args if not isinstance(args, str) else json.loads(args)
133133

134-
if tool_call_name == "generate_task_steps":
134+
if tool_call_name == "plan_execution_steps":
135135
# Get the steps from the tool call
136136
steps_raw = tool_call_args.get("steps", [])
137137

@@ -182,7 +182,7 @@ async def chat_node(state: Dict[str, Any], config: RunnableConfig):
182182
}
183183
)
184184

185-
# If no tool calls or not generate_task_steps, return to END with the updated messages
185+
# If no tool calls or not plan_execution_steps, return to END with the updated messages
186186
return Command(
187187
goto=END,
188188
update={

0 commit comments

Comments
 (0)