fix(kimi_k25): emit JSON literals for bool/null in tool schema rendering#55
Open
zafstojano wants to merge 1 commit into
Open
fix(kimi_k25): emit JSON literals for bool/null in tool schema rendering#55zafstojano wants to merge 1 commit into
zafstojano wants to merge 1 commit into
Conversation
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.
Summary
Two cosmetic bugs in
renderers/kimi_k25.pycaused the TypeScript-style tool renderer to leak Python literals (True/False/None) into output that is advertised as TypeScript. Both share the same root cause: Python'sstr()/repr()produce capitalized literals where JSON / TS expect lower-case (true/false/null)._EnumType.to_typescript_stylefell through tostr(e)for non-string enum members, sonull/true/falseenum values rendered asNone/True/False._TypedParam.to_typescript_stylerouted numeric and boolean defaults throughrepr(), which is correct for ints/floats but wrong for bools (repr(True) == "True").Fix
Route everything through
json.dumps, which already produces correct JSON / TS-compatible syntax for ints, floats, bools,None, strings, lists, and dicts. The string branch in_EnumTypeis kept as-is to preserve the existing quoting style.Minimal Example for Repro
Before
After
Note
Low Risk
Low risk: small, localized formatting change to tool schema TypeScript string rendering; behavior only affects emitted declarations, not parsing or model I/O.
Overview
Fixes Kimi K2.5 TypeScript-style tool schema output so non-string enum values and parameter defaults are always rendered via
json.dumps, producingtrue/false/nullinstead of PythonTrue/False/None.This changes
_EnumType.to_typescript_styleand_TypedParam.to_typescript_styleto consistently emit JSON literals for booleans/null (and other non-string values) in generated tool declarations.Reviewed by Cursor Bugbot for commit 9e1d2c4. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix bool/null rendering in Kimi K2.5 tool schema to emit JSON literals instead of Python repr
In kimi_k25.py, enum values and parameter defaults were serialized using Python's
str()/repr(), producing Python-specific output likeTrue/False/Noneinstead of valid JSON literalstrue/false/null. Both_EnumType.to_typescript_styleand_TypedParam.to_typescript_stylenow usejson.dumps()for all non-string values.Macroscope summarized 9e1d2c4.