fix(adapters): only quote string members of Literal in BAMLAdapter schema#10074
fix(adapters): only quote string members of Literal in BAMLAdapter schema#10074nikolauspschuetz wants to merge 1 commit into
Conversation
…hema _render_type_str wrapped every Literal member in double quotes, so Literal[1, 2, 3] rendered as "1" or "2" or "3" and Literal[True, False] as "True" or "False" in the schema shown to the LLM. Ints, bools and None are not strings and should render bare; only string members are quoted. Add a regression test covering mixed string/int/bool Literals.
Greptile SummaryThis PR updates how
Confidence Score: 4/5Mostly safe, with one contained schema-rendering bug to fix. The main change is small and correct for strings, integers, and booleans. The changed
What T-Rex did
Important Files Changed
Reviews (1): Last reviewed commit: "fix(adapters): only quote string members..." | Re-trigger Greptile |
| return " or ".join(f'"{arg}"' for arg in args) | ||
| # Only string members are quoted; ints, bools, and None render bare | ||
| # so the schema shown to the LLM matches how the value is emitted. | ||
| return " or ".join(f'"{arg}"' if isinstance(arg, str) else str(arg) for arg in args) |
There was a problem hiding this comment.
Handle literal nulls
None literals now render as None, while the rest of this schema uses null for absent values (Optional returns or null) and the adapter asks for JSON output. A field like Literal[None, "auto"] would be shown as None or "auto", which does not match the JSON value the model must emit (null) and can mislead the LLM/parser.
Artifacts
Repro: focused Python harness rendering Literal[None, "auto"] with the actual BAMLAdapter code
- Evidence file captured while the check ran.
Repro: command output showing None in the rendered schema and the failed null expectation
- The full error output from the failing run.
_render_type_strwrapped every Literal member in double quotes, soLiteral[1, 2, 3]rendered as"1" or "2" or "3"andLiteral[True, False]as"True"or"False"in the schema shown to the LLM. Ints, bools and None are not strings and should render bare; only string members are quoted. Add a regression test covering mixed string/int/bool Literals.