mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-23 14:04:18 +02:00
Fix tool_choice reset for structured output sampling
Preserve tool_choice='required' when result_type is set to ensure LLM calls final_response instead of returning text responses. Fixes #3011 Co-authored-by: Bill Easton <strawgate@users.noreply.github.com>
This commit is contained in:
parent
fdc96f323a
commit
cfba439417
1 changed files with 3 additions and 2 deletions
|
|
@ -634,7 +634,8 @@ async def sample_impl(
|
|||
# Continue with the updated history
|
||||
current_messages = step.history
|
||||
|
||||
# After first iteration, reset tool_choice to auto
|
||||
tool_choice = None
|
||||
# After first iteration, reset tool_choice to auto (unless structured output is required)
|
||||
if result_type is None or result_type is str:
|
||||
tool_choice = None
|
||||
|
||||
raise RuntimeError(f"Sampling exceeded maximum iterations ({max_iterations})")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue