fix: strip null values from tool call args to prevent Jinja template errors#12236
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
fix: strip null values from tool call args to prevent Jinja template errors#12236roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
…errors Local models using Jinja chat templates (e.g. llama.cpp, Ollama) cannot handle null values in tool call arguments, causing "Cannot convert value of type Optional<Any> to Jinja Value" errors when selecting follow-up answers. Changes: - Remove strict mode from ask_followup_question tool definition and make mode optional (not required), matching the read_command_output pattern - Update examples to omit mode instead of using null - Strip null mode values when building follow_up JSON in the tool - Strip null values from all tool call arguments during OpenAI message serialization as a general safety net - Add tests for null stripping behavior Addresses #12233
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR attempts to address Issue #12233.
Problem
Local models using Jinja chat templates (e.g. llama.cpp, Ollama) cannot handle
nullvalues in tool call arguments, causing:This happens because the
ask_followup_questiontool schema requiresmodewithtype: ["string", "null"]andstrict: true, forcing models to output"mode": null. When this tool call appears in conversation history and gets serialized back to the model, the Jinja template fails on the null value.Changes
Tool schema (
ask_followup_question.ts): Removedstrict: trueand mademodeoptional (not required), following the same pattern asread_command_output. Updated examples to omitmodeinstead of usingnull.Tool execution (
AskFollowupQuestionTool.ts): Strip nullmodevalues when building the follow-up JSON to prevent nulls from reaching the conversation history.Message serialization (
openai-format.ts): Strip null values from ALL tool call arguments during OpenAI message conversion as a general safety net. This prevents any tool from inadvertently sending null values to Jinja templates.Tests: Added tests verifying null mode stripping in both tool execution and message serialization.
Feedback and guidance are welcome.
Interactively review PR in Roo Code Cloud