airflow.providers.amazon.aws.hooks.bedrock

Classes

BedrockHook

Interact with Amazon Bedrock.

BedrockRuntimeHook

Interact with the Amazon Bedrock Runtime.

BedrockAgentHook

Interact with the Amazon Agents for Bedrock API.

BedrockAgentRuntimeHook

Interact with the Amazon Agents for Bedrock API.

BedrockAgentCoreControlHook

Interact with the Amazon Bedrock AgentCore control plane API.

BedrockAgentCoreHook

Interact with the Amazon Bedrock AgentCore runtime plane API.

Module Contents

class airflow.providers.amazon.aws.hooks.bedrock.BedrockHook(*args, **kwargs)[source]

Bases: airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook

Interact with Amazon Bedrock.

Provide thin wrapper around boto3.client("bedrock").

Additional arguments (such as aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.

client_type = 'bedrock'[source]
get_guardrail_id_by_name(guardrail_name)[source]

Get the guardrail ID by name, or None if not found.

class airflow.providers.amazon.aws.hooks.bedrock.BedrockRuntimeHook(*args, **kwargs)[source]

Bases: airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook

Interact with the Amazon Bedrock Runtime.

Provide thin wrapper around boto3.client("bedrock-runtime").

Additional arguments (such as aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.

client_type = 'bedrock-runtime'[source]
class airflow.providers.amazon.aws.hooks.bedrock.BedrockAgentHook(*args, **kwargs)[source]

Bases: airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook

Interact with the Amazon Agents for Bedrock API.

Provide thin wrapper around boto3.client("bedrock-agent").

Additional arguments (such as aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.

client_type = 'bedrock-agent'[source]
class airflow.providers.amazon.aws.hooks.bedrock.BedrockAgentRuntimeHook(*args, **kwargs)[source]

Bases: airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook

Interact with the Amazon Agents for Bedrock API.

Provide thin wrapper around boto3.client("bedrock-agent-runtime").

Additional arguments (such as aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.

client_type = 'bedrock-agent-runtime'[source]
class airflow.providers.amazon.aws.hooks.bedrock.BedrockAgentCoreControlHook(*args, **kwargs)[source]

Bases: airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook

Interact with the Amazon Bedrock AgentCore control plane API.

Provide thin wrapper around boto3.client("bedrock-agentcore-control").

Additional arguments (such as aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.

client_type = 'bedrock-agentcore-control'[source]
class airflow.providers.amazon.aws.hooks.bedrock.BedrockAgentCoreHook(*args, **kwargs)[source]

Bases: airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook, airflow.providers.common.ai.managed_agents.base.BaseManagedAgentHook

Interact with the Amazon Bedrock AgentCore runtime plane API.

Provide thin wrapper around boto3.client("bedrock-agentcore").

Additional arguments (such as aws_conn_id and config) may be specified and are passed down to the underlying AwsBaseHook; the connection’s config_kwargs apply as they do for every other AWS hook.

With the common.ai extra installed, the hook also implements the Common AI managed-agent contract, so hook.agent(runtime_arn) can be handed to a ManagedAgentToolset. The agent is the runtime ARN; the session is AgentCore’s runtimeSessionId, which the service requires to be 33 to 256 characters long. A request carrying a prompt is sent as {"prompt": ...} and a request carrying messages as {"messages": [...]}, both as application/json. The container behind the runtime defines its own response shape, so the answer text is taken from the first of output, result, text or response that holds a string, or from the text_key vendor option when the container’s contract is known; otherwise the whole JSON body is returned as text. The decoded body is always available on ManagedAgentResponse.raw.

A remote invocation may have unknown effects, so the contract methods disable botocore’s retries unless the connection or the caller configured them, and let failures propagate to Airflow’s task-level retry instead. ManagedAgentRequest.timeout is honored as the botocore connect and read timeout of the call; a client is built per distinct timeout and reused. AgentCore has no error that means “rephrase the prompt” (a container’s own errors arrive inside a successful body), so the hook raises terminal errors or lets transient ones propagate, never ManagedAgentRejected.

from airflow.providers.amazon.aws.hooks.bedrock import BedrockAgentCoreHook
from airflow.providers.common.ai.toolsets import ManagedAgentToolset

claims = BedrockAgentCoreHook(aws_conn_id="aws_prod", region_name="us-east-1").agent(
    "arn:aws:bedrock-agentcore:us-east-1:123456789012:runtime/claims"
)
toolset = ManagedAgentToolset(
    claims, tool_name="ask_claims_agent", description="...", vendor_options={"text_key": "answer"}
)

Two vendor_options are read by the hook itself rather than forwarded to InvokeAgentRuntime: text_key names the response field that holds the answer text when the container’s contract is known (a body without a string there is an error), and max_response_bytes bounds the body read into worker memory (default 1 MiB). Every other option is passed to the API call as is.

client_type = 'bedrock-agentcore'[source]
agent_platform = 'aws.bedrock_agentcore'[source]

The platform every ManagedAgentRef from this hook carries.

resolve_agent(agent)[source]

Normalize agent into a platform-qualified reference. Must not make a network call.

get_agent_capabilities(agent)[source]

Report what agent on this connection can do. Must not make a network call.

invoke_agent(agent, request)[source]

Send request to agent and return its answer. Blocking.

Was this entry helpful?