Skip to content

feat(groq): Allow kwargs in with_structured_output to override tool_choice - #34053

Merged
ccurme (ccurme) merged 3 commits into
langchain-ai:masterfrom
dumko2001:fix/groq-with-structured-output-kwargs
Dec 12, 2025
Merged

ccurme (ccurme) merged 3 commits into
langchain-ai:masterfrom
dumko2001:fix/groq-with-structured-output-kwargs

Conversation

@dumko2001

Copy link
Copy Markdown
Contributor

Fixes #33995

Allow users to pass additional kwargs (like tool_choice) to with_structured_output() to avoid 400 errors when the model doesn't trigger a tool call. This aligns ChatGroq with ChatOpenAI behavior.

Users can now override the default tool_choice:
llm.with_structured_output(Schema, tool_choice="auto")

Description: Allow users to pass additional keyword arguments (like tool_choice) to with_structured_output() to avoid 400 errors when the model doesn't trigger a tool call. This aligns ChatGroq.with_structured_output() with ChatOpenAI.with_structured_output() behavior by removing the kwargs restriction and passing them through to bind_tools() and bind() methods.

Issue: Fixes #33995

Dependencies: None

Fixes langchain-ai#33995

Allow users to pass additional kwargs (like tool_choice) to
with_structured_output() to avoid 400 errors when the model
doesn't trigger a tool call. This aligns ChatGroq with ChatOpenAI
behavior.

Users can now override the default tool_choice:
  llm.with_structured_output(Schema, tool_choice="auto")
@github-actions github-actions Bot added integration PR made that is related to a provider partner package integration groq `langchain-groq` package issues & PRs labels Nov 20, 2025
@codspeed

codspeed Bot commented Nov 20, 2025 •

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #34053 will not alter performance

Comparing dumko2001:fix/groq-with-structured-output-kwargs (d803891) with master (8ad0e9f)

Summary

✅ 1 untouched
⏩ 33 skipped1

Footnotes

  1. 33 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@dumko2001 Sidharth Rajmohan (dumko2001) changed the title groq: allow kwargs in with_structured_output to override tool_choice feat(groq): Allow kwargs in with_structured_output to override tool_choice Nov 20, 2025
@github-actions github-actions Bot added the feature For PRs that implement a new feature; NOT A FEATURE REQUEST label Nov 20, 2025
@ccurme ccurme (ccurme) self-assigned this Dec 12, 2025
@ccurme

Copy link
Copy Markdown
Collaborator

I'm not sure this will fix the issue as we are already specifying tool_choice=tool_name.

@ccurme
ccurme (ccurme) merged commit fb892ee into langchain-ai:master Dec 12, 2025
43 checks passed
DreamZhongJu pushed a commit to DreamZhongJu/langchain that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external feature For PRs that implement a new feature; NOT A FEATURE REQUEST groq `langchain-groq` package issues & PRs integration PR made that is related to a provider partner package integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChatGroq setting wrong toolcall flag in resulting API call.

3 participants