langgraph-supervisor errors out when using Gemini models #217

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

Originally created by @0xbadshah on GitHub (Mar 27, 2025).

Example Code

Example code:

const model = new ChatGoogleGenerativeAI({
    model: "gemini-2.5-pro-exp-03-25",
    temperature: 0,
  });

  const agent = createReactAgent({
    llm: model,
    tools: [internal_one_tool, internal_two_tool],
    prompt: "You're a helpful assistant.",
    name: "testing_agent"
  });

   const workflow = createSupervisor({
     llm: model,
     agents: [agent],
     prompt: "You're a helpful assistant. You have access to following agent: testing_agent. You can use it to answer questions.",
     outputMode: "last_message"
   });

   const app = workflow.compile();

   const result = await app.invoke({
      messages: [{
        type: "human",
        content: "Test input that triggers the testing_agent"
      }]
    });

Description

When using @langchain/langgraph-supervisor with Gemini models, two issues occur:

  1. createReactAgent errors with Error: Unknown / unsupported author: testing_agent because the Gemini doesn't seem to support name parameter in createReactAgent (Open bug ticket - https://github.com/langchain-ai/langchainjs/issues/7832)
  2. Gemini models doesn't support function calling with empty schema. Using langgraph-supervisor will error GenerateContentRequest.tools[0].function_declarations[0].parameters.properties: should be non-empty for OBJECT type

The second error occurs because langgraph-supervisor explicitly adds an empty schema here:

https://github.com/langchain-ai/langgraphjs/blob/05e21f01e5b9bd77d18a08b4cba96b7d91d8f842/libs/langgraph-supervisor/src/handoff.ts#L53-L57

System Info

Library versions:

        "@langchain/core": "^0.3.43",
        "@langchain/google-genai": "^0.2.0",
        "@langchain/langgraph": "^0.2.60",
        "@langchain/langgraph-supervisor": "^0.0.9",
Originally created by @0xbadshah on GitHub (Mar 27, 2025). ### Example Code Example code: ``` const model = new ChatGoogleGenerativeAI({ model: "gemini-2.5-pro-exp-03-25", temperature: 0, }); const agent = createReactAgent({ llm: model, tools: [internal_one_tool, internal_two_tool], prompt: "You're a helpful assistant.", name: "testing_agent" }); const workflow = createSupervisor({ llm: model, agents: [agent], prompt: "You're a helpful assistant. You have access to following agent: testing_agent. You can use it to answer questions.", outputMode: "last_message" }); const app = workflow.compile(); const result = await app.invoke({ messages: [{ type: "human", content: "Test input that triggers the testing_agent" }] }); ``` ### Description When using `@langchain/langgraph-supervisor` with Gemini models, two issues occur: 1. createReactAgent errors with `Error: Unknown / unsupported author: testing_agent` because the Gemini doesn't seem to support `name` parameter in createReactAgent (Open bug ticket - https://github.com/langchain-ai/langchainjs/issues/7832) 2. Gemini models doesn't support function calling with empty schema. Using langgraph-supervisor will error `GenerateContentRequest.tools[0].function_declarations[0].parameters.properties: should be non-empty for OBJECT type` The second error occurs because langgraph-supervisor explicitly adds an empty schema here: https://github.com/langchain-ai/langgraphjs/blob/05e21f01e5b9bd77d18a08b4cba96b7d91d8f842/libs/langgraph-supervisor/src/handoff.ts#L53-L57 ### System Info Library versions: ``` "@langchain/core": "^0.3.43", "@langchain/google-genai": "^0.2.0", "@langchain/langgraph": "^0.2.60", "@langchain/langgraph-supervisor": "^0.0.9", ```
yindo added the prebuilt label 2026-02-15 17:17:28 -05:00
yindo closed this issue 2026-02-15 17:17:28 -05:00
Author
Owner

@liftgoals commented on GitHub (Mar 27, 2025):

Yes, I've got the same issues. I solved the second issue by just adding a dummy variable:

{
      name: toolName,
      schema: z.object({
        reason: z.string().optional().describe("Optional reason for the handoff"),
      }),
      description: "Ask another agent for help.",
    }

But I haven't been able to make it work. For me it fails when handing over to another agent, otherwise it responds.

I'm using 'gemini-2.0-flash-lite'

@liftgoals commented on GitHub (Mar 27, 2025): Yes, I've got the same issues. I solved the second issue by just adding a dummy variable: ``` { name: toolName, schema: z.object({ reason: z.string().optional().describe("Optional reason for the handoff"), }), description: "Ask another agent for help.", } ``` But I haven't been able to make it work. For me it fails when handing over to another agent, otherwise it responds. I'm using 'gemini-2.0-flash-lite'
Author
Owner

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

@benjamincburns i believe this is the JS integration issue, since the same tools work fine for me in Python. it's possible that we're not converting the tools in the same way in JS as we are in PY in the genai package

@vbarda commented on GitHub (Mar 27, 2025): @benjamincburns i believe this is the JS integration issue, since the same tools work fine for me in Python. it's possible that we're not converting the tools in the same way in JS as we are in PY in the genai package
Author
Owner

@benjamincburns commented on GitHub (May 8, 2025):

Hi @Chan9390 - can you please update the issue description with a complete, executable MRE? You haven't included your tool definitions, and I don't know if they're important for the reproduction or not.

@benjamincburns commented on GitHub (May 8, 2025): Hi @Chan9390 - can you please update the issue description with a complete, executable [MRE](https://en.wikipedia.org/wiki/Minimal_reproducible_example)? You haven't included your tool definitions, and I don't know if they're important for the reproduction or not.
Author
Owner

@benjamincburns commented on GitHub (May 9, 2025):

On latest releases of @langchain/core, @langchain/langgraph, @langchain/langgraph-supervisor and @langchain/google-genai I can reproduce the unknown author error, but not the empty schema one. I can still update the handoff schema to z.undefined(), as that's technically more correct than z.object({}) (null/undefined input vs empty object) when input is ignored. I'm hesitant to do that without being able to reproduce the error though, as I don't want to swap one problem for another.

Regarding the author issue, I have a change in progress that'll fix that, for release tomorrow. You'll need to pass a parameter to the createSupervisor and createReactAgent factory functions to cause it to inline the agent name rather than passing it via AIMessage.name.

Example:

      const mathAgent = createReactAgent({
        llm: mathLLM,
        tools: [add],
        name: "math_expert",
        prompt: "You are a math expert. Always use one tool at a time.",
        includeAgentName: "inline",
      });

      const researchAgent = createReactAgent({
        llm: researchLLM,
        tools: [webSearch],
        name: "research_expert",
        prompt:
          "You are a world class researcher with access to web search. Do not do any math.",
        includeAgentName: "inline",
      });

      const workflow = createSupervisor({
        agents: [mathAgent, researchAgent],
        llm: model,
        prompt:
          "You are a team supervisor managing a research expert and a math expert.",
        includeAgentName: "inline"
      });

Right now the parameter exists for createSupervisor, but it only changes the message format and doesn't drop the name field.

@benjamincburns commented on GitHub (May 9, 2025): On latest releases of `@langchain/core`, `@langchain/langgraph`, `@langchain/langgraph-supervisor` and `@langchain/google-genai` I can reproduce the unknown author error, but not the empty schema one. I can still update the handoff schema to `z.undefined()`, as that's technically more correct than `z.object({})` (null/undefined input vs empty object) when input is ignored. I'm hesitant to do that without being able to reproduce the error though, as I don't want to swap one problem for another. Regarding the author issue, I have a change in progress that'll fix that, for release tomorrow. You'll need to pass a parameter to the `createSupervisor` and `createReactAgent` factory functions to cause it to inline the agent name rather than passing it via `AIMessage.name`. Example: ``` const mathAgent = createReactAgent({ llm: mathLLM, tools: [add], name: "math_expert", prompt: "You are a math expert. Always use one tool at a time.", includeAgentName: "inline", }); const researchAgent = createReactAgent({ llm: researchLLM, tools: [webSearch], name: "research_expert", prompt: "You are a world class researcher with access to web search. Do not do any math.", includeAgentName: "inline", }); const workflow = createSupervisor({ agents: [mathAgent, researchAgent], llm: model, prompt: "You are a team supervisor managing a research expert and a math expert.", includeAgentName: "inline" }); ``` Right now the parameter exists for `createSupervisor`, but it only changes the message format and doesn't drop the `name` field.
Author
Owner

@benjamincburns commented on GitHub (May 13, 2025):

Should be fixed as of last night's release of @langchain/langgraph-supervisor v0.0.12

@benjamincburns commented on GitHub (May 13, 2025): Should be fixed as of last night's release of `@langchain/langgraph-supervisor` v0.0.12
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#217