Repository navigation
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, foroutput_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 hasparse()as well. A refused, cut-off or invalid reply throws aStructuredOutputExceptionthat says which.Schema::sanitize(),Schema::errors()andSchema::hydrate()work on any schema array.- Tools from invokable classes and closures:
Tool::fromClass(GetWeather::class)andTool::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 itstool_result. - A tool that throws
ToolErroranswers withis_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