fix: coerce string follow_up to array in ask_followup_question tool#12234
Draft
roomote-v0[bot] wants to merge 2 commits intomainfrom
Draft
fix: coerce string follow_up to array in ask_followup_question tool#12234roomote-v0[bot] wants to merge 2 commits intomainfrom
roomote-v0[bot] wants to merge 2 commits intomainfrom
Conversation
Some models (e.g. Qwen3.6 35B-A3B) output the follow_up parameter as a string instead of the required array format. This adds a coerceFollowUp helper that normalizes: - JSON strings that parse to arrays - Plain strings (wrapped as single suggestion) - Existing arrays (passed through unchanged) Applied in AskFollowupQuestionTool.execute() and both partial/finalize handlers in NativeToolCallParser. Closes #12233
Open
|
@roomote After this change, model can call ask_followup_question correctly. However, when I choose an answer, my model gives an error: Chat template error: Runtime error: Cannot convert value of type Optional to Jinja Value |
Contributor
Author
Fixed the Jinja template error by ensuring all coerced |
The tool schema requires mode on each suggestion item (required: ["text", "mode"]). When follow_up was coerced from a string, the mode field was missing entirely. Some model Jinja templates (e.g. Qwen via llama.cpp) fail with "Cannot convert value of type Optional<Any> to Jinja Value" when a required field is absent from tool call arguments in conversation history. Now all coercion paths (coerceFollowUp helper + NativeToolCallParser partial and finalization handlers) normalize every suggestion to include mode: null when not explicitly set.
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.
Related GitHub Issue
Closes: #12233
Description
This PR attempts to address Issue #12233. Feedback and guidance are welcome.
Some models (e.g. Qwen3.6 35B-A3B) output the
follow_upparameter ofask_followup_questionas a string instead of the required array format. This causes the tool call to fail with a missing parameter error.Changes:
Added
coerceFollowUp()helper inAskFollowupQuestionTool.tsthat normalizesfollow_upfrom various formats into the expectedSuggestion[]:[{ text: value }]Updated
AskFollowupQuestionTool.execute()to apply coercion before the array check.Updated
NativeToolCallParser.tsin both the partial streaming handler (createPartialToolUse) and finalization handler (finalizeStreamingToolCall) to coerce stringfollow_upvalues to arrays.Added/updated tests covering:
coerceFollowUphelper function itselfTest Procedure
cd src && npx vitest run core/tools/__tests__/askFollowupQuestionTool.spec.tsPre-Submission Checklist
Documentation Updates
Additional Notes
This fix is backwards-compatible. Models that already produce arrays are unaffected. Models that produce strings will now have their output gracefully coerced into the expected format.
Interactively review PR in Roo Code Cloud