agent_core

AWS AgentCore Processor Module.

This module defines the AWSAgentCoreProcessor, which invokes agents hosted on Amazon Bedrock AgentCore Runtime and streams their responses as LLMTextFrames.

pipecat.services.aws.agent_core.default_context_to_payload_transformer(context: LLMContext) str | None[source]

Default transformer to create AgentCore payload from LLM context.

Extracts the latest user or system message text and wraps it in {“prompt”: “<text>”}.

Parameters:

context – The LLM context containing conversation messages.

Returns:

A JSON string payload for AgentCore, or None if no valid message found.

pipecat.services.aws.agent_core.default_response_to_output_transformer(response_line: str) str | None[source]

Default transformer to extract output text from AgentCore response.

Expects responses with {“response”: “<text>”} format.

Parameters:

response_line – The raw response line from AgentCore (without “data: “ prefix).

Returns:

The extracted output text, or None if no text found.

class pipecat.services.aws.agent_core.AWSAgentCoreProcessor(agentArn: str, aws_access_key: str | None = None, aws_secret_key: str | None = None, aws_session_token: str | None = None, aws_region: str | None = None, context_to_payload_transformer: Callable[[LLMContext], str | None] | None = None, response_to_output_transformer: Callable[[str], str | None] | None = None, **kwargs)[source]

Bases: FrameProcessor

Processor that runs an Amazon Bedrock AgentCore agent.

Input:
  • LLMContextFrame: Supplies a context used to invoke the agent.

Output:
  • LLMTextFrame: The agent’s text response(s). A single agent invocation may result in multiple text frames.

This processor transforms the input context to a payload for the AgentCore agent, and transforms the agent’s response(s) into output text frame(s). Both mappings are configurable via transformers. Below is the default behavior.

Input transformer (context_to_payload_transformer):
  • Grabs the latest user or system message (if it’s the latest message)

  • Extracts its text content

  • Constructs a payload that looks like {“prompt”: “<text>”}

Output transformer (response_to_output_transformer):
  • Expects responses that look like {“response”: “<text>”}

  • Extracts the text for use in the LLMTextFrame(s)

__init__(agentArn: str, aws_access_key: str | None = None, aws_secret_key: str | None = None, aws_session_token: str | None = None, aws_region: str | None = None, context_to_payload_transformer: Callable[[LLMContext], str | None] | None = None, response_to_output_transformer: Callable[[str], str | None] | None = None, **kwargs)[source]

Initialize the AWS AgentCore processor.

Parameters:
  • agentArn – The Amazon Web Services Resource Name (ARN) of the agent.

  • aws_access_key – AWS access key ID. If None, uses default credentials.

  • aws_secret_key – AWS secret access key. If None, uses default credentials.

  • aws_session_token – AWS session token for temporary credentials.

  • aws_region – AWS region.

  • context_to_payload_transformer – Optional callable to transform LLMContext into AgentCore payload string. If None, uses default_context_to_payload_transformer.

  • response_to_output_transformer – Optional callable to extract output text from AgentCore response. If None, uses default_response_to_output_transformer.

  • **kwargs – Additional arguments passed to parent FrameProcessor.

async process_frame(frame: Frame, direction: FrameDirection)[source]

Process incoming frames and handle LLM message frames.

Parameters:
  • frame – The incoming frame to process.

  • direction – The direction of frame flow in the pipeline.