Skip to content

v0.2.0 — first public release

Latest

Choose a tag to compare

@DW-dev-UE DW-dev-UE released this 28 Jul 09:23

First public release of schema2code.

LLM agents normally use tools by emitting JSON tool calls, which means the tool
schemas ride along in every request and each call costs a full API round trip.
schema2code hands the model short function signatures instead and lets it write
one Python program that calls those tools, executed in a restricted sandbox.

Measured on a live A/B

15 tasks × 2 arms, gpt-4o-mini ×3 repeats + gpt-4o ×1, temperature 0, token
counts read from the API usage field:

JSON tool-calling schema2code
Tokens per task 3,319 995 (−70%)
API round trips 3.35 1.15 (−66%)
Accuracy 61.7% 78.3%
Accuracy (gpt-4o only) 80% 100%

Loop-style tasks fell from 4.2 round trips to 1.0. Full method, per-task
tables, and the raw request/response transcripts are in benchmarks/results/.

What's in it

  • ToolRegistry — register plain Python functions; signatures and docs come
    from type hints and docstrings
  • to_prompt() — compact interface in signatures, detailed, or minimal
  • Sandbox — child process, hard timeout, restricted builtins, import
    allowlist, and tool RPC so closures and bound methods work unpickled
  • Escape guards blocking the known introspection breakouts, reported as
    error_type="security" rather than crashes
  • OpenAI / Anthropic schema import with constraints preserved and
    non-identifier names sanitized
  • Call policies, optional argument validation, result cache, async tools,
    token metrics

Zero runtime dependencies, Python 3.10–3.13, tested on Linux and Windows.

Before you rely on it

The sandbox defends against model mistakes, not against an adversary — see
SECURITY.md before exposing it to untrusted input. Below roughly
ten tools the compact interface can cost more tokens than the schemas it
replaces. The measured percentages come from one workload; re-run
benchmarks/bench_v2.py against your own tools.

Docs: usage guide · architecture ·
한국어 README.ko.md · 日本語 README.ja.md