Fix qwen3_coder tool parser crash on non-numeric int/number params#1330
Open
robertlangdonn wants to merge 1 commit into
Open
Fix qwen3_coder tool parser crash on non-numeric int/number params#1330robertlangdonn wants to merge 1 commit into
robertlangdonn wants to merge 1 commit into
Conversation
_convert_param_value coerces values with int()/float() based on the schema type, but these calls were unguarded: a model that emits a non-numeric string for an integer- or number-typed field (e.g. an ISO 8601 date) raised ValueError, which aborts parsing and drops the entire tool call. Fall back to the raw string when coercion fails, matching how the object/array branch already tolerates unparseable values. A slightly mistyped argument is far better than dropping the call. Relates to ml-explore#1236.
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.
Relates to #1236.
Summary
qwen3_coder._convert_param_valuecoerces parameter values toint()/float()based on the schema type, but those calls are unguarded. When a model emits a non-numeric string for aninteger- ornumber-typed field, the coercion raisesValueError, which aborts parsing and drops the entire tool call.Fix
Fall back to the raw string when
int()/float()coercion fails, matching how the object/array branch already tolerates values that are neither valid JSON nor valid Python literals. A slightly mistyped argument is far better than dropping the call.This complements #1310 / #1239, which guard the
ast.literal_evalbranch of the same function; theint()/float()branches were the remaining unguarded coercions (I noted this while reviewing #1310). Together they close the crash class described in #1236.Testing
test_qwen3_coder_unparseable_numeric_params: a non-numeric value for an int/number field falls back to the raw string, while valid numeric values are still coerced toint/float.tests/test_tool_parsing.pysuite passes.