-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Checked other resources
- This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/).
- I added a very descriptive title to this issue.
- I searched the LangChain.js documentation with the integrated search.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangChain.js rather than my code.
- The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
Attempt 1: Using BaseMessage Array (Standard LangChain Pattern)
import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
import { BaseMessage, HumanMessage } from "@langchain/core/messages";
const llm = new ChatGoogleGenerativeAI({
model: "gemini-2.0-flash-exp",
temperature: 0,
maxOutputTokens: 2048,
apiKey: process.env.GOOGLE_API_KEY,
});
const systemPrompt = "You are a helpful assistant...";
const userMessage = "Analyze this data...";
const messages: BaseMessage[] = [
new HumanMessage(systemPrompt),
new HumanMessage(userMessage),
];
const response = await llm.invoke(messages);
Attempt 2 : ( as per official docs )
const response = await llm.invoke([
["system", systemPrompt],
["human", userMessage],
]);
Error Message and Stack Trace (if applicable)
Error: Unknown / unsupported author: undefined
Description
When using ChatGoogleGenerativeAI from @langchain/google-genai with multiple messages, the SDK throws an error: "Unknown / unsupported author: undefined". This occurs despite following the official LangChain documentation patterns for message formatting.
Environment
Package: @langchain/google-genai (latest version)
Runtime: Node.js with NestJS
Model: gemini-2.0-flash-exp
LangChain Core: @langchain/core
Expected Behavior
The Gemini model should accept messages in the standard LangChain tuple notation or BaseMessage[] format as documented at: https://docs.langchain.com/oss/javascript/langchain/models#google-gemini
According to the documentation, this should work:
Actual Behavior
The SDK throws: [Error: Unknown / unsupported author: undefined]
System Info
Code Context
This issue occurs in a production NestJS application where we're trying to use Gemini for final response generation in a data analysis pipeline:
private async generateFinalResponse(
userQuery: string,
pythonOutput: string,
memoryContext?: string,
): Promise<{ response: string; tokenUsage?: TokenUsage }> {
try {
const systemPrompt = analysisAgentFinalResponseSystemPrompt;
const userMessage = getAnalysisAgentFinalResponseUserPrompt(
userQuery,
pythonOutput,
memoryContext,
);
// All of these approaches fail with "Unknown / unsupported author: undefined"
const messages: BaseMessage[] = [
new HumanMessage(systemPrompt),
new HumanMessage(userMessage),
];
const response = await this.finalresllm.invoke(messages);
// ❌ Error thrown here
return { response: response.content.toString() };
} catch (error) {
this.logger.error(`Error generating final response: ${error}`);
throw error;
}
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working