How to pass LLM with structured output to createReactAgent or createSupervisor #201

Closed
opened 2026-02-15 17:17:13 -05:00 by yindo · 5 comments
Owner

Originally created by @ali-habibzadeh on GitHub (Mar 14, 2025).

Currently your docs shows LLM is created like this to be used for agents:

const llm = new ChatAnthropic({ apiKey: config.CLAUDE_API_KEY, model: "claude-3-7-sonnet-20250219" });

const userTasksAgent = createReactAgent({
  llm,
  tools: [userTasksTool],
  name: "user-tasks-expert",
  prompt: `blablabla`,
});

But this is not ideal when this is the final task or a supervisor. Ideally I should be able to do something like this, but its not compatible:

const llm = new ChatAnthropic({ apiKey: config.CLAUDE_API_KEY, model: "claude-3-7-sonnet-20250219" });

const userTasksAgent = createReactAgent({
  llm: llm.withStructuredOutput({ output: z.string(),..... }),
  tools: [userTasksTool],
  name: "user-tasks-expert",
  prompt: `blablabla`,
});
Originally created by @ali-habibzadeh on GitHub (Mar 14, 2025). Currently your docs shows LLM is created like this to be used for agents: ```typescript const llm = new ChatAnthropic({ apiKey: config.CLAUDE_API_KEY, model: "claude-3-7-sonnet-20250219" }); const userTasksAgent = createReactAgent({ llm, tools: [userTasksTool], name: "user-tasks-expert", prompt: `blablabla`, }); ``` But this is not ideal when this is the final task or a supervisor. Ideally I should be able to do something like this, but its not compatible: ```typescript const llm = new ChatAnthropic({ apiKey: config.CLAUDE_API_KEY, model: "claude-3-7-sonnet-20250219" }); const userTasksAgent = createReactAgent({ llm: llm.withStructuredOutput({ output: z.string(),..... }), tools: [userTasksTool], name: "user-tasks-expert", prompt: `blablabla`, }); ```
yindo closed this issue 2026-02-15 17:17:13 -05:00
Author
Owner

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

@ali-habibzadeh in createReactAgent you can already do that via passing responseFormat param. this will create another key with structured output in the final agent response. it's not supported yet in createSupervisor but will add responseFormat there as well (will return structured output in the final supervisor response)

@vbarda commented on GitHub (Mar 14, 2025): @ali-habibzadeh in `createReactAgent` you can already do that via passing `responseFormat` param. this will create another key with structured output in the final agent response. it's not supported yet in `createSupervisor` but will add `responseFormat` there as well (will return structured output in the final supervisor response)
Author
Owner

@ali-habibzadeh commented on GitHub (Mar 14, 2025):

@ali-habibzadeh in createReactAgent you can already do that via passing responseFormat param. this will create another key with structured output in the final agent response. it's not supported yet in createSupervisor but will add responseFormat there as well (will return structured output in the final supervisor response)

Looking forward to using it when you add it. Thanks

@ali-habibzadeh commented on GitHub (Mar 14, 2025): > [@ali-habibzadeh](https://github.com/ali-habibzadeh) in `createReactAgent` you can already do that via passing `responseFormat` param. this will create another key with structured output in the final agent response. it's not supported yet in `createSupervisor` but will add `responseFormat` there as well (will return structured output in the final supervisor response) Looking forward to using it when you add it. Thanks
Author
Owner

@ali-habibzadeh commented on GitHub (Apr 8, 2025):

Hi, Noticed the new release didn't include this. What is the ETA for supporting response format for supervisor?

@ali-habibzadeh commented on GitHub (Apr 8, 2025): Hi, Noticed the new release didn't include this. What is the ETA for supporting response format for supervisor?
Author
Owner

@vbarda commented on GitHub (Apr 8, 2025):

ah, my bad! will add shortly and update this issue

@vbarda commented on GitHub (Apr 8, 2025): ah, my bad! will add shortly and update this issue
Author
Owner

@vbarda commented on GitHub (Apr 9, 2025):

@ali-habibzadeh released in 0.0.11

@vbarda commented on GitHub (Apr 9, 2025): @ali-habibzadeh released in 0.0.11
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#201