Skip to content

Conversation

athan37
Copy link

@athan37 athan37 commented Oct 5, 2025

Fixes 400 error when using structured output with Google models by setting function calling mode to "auto" instead of "any" when responseMimeType is "application/json".

"error" : {
   "code" 400,
   "message" : "Forced function calling (mode = ANY) is not supported when 'response_mime_type' is not set to 'text/plain'. Please set 'tool_config.function_calling_config.mode= AUTO' or set 'response_mime_type' to 'text/plain'. For more details, see: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#tool-config",
   status: "INVALID_ARGUMENT"
}

Changes

  • Modified formatToolConfig in gemini.ts to dynamically set function calling mode based on responseMimeType
  • Enhanced withStructuredOutput in chat_models.ts to automatically set responseMimeType: "application/json"
  • Added unit tests covering both default and override scenarios

Testing

  • Added 2 unit tests

Copy link

changeset-bot bot commented Oct 5, 2025

⚠️ No Changeset found

Latest commit: 2eb0315

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Oct 5, 2025

@athan37 is attempting to deploy a commit to the LangChain Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Oct 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Updated (UTC)
langchainjs-docs Ignored Ignored Oct 5, 2025 10:09pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant