Open
Description
Checked other resources
- I added a very descriptive title to this issue.
- 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 rather than my code.
- The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
- I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.
Example Code
import { Injectable } from "@nestjs/common";
import { ChatOpenAI } from "@langchain/openai";
import { NewsSchema, News } from "./news.schema";
@Injectable()
export class LlmService {
private readonly llm = new ChatOpenAI({
model: "gpt-4o-mini",
temperature: 0.2,
openAIApiKey: "myKey",
})
.bindTools([{ type: "web_search_preview" }])
.withStructuredOutput(NewsSchema, {
strict: true,
});
async positiveNewsToday(): Promise<News> {
return this.llm.invoke("Give me one positive news story from today");
}
}
Error Message and Stack Trace (if applicable)
No response
Description
I’m trying to build an agent that both has tools bound (e.g. a web‐search preview tool) and emits structured output via my own schema. However, calling .bindTools([...]) before .withStructuredOutput(...) causes an error and prevents me from using structured output at all.
System Info
System Info (Node.js / NestJS)
node -v : v22.12.0
npm -v : 10.9.0
npm ls @nestjs/core : [email protected] E:\Work\teest
├── @nestjs/[email protected]
├─┬ @nestjs/[email protected]
│ └── @nestjs/[email protected] deduped
└─┬ @nestjs/[email protected]
└── @nestjs/[email protected]