invokeStructured
Auto-generated API reference for invokeStructured.
Function: invokeStructured()
invokeStructured<
T>(opts):Promise<T>
Defined in: structured.ts:22
Run a skill that must produce STRUCTURED output, and return it validated β the
first-class version of the pattern every pipeline agent hand-rolls (offer one
submit_* tool, run, read it back from result.toolCalls, parse).
The model's only job is to call tool once; execute just acknowledges. The
parse callback validates the args (e.g. (a) => MySchema.parse(a) with Zod) so
this stays dependency-free β the runtime never imports Zod.
const cls = await invokeStructured({
adapter, skill: classifier, task,
tool: submitClassificationTool,
parse: (args) => Classification.parse(args),
})#Type Parameters
#T
T
#Parameters
#opts
#adapter
AdapterFactory
#maxSteps?
number
#memory?
ChatMemory
#observers?
Observer[]
#onConfirm?
(toolCall) => boolean | Promise<boolean>
#parse
(args) => T
Validate + shape the tool args (throws on invalid).
#signal?
AbortSignal
#skill?
SkillDefinition
#task
string
#tool
ToolDefinition
The submit tool the skill must call exactly once.
#tools?
ToolDefinition<Record<string, unknown>>[]
Extra tools available during the run (besides tool).
#Returns
Promise<T>