View Source Agens.Schema (agens v0.2.0)

JSON Schema fragments used to constrain structured LM responses.

Servings using structured outputs combine these fragments via Agens.Serving.build_schema/1 into a single JSON Schema describing the expected response shape: a body string, a next list of routing instructions, an outputs map, and a tool_calls array modeled after MCP tool calls.

The default Agens.Serving implementation wires each fragment in through the Agens.Serving.response_schema/1, Agens.Serving.outputs_schema/1 and Agens.Serving.tools_schema/1 callbacks - override those callbacks in a Serving to supply a different schema (for example, to declare a Router-specific outputs schema).

Summary

Functions

Returns the default outputs schema fragment.

Returns the base response schema (body + next).

Returns the tool_calls schema fragment modeled after the MCP Tool Calls shape.

Functions

@spec outputs() :: map()

Returns the default outputs schema fragment.

Servings declaring structured outputs typically override Agens.Serving.outputs_schema/1 to return a Router-specific schema derived from Agens.Router.Output.to_json_schema/1.

@spec response() :: map()

Returns the base response schema (body + next).

Used by Agens.Serving.response_schema/1 as the foundation that outputs and tool_calls properties are added onto.

@spec tools() :: map()

Returns the tool_calls schema fragment modeled after the MCP Tool Calls shape.