ExAgent.Schema (ExAgent v0.1.0)

Copy Markdown View Source

Convert Elixir type expressions (as written in :: annotations / typespecs) into JSON Schema fragments — the foundation for deftool and structured output.

This is deliberately a subset: it covers the common scalar/collection types a tool signature or output schema uses. Anything it can't resolve collapses to an unconstrained %{} ("any"), which is safe for the model and easy to spot.

Summary

Functions

Convert a single type AST node to a JSON Schema fragment.

Build a JSON Schema object for a list of {name, type_ast} params.

Functions

from_type(atom)

@spec from_type(Macro.t() | nil) :: map()

Convert a single type AST node to a JSON Schema fragment.

object_schema(params)

@spec object_schema([{atom(), Macro.t() | nil}]) :: map()

Build a JSON Schema object for a list of {name, type_ast} params.

All params are marked required by default (tool signatures have no defaults in this iteration); the model is expected to supply every one.