Skip to content

ToolProvider

Defined in: packages/core/src/tools/provider.ts:102

Tools extends ToolSet = ToolSet

ToolProviderContext = unknown

optional contextSchema?: ZodType<unknown, ToolProviderContext, $ZodTypeInternals<unknown, ToolProviderContext>>

Defined in: packages/core/src/tools/provider.ts:122

Optional — pure introspection metadata, e.g. for a settings UI to build a form from. Never read or parsed by the framework itself; parsing, if you want it, is your own getTools’s job (see createToolProvider’s doc comment for the recipe). agent.tools exposes this on the bound Agent so a caller can find it without knowing which agent it’s looking at.

Typed z.ZodType<unknown, ToolProviderContext> — output left unconstrained (the framework never parses, so there’s nothing to pin it to), but input pinned to ToolProviderContext, the exact raw value getTools receives via ctx.toolProviderContext. So a schema describing a different shape than getTools actually expects is a compile error, not a silent drift — verified via an isolated repro (a mismatched schema is rejected; Tools inference and AgentDefinition.tools, which is never widened, are both unaffected). ToolProviderContext appears fully generic here whether or not this position ends up widened: AgentDefinition.tools never widens at all, and Agent.tools (mirroring it verbatim) widens along with the rest of the agent into AnyAgent — any in every slot, so a concretely-typed contextSchema here needs no separate erasure to tolerate that. AgentRunInput.tools’s bare ToolProvider<Tools> is the one exception, defaulting ToolProviderContext to unknown — not for widening, see ExtendedToolProviderContext’s doc comment.

optional dispose(): MaybePromise<void>

Defined in: packages/core/src/tools/provider.ts:151

Optional — called when this provider instance is going away (outgoing registry after a successful project reload, or LoadedAdlProject.dispose / host unload). Safe to call more than once. Not called at the end of an agent episode — use ToolProvider.onRunEnd.

MaybePromise<void>


getTools(ctx): MaybePromise<Tools>

Defined in: packages/core/src/tools/provider.ts:137

ExtendedToolProviderContext<ToolProviderContext>

MaybePromise<Tools>


optional listTools(): ToolProviderToolSummary[]

Defined in: packages/core/src/tools/provider.ts:136

Optional — static tool names (and descriptions) for a settings UI to list, for a provider whose tool set doesn’t actually vary by call context. Deliberately not passed an ExtendedToolProviderContext: an inspector calling this has no real agentId / memoryScope / toolProviderContext to offer, only a fabricated one, so this exists precisely to avoid needing one. Never read or called by the framework itself — getTools is still the only thing agent.run / agent.stream resolve against.

Skip this when enumerating tool names genuinely requires a resolved context (e.g. the set of tools itself, not just their behavior, differs per toolProviderContext); an inspector should treat a missing listTools as “can’t introspect this provider” rather than guessing by calling getTools with a made-up context.

ToolProviderToolSummary[]


optional onRunEnd(ctx): MaybePromise<void>

Defined in: packages/core/src/tools/provider.ts:144

Optional — called when this agent episode finishes (success, failure, or abort). ctx is the same envelope ToolProvider.getTools received, including ExtendedToolProviderContext.agentCallId. Safe to call when nothing was acquired (no-op). Not called on project reload — use ToolProvider.dispose.

ExtendedToolProviderContext<ToolProviderContext>

MaybePromise<void>