Error15 reports
Fix BadRequestError
in LangChain
✅ Solution
BadRequestError in Langchain often stems from improperly formatted requests sent to external services like OpenAI or Anthropic, typically due to incorrect serialization of data structures in prompts or tool outputs. To fix this, carefully review the Langchain agent's prompt formatting, tool input/output schemas, and how data is being serialized, ensuring they adhere to the API's expected format, and utilize debugging tools to inspect the exact request being sent. Validate that all required fields are provided, types match the schema and optional parameters are handled correctly.
Related Issues
Real GitHub issues where developers encountered this error:
Bug Report: MCP Tools Return List Instead of String, Breaking Chat Model SerializationJan 8, 2026
OpenAI.BadRequestError when using create_agent with structured output and tools with optional input parametersJan 4, 2026
AnthropicPromptCachingMiddleware applies cache_control to tool_use/tool_result blocks called by code_execution, causing API errorsDec 30, 2025
`SummarizationMiddleware` includes metadata in prompt causing context length overflowDec 29, 2025
In agent, there is no suitable reasoning_content for deepseekDec 20, 2025
Timeline
First reported:Oct 26, 2025
Last reported:Jan 8, 2026