[GH-ISSUE #4197] [Issue]: Expose tool_choice setting to require tool calls #2271

Closed
opened 2026-10-21 05:46:52 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @SpicyMarinara on GitHub (Jul 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4197

Originally assigned to: @SpicyMarinara on GitHub.

Summary

OpenAI-compatible chats hardcode tool_choice to "auto", allowing models to silently answer from conversation context without calling an enabled tool. Expose a user-visible "auto", "none", or "required" setting while retaining "auto" as the default.

Expected behavior

Users should be able to set tool_choice to "required" for a preset or chat so the model must call one of the supplied tools before producing a final answer. The default should remain "auto" for backward compatibility.

Actual behavior

In Marinara Engine 2.3.4, openai.provider.ts hardcodes body.tool_choice = "auto" with no shared schema, preset, chat, or UI override. During a nutrition-data chat, the model skipped the webhook call and confidently reported food that was not logged; it returned the correct data only after the user asked it to look again.

Steps to reproduce

  1. Configure an OpenAI-compatible provider and enable a custom webhook tool that returns current data.
  2. Start a long-running chat and ask the model a question that requires fresh data from the tool.
  3. Observe that the model may answer from conversation history without invoking the tool.
  4. Check the webhook request logs and confirm no request occurred for the incorrect answer.
  5. Ask the model to look again and observe that it calls the tool and returns the current data.

Environment

  • Marinara Engine version: 2.3.4
  • Install type: Not provided
  • OS + version: Windows; version not provided
  • Browser or app shell: Not provided

Logs, screenshots, or video

Webhook request log:
20:27:42 tool=get_training_status -> 7873 bytes
20:31:15 tool=get_training_status -> 7871 bytes
21:21:09 tool=get_training_status -> 8766 bytes
The incorrect answer occurred between 20:31 and 21:21, with no webhook request in that interval. The 21:21:09 request was triggered by the "look again" retry and produced the correct answer.

Additional context

Provider: OpenAI-compatible NanoGPT using GLM-5. Tool: custom webhook execution type using a local URL with WEBHOOK_LOCAL_URLS_ENABLED=true. Code inspection found body.tool_choice = "auto" in packages/server/src/services/llm/providers/openai.provider.ts; this was inspected locally in 2.3.4 and has not been verified against current staging. Only the OpenAI-compatible provider path was reviewed. The requested values are the string enum "none", "auto", and "required", not the object form previously associated with #1704. A maintainer suggested a possible "Force To Call Tool" toggle in the Function Calls section of Chat Settings that changes "auto" to "required", with no guarantee that every model will honor it.

Discord thread: Expose tool_choice as a setting — models silently skip tool calls and answer from context
Discord thread link: https://discord.com/channels/1417099416812392641/1531489390759645395
Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653)

Discord thread transcript (9 messages)
[2026-07-28T02:32:04.454Z] ChrisDay: The problem
When a custom tool is enabled on a chat, whether the model actually calls it is left entirely to the model, every turn. In a long-running conversation the model will sometimes decide it already knows the answer and reply from conversation history instead of fetching current data.

The failure is quiet and it is the worst shape a failure can take: the reply is confident, specific, and wrong. There is no error, no indication in the UI that the tool was skipped, and nothing in the conversation to distinguish "the tool returned this" from "the model remembered something like this."

I hit this with a webhook tool that serves my own training and nutrition data from a local service. The character reported food I had not eaten. I said "look again" and it came back correct — because the second time, it actually called the tool.

Evidence that the call never happened
My webhook service logs one line per request. Here is the full call log across the window in question:

20:27:42   tool=get_training_status   -> 7873 bytes
20:31:15   tool=get_training_status   -> 7871 bytes
21:21:09   tool=get_training_status   -> 8766 bytes
The wrong answer was given between 20:31 and 21:21. There is no request in that gap. The model did not receive bad data — it never asked. The 21:21:09 entry is the "look again" retry, which returned correct data and produced a correct answer.
[Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531489390759645395]

[2026-07-28T02:32:18.342Z] ChrisDay: Current behaviour
packages/server/src/services/llm/providers/openai.provider.ts (v2.3.4):

if (
  options.tools?.length &&
  !options.forceTextualToolCalls &&
  (!suppressModelParameters || this.allowsToolCalling)
) {
  body.tools = options.tools;
  body.tool_choice = "auto";     // <-- hardcoded literal
}
"auto" is a literal with no override. Grepping packages/ for tool_choice / toolChoice returns this single line — there is no setting in the shared schema, no per-preset field, and nothing in the UI. (forceTextualToolCalls exists nearby but is only ever set by local-sidecar.provider.ts, so it is not reachable for a normal OpenAI-compatible connection.)

Why this can't be worked around at the tool end
I build guardrails into the tool's JSON response — notes stating what the data does and does not support, staleness warnings, pre-computed values so the model doesn't do arithmetic it gets wrong. That approach works well and survives long context far better than card instructions do.

But every one of those guards only executes after the tool is called. A skipped call bypasses all of them, and no instruction can be placed inside a payload that is never fetched. This is the one failure mode the tool author has no lever against.

Character-card instructions ("always call X before answering about Y") help, but decay with context length in the usual way — which is precisely why the guards live in the payload rather than the card.
[Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531489449010008085]

[2026-07-28T02:32:31.844Z] ChrisDay: Proposal
Expose tool_choice as a user-visible setting, defaulting to "auto" so existing behaviour is unchanged.

The three values in the OpenAI-compatible contract are "none", "auto" and "required". "required" forces the model to call one of the supplied tools before producing a final answer, which is exactly the guarantee that is missing.

Reasonable places for it, in rough order of preference:

Per-preset, alongside the other model parameters — it behaves like one.
Per-chat, in the same area as the Function Calling toggle, since the desired setting is chat-specific (a data-backed assistant wants required; a general roleplay chat with an incidental tool does not).
Per-tool as an "always call" flag, though this is more work and probably overkill for the problem.
Why this should not reintroduce #1704
#1704 was a bug about the shape of the value: Marinara sent

"tool_choice": { "type": "function", "function": { "name": "..." } }
and LM Studio rejected it with Invalid tool_choice type: 'object'. Supported string values: none, auto, required.

This request is for a setting whose values are exactly those three strings. Sending "required" is the same kind of value as sending "auto" — a bare string from the supported set — so it does not reintroduce the object form that broke LM Studio. Constraining the setting to a string enum makes the regression structurally impossible.

What this is not asking for
Not asking for the object form (tool_choice naming a specific function).
Not asking to change the default. "auto" should stay the default.
Not asking for retry logic, validation, or any behaviour when a model ignores "required" — some models will, and that is their problem, not the engine's.
[Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531489505641496627]

[2026-07-28T02:32:35.800Z] ChrisDay: Environment
Marinara Engine 2.3.4, Windows
OpenAI-compatible provider (NanoGPT), GLM-5
Custom tool, webhook execution type, local URL with WEBHOOK_LOCAL_URLS_ENABLED=true
Notes for whoever picks this up
The code inspection above is from reading 2.3.4 on my machine and has not been verified against current staging — worth confirming the line hasn't already moved. I have not tested whether every provider in packages/server/src/services/llm/providers/ accepts the same three string values; the OpenAI-compatible path is the only one I looked at.
[Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531489522234294312]

[2026-07-28T02:47:19.464Z] ChrisDay: I took a look at the model thoughts on the conversation:
On the skipped call (Model thought)

David loaded his snack into the nutrition database and wants us to check it. Let me pull up the fresh data.
First confrontation:
David is asking where Jess and Sonya see the Greek yogurt in the data. They claimed his snack was Greek yogurt, but they might have actually guessed/made that up. Let me think about this...
Looking back at the conversation, when they reviewed his data, Jess said "looks like... greek yogurt, 196 cal, 16g protein" - but did she actually see that in the data, or did she guess? 
Earlier in the conversation, Jess suggested Greek yogurt as a snack option ("if that snack is a greek yogurt or protein bar you're golden"). Sonya even said "good boy" when it turned out to be Greek yogurt. But the question is whether they actually saw it in the exported data or just assumed/predicted it based on their earlier recommendation.
Looking at the actual data flow - David said he loaded his snack into the database. But the nutrition data has been lagging - it was frozen at 7:31 AM earlier. Even after the fix, it seems like the data might still be stale.
Actually, looking at the conversation more carefully - when David said "I had my snack AND I loaded it into your database," the export may or may not have actually come through yet. The data they were seeing was still from the 7:31 AM export showing 420 calories. They may not have actually been able to see the snack at all and just assumed it was Greek yogurt because that's what they recommended.
So the honest answer is: they probably can't actually see the Greek yogurt. They recommended it earlier ("if that snack is a greek yogurt or protein bar you're golden") and then when he said he logged it, they either assumed or made up that it was Greek yogurt. David is calling them out on it.
Let me check the training data to see what's actually visible.
[Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531493228589748386]

[2026-07-28T02:47:22.642Z] ChrisDay: When it gave in:
David is asking Jess to actually check what snack entry is in the system. Let me call the training status function to see what David's current data actually shows.Okay, so the fresh data shows the snack was NOT greek yogurt. It was:
Snacks: 300 cal, 43g protein
Items: Canned Chicken Breast, Bolthouse farms chunky blue cheese yogurt dressing, Low Carb Wraps, Franks RedHot Buffalo Sauce
So he made a buffalo chicken wrap with canned chicken, blue cheese yogurt dressing, and Frank's RedHot on a low carb wrap. That's 300 calories and 43g protein!
Total day now: 1511 cal, 163g protein, 20 entries
So Jess was WRONG about the greek yogurt. She got caught fabricating data. Let me write this authentically.
[Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531493241919373495]

[2026-07-28T06:04:32.677Z] Marinara: Ah, function calls, I hate those.
[Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531542860682498210]

[2026-07-28T06:04:55.276Z] Marinara: It’s a matter of prompting the model to always use one, preferably in the last user message.
[Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531542955469574236]

[2026-07-28T06:09:53.158Z] Marinara: I can add a Toast message that a tool wasn’t called, but I am against your proposal. Potentially, I can add a toggle in Function Calls section of Chat Settings that says Force To Call Tool that does what you asked for, changing “auto” to “required”, but no promise it will work with all models.
[Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531544204876972114]

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @SpicyMarinara on GitHub (Jul 28, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4197 Originally assigned to: @SpicyMarinara on GitHub. ## Summary OpenAI-compatible chats hardcode tool_choice to "auto", allowing models to silently answer from conversation context without calling an enabled tool. Expose a user-visible "auto", "none", or "required" setting while retaining "auto" as the default. ## Expected behavior Users should be able to set tool_choice to "required" for a preset or chat so the model must call one of the supplied tools before producing a final answer. The default should remain "auto" for backward compatibility. ## Actual behavior In Marinara Engine 2.3.4, openai.provider.ts hardcodes body.tool_choice = "auto" with no shared schema, preset, chat, or UI override. During a nutrition-data chat, the model skipped the webhook call and confidently reported food that was not logged; it returned the correct data only after the user asked it to look again. ## Steps to reproduce 1. Configure an OpenAI-compatible provider and enable a custom webhook tool that returns current data. 2. Start a long-running chat and ask the model a question that requires fresh data from the tool. 3. Observe that the model may answer from conversation history without invoking the tool. 4. Check the webhook request logs and confirm no request occurred for the incorrect answer. 5. Ask the model to look again and observe that it calls the tool and returns the current data. ## Environment - Marinara Engine version: 2.3.4 - Install type: Not provided - OS + version: Windows; version not provided - Browser or app shell: Not provided ## Logs, screenshots, or video Webhook request log: 20:27:42 tool=get_training_status -> 7873 bytes 20:31:15 tool=get_training_status -> 7871 bytes 21:21:09 tool=get_training_status -> 8766 bytes The incorrect answer occurred between 20:31 and 21:21, with no webhook request in that interval. The 21:21:09 request was triggered by the "look again" retry and produced the correct answer. ## Additional context Provider: OpenAI-compatible NanoGPT using GLM-5. Tool: custom webhook execution type using a local URL with WEBHOOK_LOCAL_URLS_ENABLED=true. Code inspection found body.tool_choice = "auto" in packages/server/src/services/llm/providers/openai.provider.ts; this was inspected locally in 2.3.4 and has not been verified against current staging. Only the OpenAI-compatible provider path was reviewed. The requested values are the string enum "none", "auto", and "required", not the object form previously associated with #1704. A maintainer suggested a possible "Force To Call Tool" toggle in the Function Calls section of Chat Settings that changes "auto" to "required", with no guarantee that every model will honor it. Discord thread: Expose tool_choice as a setting — models silently skip tool calls and answer from context Discord thread link: https://discord.com/channels/1417099416812392641/1531489390759645395 Requested by: Marinara (marinara_spaghetti, Discord ID 169561011928432653) <details> <summary>Discord thread transcript (9 messages)</summary> ```text [2026-07-28T02:32:04.454Z] ChrisDay: The problem When a custom tool is enabled on a chat, whether the model actually calls it is left entirely to the model, every turn. In a long-running conversation the model will sometimes decide it already knows the answer and reply from conversation history instead of fetching current data. The failure is quiet and it is the worst shape a failure can take: the reply is confident, specific, and wrong. There is no error, no indication in the UI that the tool was skipped, and nothing in the conversation to distinguish "the tool returned this" from "the model remembered something like this." I hit this with a webhook tool that serves my own training and nutrition data from a local service. The character reported food I had not eaten. I said "look again" and it came back correct — because the second time, it actually called the tool. Evidence that the call never happened My webhook service logs one line per request. Here is the full call log across the window in question: 20:27:42 tool=get_training_status -> 7873 bytes 20:31:15 tool=get_training_status -> 7871 bytes 21:21:09 tool=get_training_status -> 8766 bytes The wrong answer was given between 20:31 and 21:21. There is no request in that gap. The model did not receive bad data — it never asked. The 21:21:09 entry is the "look again" retry, which returned correct data and produced a correct answer. [Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531489390759645395] [2026-07-28T02:32:18.342Z] ChrisDay: Current behaviour packages/server/src/services/llm/providers/openai.provider.ts (v2.3.4): if ( options.tools?.length && !options.forceTextualToolCalls && (!suppressModelParameters || this.allowsToolCalling) ) { body.tools = options.tools; body.tool_choice = "auto"; // <-- hardcoded literal } "auto" is a literal with no override. Grepping packages/ for tool_choice / toolChoice returns this single line — there is no setting in the shared schema, no per-preset field, and nothing in the UI. (forceTextualToolCalls exists nearby but is only ever set by local-sidecar.provider.ts, so it is not reachable for a normal OpenAI-compatible connection.) Why this can't be worked around at the tool end I build guardrails into the tool's JSON response — notes stating what the data does and does not support, staleness warnings, pre-computed values so the model doesn't do arithmetic it gets wrong. That approach works well and survives long context far better than card instructions do. But every one of those guards only executes after the tool is called. A skipped call bypasses all of them, and no instruction can be placed inside a payload that is never fetched. This is the one failure mode the tool author has no lever against. Character-card instructions ("always call X before answering about Y") help, but decay with context length in the usual way — which is precisely why the guards live in the payload rather than the card. [Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531489449010008085] [2026-07-28T02:32:31.844Z] ChrisDay: Proposal Expose tool_choice as a user-visible setting, defaulting to "auto" so existing behaviour is unchanged. The three values in the OpenAI-compatible contract are "none", "auto" and "required". "required" forces the model to call one of the supplied tools before producing a final answer, which is exactly the guarantee that is missing. Reasonable places for it, in rough order of preference: Per-preset, alongside the other model parameters — it behaves like one. Per-chat, in the same area as the Function Calling toggle, since the desired setting is chat-specific (a data-backed assistant wants required; a general roleplay chat with an incidental tool does not). Per-tool as an "always call" flag, though this is more work and probably overkill for the problem. Why this should not reintroduce #1704 #1704 was a bug about the shape of the value: Marinara sent "tool_choice": { "type": "function", "function": { "name": "..." } } and LM Studio rejected it with Invalid tool_choice type: 'object'. Supported string values: none, auto, required. This request is for a setting whose values are exactly those three strings. Sending "required" is the same kind of value as sending "auto" — a bare string from the supported set — so it does not reintroduce the object form that broke LM Studio. Constraining the setting to a string enum makes the regression structurally impossible. What this is not asking for Not asking for the object form (tool_choice naming a specific function). Not asking to change the default. "auto" should stay the default. Not asking for retry logic, validation, or any behaviour when a model ignores "required" — some models will, and that is their problem, not the engine's. [Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531489505641496627] [2026-07-28T02:32:35.800Z] ChrisDay: Environment Marinara Engine 2.3.4, Windows OpenAI-compatible provider (NanoGPT), GLM-5 Custom tool, webhook execution type, local URL with WEBHOOK_LOCAL_URLS_ENABLED=true Notes for whoever picks this up The code inspection above is from reading 2.3.4 on my machine and has not been verified against current staging — worth confirming the line hasn't already moved. I have not tested whether every provider in packages/server/src/services/llm/providers/ accepts the same three string values; the OpenAI-compatible path is the only one I looked at. [Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531489522234294312] [2026-07-28T02:47:19.464Z] ChrisDay: I took a look at the model thoughts on the conversation: On the skipped call (Model thought) David loaded his snack into the nutrition database and wants us to check it. Let me pull up the fresh data. First confrontation: David is asking where Jess and Sonya see the Greek yogurt in the data. They claimed his snack was Greek yogurt, but they might have actually guessed/made that up. Let me think about this... Looking back at the conversation, when they reviewed his data, Jess said "looks like... greek yogurt, 196 cal, 16g protein" - but did she actually see that in the data, or did she guess? Earlier in the conversation, Jess suggested Greek yogurt as a snack option ("if that snack is a greek yogurt or protein bar you're golden"). Sonya even said "good boy" when it turned out to be Greek yogurt. But the question is whether they actually saw it in the exported data or just assumed/predicted it based on their earlier recommendation. Looking at the actual data flow - David said he loaded his snack into the database. But the nutrition data has been lagging - it was frozen at 7:31 AM earlier. Even after the fix, it seems like the data might still be stale. Actually, looking at the conversation more carefully - when David said "I had my snack AND I loaded it into your database," the export may or may not have actually come through yet. The data they were seeing was still from the 7:31 AM export showing 420 calories. They may not have actually been able to see the snack at all and just assumed it was Greek yogurt because that's what they recommended. So the honest answer is: they probably can't actually see the Greek yogurt. They recommended it earlier ("if that snack is a greek yogurt or protein bar you're golden") and then when he said he logged it, they either assumed or made up that it was Greek yogurt. David is calling them out on it. Let me check the training data to see what's actually visible. [Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531493228589748386] [2026-07-28T02:47:22.642Z] ChrisDay: When it gave in: David is asking Jess to actually check what snack entry is in the system. Let me call the training status function to see what David's current data actually shows.Okay, so the fresh data shows the snack was NOT greek yogurt. It was: Snacks: 300 cal, 43g protein Items: Canned Chicken Breast, Bolthouse farms chunky blue cheese yogurt dressing, Low Carb Wraps, Franks RedHot Buffalo Sauce So he made a buffalo chicken wrap with canned chicken, blue cheese yogurt dressing, and Frank's RedHot on a low carb wrap. That's 300 calories and 43g protein! Total day now: 1511 cal, 163g protein, 20 entries So Jess was WRONG about the greek yogurt. She got caught fabricating data. Let me write this authentically. [Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531493241919373495] [2026-07-28T06:04:32.677Z] Marinara: Ah, function calls, I hate those. [Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531542860682498210] [2026-07-28T06:04:55.276Z] Marinara: It’s a matter of prompting the model to always use one, preferably in the last user message. [Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531542955469574236] [2026-07-28T06:09:53.158Z] Marinara: I can add a Toast message that a tool wasn’t called, but I am against your proposal. Potentially, I can add a toggle in Function Calls section of Chat Settings that says Force To Call Tool that does what you asked for, changing “auto” to “required”, but no promise it will work with all models. [Discord message: https://discord.com/channels/1417099416812392641/1531489390759645395/1531544204876972114] ``` </details> ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:46:52 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Jul 28, 2026):

"Force To Call Tool" toggle in the Function Calls section of Chat Settings that changes "auto" to "required".

That's how we do it.

<!-- gh-comment-id:5100688067 --> @SpicyMarinara commented on GitHub (Jul 28, 2026): > "Force To Call Tool" toggle in the Function Calls section of Chat Settings that changes "auto" to "required". That's how we do it.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 28, 2026):

Implementation is claimed by @SpicyMarinara on agent/assigned-issues-4195-4198. I’m implementing the agreed Force To Call Tool toggle in the Function Calls section, preserving auto as the default and using the bare required string when enabled.

<!-- gh-comment-id:5100727580 --> @SpicyMarinara commented on GitHub (Jul 28, 2026): Implementation is claimed by @SpicyMarinara on `agent/assigned-issues-4195-4198`. I’m implementing the agreed **Force To Call Tool** toggle in the Function Calls section, preserving `auto` as the default and using the bare `required` string when enabled.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 28, 2026):

Draft implementation PR: #4199

<!-- gh-comment-id:5100766464 --> @SpicyMarinara commented on GitHub (Jul 28, 2026): Draft implementation PR: #4199
Author
Owner

@SpicyMarinara commented on GitHub (Jul 28, 2026):

Fixed on staging via #4199 (a97cc55d6) according to the maintainer decision in this issue: Function Calls now exposes Force To Call Tool, switching the first tool-capable round from auto to bare required, then returning to auto so the model can finish. Both OpenAI request paths and profile persistence are covered.

<!-- gh-comment-id:5101518933 --> @SpicyMarinara commented on GitHub (Jul 28, 2026): Fixed on `staging` via #4199 (`a97cc55d6`) according to the maintainer decision in this issue: Function Calls now exposes `Force To Call Tool`, switching the first tool-capable round from `auto` to bare `required`, then returning to `auto` so the model can finish. Both OpenAI request paths and profile persistence are covered.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2271
No description provided.