API Reference
    Preparing search index...

    Class representing a response from a Bedrock agent function.

    You can use this class to customize the response sent back to the Bedrock agent with additional fields like:

    • session attributes
    • prompt session attributes
    • response state (FAILURE or REPROMPT)

    When working with the BedrockAgentFunctionResolver class, this is built automatically when you return anything from your function handler other than an instance of this class.

    Index

    Constructors

    Properties

    body: string

    The response object that defines the response from execution of the function.

    knowledgeBasesConfiguration?: Record<string, JSONValue>

    Optional field to configure knowledge bases for the agent.

    Bedrock Agent Knowledge Bases for more details.

    promptSessionAttributes: Record<string, JSONValue>

    Optional field to instruct the agent to prompt attributes and their values.

    responseState?: ResponseState

    Optional field to indicate the whether the response is a failure or a reprompt. If not provided, the default is undefined, which means no specific response state is set.

    • FAILURE: The agent throws a DependencyFailedException for the current session.
    • REPROMPT: The agent passes a response string to the model to reprompt it.
    sessionAttributes: Record<string, JSONValue>

    Optional field to store session attributes and their values.

    Methods

    • Builds the Bedrock function response object according to the Bedrock agent function response format.

      Parameters

      • options: { actionGroup: string; func: string }

        The options for building the response.

        • actionGroup: string

          The action group of the function, this comes from the event.actionGroup field in the Bedrock agent function event.

        • func: string

          The name of the function being invoked by the agent, this comes from the event.function field in the Bedrock agent function event.

      Returns {
          knowledgeBasesConfiguration?: Record<string, JSONValue>;
          messageVersion: string;
          promptSessionAttributes: Record<string, JSONValue>;
          response: {
              actionGroup: string;
              function: string;
              functionResponse: {
                  responseBody: { TEXT: { body: string } };
                  responseState?: ResponseState;
              };
          };
          sessionAttributes: Record<string, JSONValue>;
      }