Skip to content

fix: use SetFunctionCallNameString when forcing a specific tool (3 sites)#9526

Merged
mudler merged 3 commits intomudler:masterfrom
Anai-Guo:fix/tool_choice-wrong-setter
Apr 24, 2026
Merged

fix: use SetFunctionCallNameString when forcing a specific tool (3 sites)#9526
mudler merged 3 commits intomudler:masterfrom
Anai-Guo:fix/tool_choice-wrong-setter

Conversation

@Anai-Guo
Copy link
Copy Markdown
Contributor

Summary

Follows up on #9509 (merged) which fixed the same bug in MergeOpenResponsesConfig.

Three additional call sites were using SetFunctionCallString(name) (which writes the mode field, e.g. "none"/"auto"/"required") when they should be using SetFunctionCallNameString(name) (which writes the specific function name field read by ShouldCallSpecificFunction / FunctionToCall).

Net effect of the original code: when a caller sends tool_choice: {type: "function", function: {name: "my_tool"}} via these three endpoints, the grammar-based forcing is silently never engaged because the name ends up in the wrong config field.

Sites fixed

File Line Endpoint
core/http/endpoints/anthropic/messages.go 883 Anthropic /v1/messages
core/http/endpoints/openai/realtime_model.go 171 OpenAI Realtime
core/http/endpoints/openresponses/responses.go 776 /v1/responses (non-middleware path)

In each case the change is:

- cfg.SetFunctionCallString(name)
+ cfg.SetFunctionCallNameString(name)

Tracked in issue #9508.

Test plan

  • Send tool_choice: {"type": "function", "function": {"name": "my_tool"}} via Anthropic /v1/messages endpoint and verify grammar-based forcing engages
  • Same via OpenAI Realtime endpoint
  • Same via /v1/responses endpoint

🤖 Generated with Claude Code

@mudler mudler merged commit 5e062b4 into mudler:master Apr 24, 2026
1 check passed
Anai-Guo added a commit to Anai-Guo/LocalAI that referenced this pull request Apr 25, 2026
Follows up on mudler#9526 (the 3-site setter fix) by addressing the remaining
clause in mudler#9508 — string mode and OpenAI-spec specific-function shape both
silently failed in the /v1/chat/completions parsing path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants