You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
FEATURE: allow specifying tool use none in completion prompt
This PR adds support for disabling further tool calls by setting tool_choice to :none across all supported LLM providers:
- OpenAI: Uses "none" tool_choice parameter
- Anthropic: Uses {type: "none"} and adds a prefill message to prevent confusion
- Gemini: Sets function_calling_config mode to "NONE"
- AWS Bedrock: Doesn't natively support tool disabling, so adds a prefill message
We previously used to disable tool calls by simply removing tool definitions, but this would cause errors with some providers. This implementation uses the supported method appropriate for each provider while providing a fallback for Bedrock.
Co-authored-by: Natalie Tay <[email protected]>
* remove stray puts
* cleaner chain breaker for last tool call (works in thinking)
remove unused code
* improve test
---------
Co-authored-by: Natalie Tay <[email protected]>
# note, Anthropic must never prefill with an ending whitespace
67
+
"I WILL NOT USE TOOLS IN THIS REPLY, user expressed they wanted to stop using tool calls.\nHere is the best, complete, answer I can come up with given the information I have."
68
+
end
69
+
70
+
defself.no_more_tool_calls_text_user
71
+
"DO NOT USE TOOLS IN YOUR REPLY. Return the best answer you can given the information I supplied you."
72
+
end
73
+
74
+
defno_more_tool_calls_text
75
+
self.class.no_more_tool_calls_text
76
+
end
77
+
78
+
defno_more_tool_calls_text_user
79
+
self.class.no_more_tool_calls_text_user
80
+
end
81
+
69
82
deftranslate
70
-
messages=prompt.messages
83
+
messages=trim_messages(prompt.messages)
84
+
last_message=messages.last
85
+
inject_done_on_last_tool_call=false
71
86
72
-
# Some models use an assistant msg to improve long-context responses.
0 commit comments