Skip to content

Commit 4e4c0d3

Browse files
fix(react): map JSON Schema types to Python types in tools template
Map integer->int, number->float, boolean->bool for clearer type hints in tool descriptions. Also applies inside list[T] generics. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bd19006 commit 4e4c0d3

File tree

1 file changed

+7
-4
lines changed
  • src/msgflux/generation/reasoning

1 file changed

+7
-4
lines changed

src/msgflux/generation/reasoning/react.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@
3535
to assist with the user query. Don't make assumptions about what values
3636
to plug into functions. Here are the available tools:
3737
38+
{%- set type_map = {"integer": "int", "number": "float", "string": "string", "boolean": "bool", "object": "object"} -%}
3839
{%- macro render_type(spec) -%}
39-
{%- if spec.get('type') == 'array' and spec.get('items') -%}
40-
list[{{ spec['items'].get('type', 'unknown') }}]
41-
{%- elif spec.get('type') == 'array' -%}
40+
{%- set raw = spec.get('type', 'unknown') -%}
41+
{%- set mapped = type_map.get(raw, raw) -%}
42+
{%- if raw == 'array' and spec.get('items') -%}
43+
list[{{ type_map.get(spec['items'].get('type', 'unknown'), spec['items'].get('type', 'unknown')) }}]
44+
{%- elif raw == 'array' -%}
4245
list
4346
{%- else -%}
44-
{{ spec.get('type', 'unknown') }}
47+
{{ mapped }}
4548
{%- endif -%}
4649
{%- endmacro -%}
4750

0 commit comments

Comments
 (0)