Hello everyone! I’m using supervisor to understand which next graph to run (subgraph) from the user’s request. Each subgraph has its own state, and I want to make supervisor generate the state for the selected graph based on the user’s request (message).
If I understand correctly, your supervisor is going to triage a request, and then kick off a subgraph with Command(goto=“subgraph”, update={state for subgraph}} or an alternative.
There are a few design choices here:
You could use withStructuredOutput alongside a custom prompt to generate the inputs for your graph, and then pass those in.
You could treat each subgraph as a tool - then the LLM can choose which subgraph to call based on a prompt, and will generate the inputs to that tool. The tool can still .invoke() a graph object inside the function.
LLM triages where to go - this should also probably be done using withStructuredOutput(). The LLM will return a string designating which sub agent to hand off to.
Then once the destination has been chosen, you can get the input state (BaseModel, dict, etc.) back from a separate call using withStructuredOutput.
Then you can manually invoke the subgraph, or navigate to it with Command (if the subgraph is a node in your main graph)