Represents the result of an agent execution.

// Success case
const result = AgentResult.success(
{ response: "Hello!", sentiment: "positive" },
{ model: "gpt-4", cost: 0.02 }
);

// Failure case
const result = AgentResult.failure(
new Error("API timeout"),
{ model: "gpt-4", stage: "execution" }
);

Type Parameters

  • T

    The type of data returned by the agent

Methods

  • Gets the data or returns a default value if the result is a failure

    Parameters

    • defaultValue: T

      The default value to return on failure

    Returns T

Properties

success: boolean
data: undefined | T
error: undefined | Error
warnings: string[] = []
partial: boolean = false