Description
fastcore.tools.view() currently declares:
view_range: tuple[int, int] = None
When this is turned into a tool schema via toolslm.funccall.get_schema(), the generated JSON Schema for view_range uses prefixItems without items.
That works for some consumers, but OpenAI rejects it with:
Invalid schema for function 'view': In context=('properties', 'view_range'), array schema missing items.
This breaks downstream tools that expose fastcore.tools.view directly as an OpenAI function/tool, including shell-sage when configured to use OpenAI models.
Reproduction
Environment:
- macOS
shell-sage 1.0.6
fastcore 1.12.33
- also reproduced by inspecting latest
fastcore 1.12.34 source on PyPI
Minimal repro:
from toolslm.funccall import get_schema
from fastcore.tools import view
import json
print(json.dumps(get_schema(view, pname="parameters"), indent=2))
Generated schema includes:
"view_range": {
"type": "array",
"default": null,
"prefixItems": [
{"type": "integer"},
{"type": "integer"}
]
}
OpenAI then rejects the tool schema with:
Invalid schema for function 'view': In context=('properties', 'view_range'), array schema missing items.
Expected
The generated schema should be accepted by OpenAI function/tool calling.
Actual
The generated schema is rejected by OpenAI because the array schema has prefixItems but no items.
Local workaround
Changing the signature to:
view_range: list[int] = None
produces:
"view_range": {
"type": "array",
"items": {"type": "integer"},
"default": null
}
and fixes the issue for OpenAI-backed shell-sage.
Suggested fix
Either:
- change
view_range in fastcore.tools.view() from tuple[int, int] to list[int], or
- update the schema generator so tuple schemas emitted for OpenAI-compatible tool calling also include a valid
items field.
I’m happy to test a fix against shell-sage + OpenAI.
Description
fastcore.tools.view()currently declares:When this is turned into a tool schema via
toolslm.funccall.get_schema(), the generated JSON Schema forview_rangeusesprefixItemswithoutitems.That works for some consumers, but OpenAI rejects it with:
This breaks downstream tools that expose
fastcore.tools.viewdirectly as an OpenAI function/tool, includingshell-sagewhen configured to use OpenAI models.Reproduction
Environment:
shell-sage 1.0.6fastcore 1.12.33fastcore 1.12.34source on PyPIMinimal repro:
Generated schema includes:
OpenAI then rejects the tool schema with:
Expected
The generated schema should be accepted by OpenAI function/tool calling.
Actual
The generated schema is rejected by OpenAI because the array schema has
prefixItemsbut noitems.Local workaround
Changing the signature to:
produces:
and fixes the issue for OpenAI-backed
shell-sage.Suggested fix
Either:
view_rangeinfastcore.tools.view()fromtuple[int, int]tolist[int], oritemsfield.I’m happy to test a fix against
shell-sage+ OpenAI.