Type Alias ToolReturnType<TInput, TConfig, TOutput>

ToolReturnType<TInput, TConfig, TOutput>: TOutput extends DirectToolOutput
    ? TOutput
    : TConfig extends {
            toolCall: {
                id: string;
            };
        }
        ? ToolMessage
        : TConfig extends {
                toolCall: {
                    id: undefined;
                };
            }
            ? TOutput
            : TConfig extends {
                    toolCall: {
                        id?: string;
                    };
                }
                ? TOutput | ToolMessage
                : TInput extends ToolCall
                    ? ToolMessage
                    : TOutput

Conditional type that determines the return type of the StructuredTool.invoke method.

  • If the input is a ToolCall, it returns a ToolMessage
  • If the config is a runnable config and contains a toolCall property, it returns a ToolMessage
  • Otherwise, it returns the original output type

Type Parameters

  • TInput
  • TConfig
  • TOutput