Repository navigation
Conversation
Preserve string enum display and serialize other values as JSON. Add regression coverage for flat and OpenAI-wrapped tools. Assisted-by: OpenAI Codex
ErenAta16
left a comment
There was a problem hiding this comment.
Checked by loading tool_utils.py from main and from this head and calling the default tool_formatter on both (I could not run the pytest module here because the test package imports trl).
String enums are byte-identical to main for ["small", "large"], ["a, b", "c"], ["默认", "x"], ["1", "2"] and the empty list, both flat and OpenAI-wrapped, so existing prompts do not change. For non-string enums main raises TypeError: sequence item 0: expected str instance on [1, 2, 3], [0.5, 1.5], [True, False], [None] and on dict or list members; this head renders 1, 2, 3, 0.5, 1.5, true, false, null and {"a": 1}, [1, 2]. Flat and wrapped tools render the same. The enum join in tool_formatter is the only place in this file that formats enum values, so no sibling site needs the same change.
Nothing blocking. One optional observation: a mixed enum such as ["1", 1] renders as [1, 1], so the prompt cannot tell the string "1" from the integer 1. Leaving strings unquoted is what keeps existing prompts unchanged, so I would keep it; a sentence in the docstring or the PR description would be enough.
Preserve string enum display and serialize other values as JSON. Add regression coverage for flat and OpenAI-wrapped tools.