SCUA

News

SCUA 0.46.0: tool schemas from your argument records

November 15, 2026

SCUA 0.46.0 is mostly for people writing tools that a model calls. The record a tool declares for its arguments now gives the schema the model reads, in a form that OpenAI's and Anthropic's strict modes accept, and the tool can tell the model about every wrong argument in one reply. The release also brings nested block comments, and portable_math, a set of maths functions that return the same bits on every platform.

#The schema comes from the argument record

A tool that reads its arguments with sys.parse_args(T) declares them once, as a record, and scua schema turns that record into JSON Schema. In this release the schema carries more of what the record says. Doc comments become description, a constant default becomes default, and more where rules have a schema form, among them x == 3, x % 5 == 0 and an exact length.

scua schema --portable writes the part of JSON Schema that both OpenAI's strict mode for structured outputs and Anthropic's strict tool use accept. Every object is closed, every property is required with null standing for "use the default", and the numeric and length limits go into each field's description, where the model still reads them. parse_args still checks every rule.

A server that lists its tools at run time can now get the same document as a value. json.schema(T) is made when the program compiles, from the same declaration, so it can't drift from the type:

import json

-- Look up the weather.
record Weather {
  city: string where city.len() >= 1, -- A city name.
  days: int where days in 1:8 = 1,
}

const TOOLS = [{ name = "weather", inputSchema = json.schema(Weather, { portable = true }) }]
print(json.encode(TOOLS[0].inputSchema))
$ scua tools.scua
{"type":"object","properties":{"city":{"type":"string","description":"A city name.\n\nAt least 1 character."},"days":{"anyOf":[{"type":"integer"},{"type":"null"}],"description":"At least 1, less than 8.\n\nDefault: 1 (send null to use it)."}},"required":["city","days"],"description":"Look up the weather.","additionalProperties":false}

json.schema(Weather) without the option gives the default document, the one scua schema prints without --portable. See The schema as a value.

#Every wrong argument in one reply

By default parse stops at the first field that doesn't fit, so a model that sent three wrong arguments learns about one, fixes it, and finds the next on its second try. With { errors = "all" } the fault lists them all. parse, the typed decoders such as json.decode(text, T, opts), and sys.parse_args all take it:

record Order {
  item: string where item.len() >= 1,
  qty: int where qty in 1:100,
}

let raw: any = { item = "", qty = 500 }
try
  parse(raw, Order, { errors = "all" })
rescue e
  for x in e.errors do print(x.at, "-", x.message) end
end
$ scua order.scua
item - parse(raw, Order): raw.item violates Order's where rule (got )
qty - parse(raw, Order): raw.qty violates Order's where rule (got 500)

e.errors holds each misfit's own record, in the order the fields are declared, and the fault's message has a line for each. Nested records, list elements and, with unknown = "refuse", keys that name no field are reported one by one. A record with a migrate hook still reports only its first misfit, since the hook takes the data whole. Without the option nothing changes. See Every wrong argument at once.

#Block comments nest

Block comments are now written /* ... */, and a /* inside one opens another level, so you can comment out code that already holds comments:

/* Not ready yet:
fn area(r)
  /* pi times r squared */
  return 3.14159 * r * r
end
*/
print("the old area function is commented out")
$ scua comments.scua
the old area function is commented out

A block comment that is never closed is an error at the /* that opened it, where it used to swallow the rest of the file. The editor shows more comments on hover as well: a /* */ comment above a declaration, and docs on record fields and enum variants, in the file that declares them and in the files that import them.

portable_math gives the same results on every platform

math uses the operating system's maths library, which can round the last bit of sin or exp differently from one system to the next. That is enough for a model trained on one machine to score differently on another. import portable_math gives the same functions under the same names, and for the same arguments they return the same bits on macOS, Linux, Windows and WebAssembly, on arm64 and x86-64, with or without the JIT:

import math
import portable_math as pm

print(math.f64_bits(pm.sin(0.5)), math.f64_bits(pm.exp(10.0)))
$ scua pm.scua
4602308182625945072 4671783802770883936

That line is the same on an arm64 Mac, on x86-64 Linux and under the WebAssembly build. Only these functions make the promise: math, ** and the rest of the language are unchanged. See Results that match on every platform.

#Upgrading

  • --[[ ... ]] no longer starts a block comment. It stops the compile with a message pointing at /* ... */, because read as a line comment the lines after it would quietly become code. Replace each --[[ with /* and its ]] with */. A line comment that starts with [[ needs a space after the dashes: -- [[.
  • sort puts every nan after every other number, where it used to leave the numbers around a nan unsorted. min and max give nan when any argument is nan; max(nan, 1.0) used to be 1.0 while max(1.0, nan) was nan. floor, ceil and round of nan now say it has no int value.
  • An http.serve handler, and any task it spawns, can no longer open a listener with net.listen or udp.bind; the request ends with a 500. Open listeners in the program before it calls http.serve. The main script and the partitions it starts listen as before.
  • The server's messages write a size that no unit holds exactly in bytes, as 20,000,000 bytes, where they used to say 19531.25 KiB. Check anything that parses those lines.

#What's next

The next step on the roadmap is still the public package registry: a static index served from a CDN, with a signed transparency log from the first public publish. For the agent runtime, snapshot, fork and replay of agent sessions are designed and queued.

The changelog lists everything in 0.46.0, including the fixes.