Simple example for tool calling with supervisor flow not working #270

Open
opened 2026-02-15 18:15:19 -05:00 by yindo · 10 comments
Owner

Originally created by @EmmanuelPonnudurai on GitHub (May 27, 2025).

Hello. I am using this example from here https://github.com/langchain-ai/langgraphjs/tree/main/libs/langgraph-supervisor

I have everything working, except that when I ask a question "can you add 1 and 2", it doesnt call the add tool. It gets the answer from the model.

I changed the add function to return a + b + 10. This is to verify that its indeed calling the tool to add but not asking the model itself. But its not working. The answer i get is correct, which means the tool call is not happening at all.

Here is the updated add tool,

const add = tool(async (args) => args.a + args.b + 10, { // <- adding 10 to the sum to verify that this tool call is being done
  name: "add",
  description: "Add two numbers.",
  schema: z.object({
    a: z.number(),
    b: z.number(),
  }),
});

The output, however, is giving the right answer

Image

Note that I was running into another weird issue where it was complaining about this problem. I followed the fix and now it works but it surely doesnt call the tool to add.

Can someone give me some pointers on where the problem could be?

Originally created by @EmmanuelPonnudurai on GitHub (May 27, 2025). Hello. I am using this example from here https://github.com/langchain-ai/langgraphjs/tree/main/libs/langgraph-supervisor I have everything working, except that when I ask a question "can you add 1 and 2", it doesnt call the add tool. It gets the answer from the model. I changed the add function to return a + b + 10. This is to verify that its indeed calling the tool to add but not asking the model itself. But its not working. The answer i get is correct, which means the tool call is not happening at all. Here is the updated add tool, ```ts const add = tool(async (args) => args.a + args.b + 10, { // <- adding 10 to the sum to verify that this tool call is being done name: "add", description: "Add two numbers.", schema: z.object({ a: z.number(), b: z.number(), }), }); ``` The output, however, is giving the right answer ![Image](https://github.com/user-attachments/assets/4f5b04ee-d2b0-45c3-9e81-010c17e82de5) Note that I was running into another weird issue where it was complaining about this [problem](https://github.com/langchain-ai/langgraphjs/issues/1217). I followed the fix and now it works but it surely doesnt call the tool to add. Can someone give me some pointers on where the problem could be?
yindo added the bug label 2026-02-15 18:15:19 -05:00
Author
Owner

@vbarda commented on GitHub (May 27, 2025):

do you have a langsmith trace?

@vbarda commented on GitHub (May 27, 2025): do you have a langsmith trace?
Author
Owner

@EmmanuelPonnudurai commented on GitHub (May 27, 2025):

@vbarda full_output.json

I've attached the full output if that helps.

Can you point me to some docs/info/wiki explaining how I can add the langsmith tracing on top of the sample im using?

@EmmanuelPonnudurai commented on GitHub (May 27, 2025): @vbarda [full_output.json](https://github.com/user-attachments/files/20464317/full_output.json) I've attached the full output if that helps. Can you point me to some docs/info/wiki explaining how I can add the langsmith tracing on top of the [sample im using](https://github.com/langchain-ai/langgraphjs/tree/main/libs/langgraph-supervisor)?
Author
Owner

@vbarda commented on GitHub (May 27, 2025):

all you need is a free langsmith API key and an environment variable that enables tracing, and everything will work out of box: https://docs.smith.langchain.com/observability

@vbarda commented on GitHub (May 27, 2025): all you need is a free langsmith API key and an environment variable that enables tracing, and everything will work out of box: https://docs.smith.langchain.com/observability
Author
Owner

@EmmanuelPonnudurai commented on GitHub (May 27, 2025):

@vbarda Thank you. Should i expect some delay before they start showing up ? I ran my workflow a bunch of times and I still do not see anything there.

  • setup an account in langchain
  • logged into langsmith
  • created api key and added these env variables
    • LANGSMITH_API_KEY: {my_api_key}
    • LANGSMITH_TRACING: true

Image

@EmmanuelPonnudurai commented on GitHub (May 27, 2025): @vbarda Thank you. Should i expect some delay before they start showing up ? I ran my workflow a bunch of times and I still do not see anything there. - setup an account in langchain - logged into langsmith - created api key and added these env variables - LANGSMITH_API_KEY: {my_api_key} - LANGSMITH_TRACING: true ![Image](https://github.com/user-attachments/assets/973f5bce-b547-4d99-8226-5ed9eaff2c69)
Author
Owner

@EmmanuelPonnudurai commented on GitHub (May 27, 2025):

@vbarda My bad. The env variable didnt stick. I had to redo it and now it works. Here is the trace https://smith.langchain.com/public/925a449f-b2ce-4e81-8c7f-07a881e68d31/r

I do see the tool call made and the answer 13 being listed for a sum of 1 + 2. Which is correct as per my add method. But i dont see this output in my code. I always see answer is 3.

@EmmanuelPonnudurai commented on GitHub (May 27, 2025): @vbarda My bad. The env variable didnt stick. I had to redo it and now it works. Here is the trace https://smith.langchain.com/public/925a449f-b2ce-4e81-8c7f-07a881e68d31/r I do see the tool call made and the answer 13 being listed for a sum of 1 + 2. Which is correct as per my add method. But i dont see this output in my code. I always see answer is 3.
Author
Owner

@EmmanuelPonnudurai commented on GitHub (May 28, 2025):

@vbarda any inputs ?

@EmmanuelPonnudurai commented on GitHub (May 28, 2025): @vbarda any inputs ?
Author
Owner

@EmmanuelPonnudurai commented on GitHub (May 28, 2025):

I feel that the createReactAgent and createSupervisor are not properly handing off the response from the tool call. I did read somewhere that these methods are encapsulations to hide all that setup, so you don't have to keep doing that again and again. But then, it's not working.

The tool call is made, but that tool calls' result is not being used. I am unable to figure out and blocked.

Also, these packages are not latest because if I use latest, im running into another issue that bindTools must be implemented. its getting very hard to use these packages witout running into bunch of issues,

  • @langchain/anthropic: 0.3.20
  • @langchain/openai: 0.5.9
@EmmanuelPonnudurai commented on GitHub (May 28, 2025): I feel that the `createReactAgent` and `createSupervisor` are not properly handing off the response from the tool call. I did read somewhere that these methods are encapsulations to hide all that setup, so you don't have to keep doing that again and again. But then, it's not working. The tool call is made, but that tool calls' result is not being used. I am unable to figure out and blocked. Also, these packages are not latest because if I use latest, im running into another issue that bindTools must be implemented. its getting very hard to use these packages witout running into bunch of issues, - @langchain/anthropic: 0.3.20 - @langchain/openai: 0.5.9
Author
Owner

@gyanendrasng commented on GitHub (Jun 4, 2025):

@EmmanuelPonnudurai did you try explicitly stating that it needs to use that tool for addition?

@gyanendrasng commented on GitHub (Jun 4, 2025): @EmmanuelPonnudurai did you try explicitly stating that it needs to use that tool for addition?
Author
Owner

@EmmanuelPonnudurai commented on GitHub (Jun 4, 2025):

@gyanendrasng Yes, I did. I am following the sample as is. But is the setup actually working for anyone with all latest versions of the packages?

Even the trace is showing that my add function was called but that desnt go back up to supervisor. The answer from the model is taken but not the result which is the tool call.

@EmmanuelPonnudurai commented on GitHub (Jun 4, 2025): @gyanendrasng Yes, I did. I am following the sample as is. But is the setup actually working for anyone with all latest versions of the packages? Even the trace is showing that my add function was called but that desnt go back up to supervisor. The answer from the model is taken but not the result which is the tool call.
Author
Owner

@ddewaele commented on GitHub (Jul 28, 2025):

The supervisor sample doesn't really work IMHO.

It only works right after startup and if you ask it 1 simple question

Important Update : The behavior below is only exhibited@langchain/openai ^0.6.3. It works a lot better with ^0.5.18

here it got the first question right ... dispatching to the research agent.
but if I then ask it to do a multiplication it doesn't dispatch to the math agent but it sticks with the supervisor agent and tries to do a web_search resulting in Error: Tool "web_search" not found. It does respond with a correct answer but it wasn't using the math agent nor the tool.

Image

When I start a new thread to do the multiplication it fails with a recursion limit issue

Image

When I restart the server complete and ask for the multiplication it works

Image

When asking a research question after having asked a multiplication question it never hits the research agent

Image
@ddewaele commented on GitHub (Jul 28, 2025): The supervisor sample doesn't really work IMHO. It only works right after startup and if you ask it 1 simple question **Important Update :** The behavior below is only exhibited`@langchain/openai ^0.6.3`. It works a lot better with `^0.5.18` here it got the first question right ... dispatching to the research agent. but if I then ask it to do a multiplication it doesn't dispatch to the math agent but it sticks with the supervisor agent and tries to do a web_search resulting in Error: Tool "web_search" not found. It does respond with a correct answer but it wasn't using the math agent nor the tool. <img width="944" height="1301" alt="Image" src="https://github.com/user-attachments/assets/9ba193d1-b3f5-4094-9952-bcf7c0ff028d" /> When I start a new thread to do the multiplication it fails with a recursion limit issue <img width="1788" height="487" alt="Image" src="https://github.com/user-attachments/assets/f79037c4-14a3-4312-aa1a-ec83c6212b18" /> When I restart the server complete and ask for the multiplication it works <img width="434" height="797" alt="Image" src="https://github.com/user-attachments/assets/8dfa1d6a-c742-4ec1-8904-ff554d701749" /> When asking a research question after having asked a multiplication question it never hits the research agent <img width="1407" height="1288" alt="Image" src="https://github.com/user-attachments/assets/97d2025f-21fa-4eb6-9734-25e96942ad89" />
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#270