Skip to content

Instantly share code, notes, and snippets.

@kennethleungty
Created December 6, 2025 07:20
Show Gist options
  • Select an option

  • Save kennethleungty/1956f970d88a52fbb0bc4f2621d6b69d to your computer and use it in GitHub Desktop.

Select an option

Save kennethleungty/1956f970d88a52fbb0bc4f2621d6b69d to your computer and use it in GitHub Desktop.
def router(state):
# Read user intent from the current graph state.
user_intent = state.get("intent")
# Decide which agent to call next based on simple logic.
# This demonstrates how you choose a target node.
if user_intent == "search":
return Command(
update={"task": "run_search"}, # Update part of the state
goto="search_agent" # Explicitly route to this node
)
else:
return Command(
update={"task": "create_summary"},
goto="summary_agent"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment