Skip to main content

Function: toolResultFrom()

toolResultFrom<TTools>(segment, tools): { [K in string | number | symbol]: TTools[K] extends ZodToolDefinition<TSchema, TReturn> ? MatchedToolResult<K, InferOutput<TSchema>, TReturn> : never }[keyof TTools] | undefined

Defined in: packages/core/src/segments/typed-tool-call.ts:97

Narrow a ToolCallSegment against a set of known tool definitions, matching by name — unlike typedToolCall(), which trusts the caller to hand it the right definition, this checks segment.name against each candidate and returns undefined if none match. Use it when a segment could belong to any tool in a shared map (e.g. a bot's full tools set) instead of one you've already singled out.

Type Parameters

TTools

TTools extends Record<string, ZodToolDefinition<any, any>>

Parameters

segment

ToolCallSegment

tools

TTools

Returns

{ [K in string | number | symbol]: TTools[K] extends ZodToolDefinition<TSchema, TReturn> ? MatchedToolResult<K, InferOutput<TSchema>, TReturn> : never }[keyof TTools] | undefined