Skip to content

Commit bd19006

Browse files
fix(react): render array params as list[T] in tools template
Map JSON Schema 'array' type to 'list[T]' for clearer Python-style type hints in the tool descriptions sent to the model. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d6d0dcb commit bd19006

File tree

1 file changed

+11
-1
lines changed
  • src/msgflux/generation/reasoning

1 file changed

+11
-1
lines changed

src/msgflux/generation/reasoning/react.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,19 @@
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+
{%- 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' -%}
42+
list
43+
{%- else -%}
44+
{{ spec.get('type', 'unknown') }}
45+
{%- endif -%}
46+
{%- endmacro -%}
47+
3848
{%- macro render_properties(properties, required, indent=0) -%}
3949
{%- for arg, spec in properties.items() %}
40-
{{ " " * indent }}- {{ arg }} ({{ spec.get('type', 'unknown') }}
50+
{{ " " * indent }}- {{ arg }} ({{ render_type(spec) }}
4151
{%- if arg in required %}, required{% endif %})
4252
{%- if spec.get('description') %}
4353
{{ " " * (indent + 1) }}{{ spec['description'] }}

0 commit comments

Comments
 (0)