Skip to content

1.16.0

Latest

Choose a tag to compare

@mozex mozex released this 30 Nov 17:15
· 2 commits to main since this release
Immutable release. Only release title and notes can be modified.
e274e07

What's Changed

  • Structured output from a PHP class: Schema::format(Person::class) builds the JSON schema from the class's constructor (backed enums, nested classes, typed lists, dates, #[Description] and #[Constraints]), sanitized to what the API accepts, for output_config.format.
  • $response->parse(Person::class) checks the reply against the schema as written, constraints included, and builds the class. It takes a schema array too, and a finished stream has parse() as well. A refused, cut-off or invalid reply throws a StructuredOutputException that says which.
  • Schema::sanitize(), Schema::errors() and Schema::hydrate() work on any schema array.
  • Tools from invokable classes and closures: Tool::fromClass(GetWeather::class) and Tool::make('get_weather', fn (string $location) => ...) build the definition from the parameters, and $tool->result($toolUse) runs the tool on Claude's call and returns its tool_result.
  • A tool that throws ToolError answers with is_error: true. Any other exception isn't caught, since its message can hold what Claude shouldn't see.

UPGRADING.md lists the changes that can affect code written against 1.15, such as a subclass of a Messages response that declares parse() with another signature.

Full Changelog: 1.15.0...1.16.0