handoff_tool needs protection against infinite loops #3

Closed
opened 2026-02-16 06:18:15 -05:00 by yindo · 3 comments
Owner

Originally created by @arthurdorigueto on GitHub (Feb 26, 2025).

The way create_handoff_tool is implemented allows for two agents to keep calling each other until the number of steps hit the graph recursion limit. There should be some hard protection agains that, right now the only protection is prompt engineering.

Originally created by @arthurdorigueto on GitHub (Feb 26, 2025). The way `create_handoff_tool` is implemented allows for two agents to keep calling each other until the number of steps hit the graph recursion limit. There should be some _hard_ protection agains that, right now the only protection is prompt engineering.
yindo closed this issue 2026-02-16 06:18:15 -05:00
Author
Owner

@vbarda commented on GitHub (Feb 26, 2025):

LangGraph has that -- you can use recursion_limit when invoking the system like the following:

swarm_graph.invoke({...}, config={"recursion_limit": 100})

@vbarda commented on GitHub (Feb 26, 2025): LangGraph has that -- you can use `recursion_limit` when invoking the system like the following: `swarm_graph.invoke({...}, config={"recursion_limit": 100})`
Author
Owner

@arthurdorigueto commented on GitHub (Feb 26, 2025):

How can I use this if I'm deploying my graph using LangGraph Cloud?

@arthurdorigueto commented on GitHub (Feb 26, 2025): How can I use this if I'm deploying my graph using LangGraph Cloud?
Author
Owner

@vbarda commented on GitHub (Mar 5, 2025):

if you're asking about recursion limit, you can simply pass this when interacting w/ deployment via LangGraph SDK - client.runs.stream(input=input, config=config, ...) where config contains recursion_limit

@vbarda commented on GitHub (Mar 5, 2025): if you're asking about recursion limit, you can simply pass this when interacting w/ deployment via [LangGraph SDK](https://langchain-ai.github.io/langgraph/cloud/reference/sdk/python_sdk_ref/) - `client.runs.stream(input=input, config=config, ...)` where config contains `recursion_limit`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph-swarm-py#3