Documentation
¶
Overview ¶
Package functool turns a typed Go function into a tool.FuncTool via New and MustNew, deriving the tool's input and output JSON schemas from the function's parameter and return types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustNew ¶
func MustNew[In, Out any](cfg Config, h HandlerFor[In, Out]) tool.FuncTool
MustNew is like New but panics if schema construction fails. It is intended for package-level initialization where a construction failure is a programming error that should surface immediately.
func New ¶
New builds a tool.FuncTool from cfg and the typed handler h. It derives the JSON input schema from In and the output schema from Out, wrapping non-struct inputs and validating arguments before invoking h. It returns an error if either schema cannot be constructed.
Types ¶
type Handler ¶
A Handler handles a call to tools/call.
This is a low-level API. It does not do any pre- or post-processing of the request or result: the params contain raw arguments, no input validation is performed, and the result is returned to the user as-is, without any validation of the output.
type HandlerFor ¶
A HandlerFor handles a call to tools/call with typed arguments and results.
HandlerFor provides significant functionality out of the box, and enforces that the tool conforms to the Agent spec:
- The In type provides a default input schema for the tool.
- The input value is automatically unmarshaled from req.Params.Arguments.
- The input value is automatically validated against its input schema. Invalid input is rejected before getting to the handler.