aws-cdk.aws-bedrock-alpha


Nameaws-cdk.aws-bedrock-alpha JSON
Version 2.206.0a0 PyPI version JSON
download
home_pagehttps://github.com/aws/aws-cdk
SummaryThe CDK Construct Library for Amazon Bedrock
upload_time2025-07-16 12:48:39
maintainerNone
docs_urlNone
authorAmazon Web Services
requires_python~=3.9
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Amazon Bedrock Construct Library

<!--BEGIN STABILITY BANNER-->---


![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)

> The APIs of higher level constructs in this module are experimental and under active development.
> They are subject to non-backward compatible changes or removal in any future version. These are
> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be
> announced in the release notes. This means that while you may use them, you may need to update
> your source code when upgrading to a newer version of this package.

---
<!--END STABILITY BANNER-->

| **Language**                                                                                   | **Package**                             |
| :--------------------------------------------------------------------------------------------- | --------------------------------------- |
| ![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) TypeScript | `@aws-cdk/aws-bedrock-alpha` |

[Amazon Bedrock](https://aws.amazon.com/bedrock/) is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies and Amazon through a single API, along with a broad set of capabilities you need to build generative AI applications with security, privacy, and responsible AI.

This construct library facilitates the deployment of Bedrock Agents, enabling you to create sophisticated AI applications that can interact with your systems and data sources.

## Table of contents

* [Agents](#agents)

  * [Create an Agent](#create-an-agent)
  * [Action groups](#action-groups)
  * [Prepare the Agent](#prepare-the-agent)
  * [Prompt Override Configuration](#prompt-override-configuration)
  * [Memory Configuration](#memory-configuration)
  * [Agent Collaboration](#agent-collaboration)
  * [Custom Orchestration](#custom-orchestration)
  * [Agent Alias](#agent-alias)

## Agents

Amazon Bedrock Agents allow generative AI applications to automate complex, multistep tasks by seamlessly integrating with your company's systems, APIs, and data sources. It uses the reasoning of foundation models (FMs), APIs, and data to break down user requests, gather relevant information, and efficiently complete tasks.

### Create an Agent

Building an agent is straightforward and fast.
The following example creates an Agent with a simple instruction and default prompts:

```python
agent = bedrock.Agent(self, "Agent",
    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,
    instruction="You are a helpful and friendly agent that answers questions about literature."
)
```

### Agent Properties

The Bedrock Agent class supports the following properties.

| Name | Type | Required | Description |
|---|---|---|---|
| name | string | No | The name of the agent. Defaults to a name generated by CDK |
| instruction | string | Yes | The instruction used by the agent that determines how it will perform its task. Must have a minimum of 40 characters |
| foundationModel | IBedrockInvokable | Yes | The foundation model used for orchestration by the agent |
| existingRole | iam.IRole | No | The existing IAM Role for the agent to use. Must have a trust policy allowing Bedrock service to assume the role. Defaults to a new created role |
| shouldPrepareAgent | boolean | No | Specifies whether to automatically update the `DRAFT` version of the agent after making changes. Defaults to false |
| idleSessionTTL | Duration | No | How long sessions should be kept open for the agent. Session expires if no conversation occurs during this time. Defaults to 1 hour |
| kmsKey | kms.IKey | No | The KMS key of the agent if custom encryption is configured. Defaults to AWS managed key |
| description | string | No | A description of the agent. Defaults to no description |
| actionGroups | AgentActionGroup[] | No | The Action Groups associated with the agent |
| promptOverrideConfiguration | PromptOverrideConfiguration | No | Overrides some prompt templates in different parts of an agent sequence configuration |
| userInputEnabled | boolean | No | Select whether the agent can prompt additional information from the user when it lacks enough information. Defaults to false |
| codeInterpreterEnabled | boolean | No | Select whether the agent can generate, run, and troubleshoot code when trying to complete a task. Defaults to false |
| forceDelete | boolean | No | Whether to delete the resource even if it's in use. Defaults to true |
| agentCollaboration | AgentCollaboration | No | Configuration for agent collaboration settings, including type and collaborators. This property allows you to define how the agent collaborates with other agents and what collaborators it can work with. Defaults to no agent collaboration configuration |
| customOrchestrationExecutor | CustomOrchestrationExecutor | No | The Lambda function to use for custom orchestration. If provided, orchestrationType is set to CUSTOM_ORCHESTRATION. If not provided, orchestrationType defaults to DEFAULT. Defaults to default orchestration |

### Action Groups

An action group defines functions your agent can call. The functions are Lambda functions. The action group uses an OpenAPI schema to tell the agent what your functions do and how to call them.

#### Action Group Properties

The AgentActionGroup class supports the following properties.

| Name | Type | Required | Description |
|---|---|---|---|
| name | string | No | The name of the action group. Defaults to a name generated in the format 'action_group_quick_start_UUID' |
| description | string | No | A description of the action group |
| apiSchema | ApiSchema | No | The OpenAPI schema that defines the functions in the action group |
| executor | ActionGroupExecutor | No | The Lambda function that executes the actions in the group |
| enabled | boolean | No | Whether the action group is enabled. Defaults to true |
| forceDelete | boolean | No | Whether to delete the resource even if it's in use. Defaults to false |
| functionSchema | FunctionSchema | No | Defines functions that each define parameters that the agent needs to invoke from the user |
| parentActionGroupSignature | ParentActionGroupSignature | No | The AWS Defined signature for enabling certain capabilities in your agent |

There are three ways to provide an API schema for your action group:

From a local asset file (requires binding to scope):

```python
action_group_function = lambda_.Function(self, "ActionGroupFunction",
    runtime=lambda_.Runtime.PYTHON_3_12,
    handler="index.handler",
    code=lambda_.Code.from_asset(path.join(__dirname, "../lambda/action-group"))
)

# When using ApiSchema.fromLocalAsset, you must bind the schema to a scope
schema = bedrock.ApiSchema.from_local_asset(path.join(__dirname, "action-group.yaml"))
schema.bind(self)

action_group = bedrock.AgentActionGroup(
    name="query-library",
    description="Use these functions to get information about the books in the library.",
    executor=bedrock.ActionGroupExecutor.from_lambda(action_group_function),
    enabled=True,
    api_schema=schema
)

agent = bedrock.Agent(self, "Agent",
    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,
    instruction="You are a helpful and friendly agent that answers questions about literature."
)

agent.add_action_group(action_group)
```

From an inline OpenAPI schema:

```python
inline_schema = bedrock.ApiSchema.from_inline("""
    openapi: 3.0.3
    info:
      title: Library API
      version: 1.0.0
    paths:
      /search:
        get:
          summary: Search for books
          operationId: searchBooks
          parameters:
            - name: query
              in: query
              required: true
              schema:
                type: string
    """)

action_group_function = lambda_.Function(self, "ActionGroupFunction",
    runtime=lambda_.Runtime.PYTHON_3_12,
    handler="index.handler",
    code=lambda_.Code.from_asset(path.join(__dirname, "../lambda/action-group"))
)

action_group = bedrock.AgentActionGroup(
    name="query-library",
    description="Use these functions to get information about the books in the library.",
    executor=bedrock.ActionGroupExecutor.from_lambda(action_group_function),
    enabled=True,
    api_schema=inline_schema
)

agent = bedrock.Agent(self, "Agent",
    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,
    instruction="You are a helpful and friendly agent that answers questions about literature."
)

agent.add_action_group(action_group)
```

From an existing S3 file:

```python
bucket = s3.Bucket.from_bucket_name(self, "ExistingBucket", "my-schema-bucket")
s3_schema = bedrock.ApiSchema.from_s3_file(bucket, "schemas/action-group.yaml")

action_group_function = lambda_.Function(self, "ActionGroupFunction",
    runtime=lambda_.Runtime.PYTHON_3_12,
    handler="index.handler",
    code=lambda_.Code.from_asset(path.join(__dirname, "../lambda/action-group"))
)

action_group = bedrock.AgentActionGroup(
    name="query-library",
    description="Use these functions to get information about the books in the library.",
    executor=bedrock.ActionGroupExecutor.from_lambda(action_group_function),
    enabled=True,
    api_schema=s3_schema
)

agent = bedrock.Agent(self, "Agent",
    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,
    instruction="You are a helpful and friendly agent that answers questions about literature."
)

agent.add_action_group(action_group)
```

### Using FunctionSchema with Action Groups

As an alternative to using OpenAPI schemas, you can define functions directly using the `FunctionSchema` class. This approach provides a more structured way to define the functions that your agent can call.

```python
action_group_function = lambda_.Function(self, "ActionGroupFunction",
    runtime=lambda_.Runtime.PYTHON_3_12,
    handler="index.handler",
    code=lambda_.Code.from_asset(path.join(__dirname, "../lambda/action-group"))
)

# Define a function schema with parameters
function_schema = bedrock.FunctionSchema(
    functions=[bedrock.FunctionProps(
        name="searchBooks",
        description="Search for books in the library catalog",
        parameters={
            "query": bedrock.FunctionParameterProps(
                type=bedrock.ParameterType.STRING,
                required=True,
                description="The search query string"
            ),
            "maxResults": bedrock.FunctionParameterProps(
                type=bedrock.ParameterType.INTEGER,
                required=False,
                description="Maximum number of results to return"
            ),
            "includeOutOfPrint": bedrock.FunctionParameterProps(
                type=bedrock.ParameterType.BOOLEAN,
                required=False,
                description="Whether to include out-of-print books"
            )
        },
        require_confirmation=bedrock.RequireConfirmation.DISABLED
    ), bedrock.FunctionProps(
        name="getBookDetails",
        description="Get detailed information about a specific book",
        parameters={
            "bookId": bedrock.FunctionParameterProps(
                type=bedrock.ParameterType.STRING,
                required=True,
                description="The unique identifier of the book"
            )
        },
        require_confirmation=bedrock.RequireConfirmation.ENABLED
    )
    ]
)

# Create an action group using the function schema
action_group = bedrock.AgentActionGroup(
    name="library-functions",
    description="Functions for interacting with the library catalog",
    executor=bedrock.ActionGroupExecutor.from_lambda(action_group_function),
    function_schema=function_schema,
    enabled=True
)

agent = bedrock.Agent(self, "Agent",
    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,
    instruction="You are a helpful and friendly agent that answers questions about literature.",
    action_groups=[action_group]
)
```

The `FunctionSchema` approach offers several advantages:

* Type-safe definition of functions and parameters
* Built-in validation of parameter names, descriptions, and other properties
* Clear structure that maps directly to the AWS Bedrock API
* Support for parameter types including string, number, integer, boolean, array, and object
* Option to require user confirmation before executing specific functions

If you chose to load your schema file from S3, the construct will provide the necessary permissions to your agent's execution role to access the schema file from the specific bucket. Similar to performing the operation through the console, the agent execution role will get a permission like:

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AmazonBedrockAgentS3PolicyProd",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::<BUCKET_NAME>/<OBJECT_KEY>"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:ResourceAccount": "ACCOUNT_NUMBER"
                }
            }
        }
    ]
}
```

```python
# create a bucket containing the input schema
schema_bucket = s3.Bucket(self, "SchemaBucket",
    enforce_sSL=True,
    versioned=True,
    public_read_access=False,
    block_public_access=s3.BlockPublicAccess.BLOCK_ALL,
    encryption=s3.BucketEncryption.S3_MANAGED,
    removal_policy=RemovalPolicy.DESTROY,
    auto_delete_objects=True
)

# deploy the local schema file to S3
deployement = aws_s3_deployment.BucketDeployment(self, "DeployWebsite",
    sources=[aws_s3_deployment.Source.asset(path.join(__dirname, "../inputschema"))],
    destination_bucket=schema_bucket,
    destination_key_prefix="inputschema"
)

# create the agent
agent = bedrock.Agent(self, "Agent",
    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0,
    instruction="You are a helpful and friendly agent that answers questions about literature.",
    user_input_enabled=True,
    should_prepare_agent=True
)

# create a lambda function
action_group_function = lambda_.Function(self, "ActionGroupFunction",
    runtime=lambda_.Runtime.PYTHON_3_12,
    handler="index.handler",
    code=lambda_.Code.from_asset(path.join(__dirname, "../lambda/action-group"))
)

# create an action group and read the schema file from S3
action_group = bedrock.AgentActionGroup(
    name="query-library",
    description="Use these functions to get information about the books in the library.",
    executor=bedrock.ActionGroupExecutor.from_lambda(action_group_function),
    enabled=True,
    api_schema=bedrock.ApiSchema.from_s3_file(schema_bucket, "inputschema/action-group.yaml")
)

# add the action group to the agent
agent.add_action_group(action_group)

# add dependency for the agent on the s3 deployment
agent.node.add_dependency(deployement)
```

### Prepare the Agent

The `Agent` constructs take an optional parameter `shouldPrepareAgent` to indicate that the Agent should be prepared after any updates to an agent or action group. This may increase the time to create and update those resources. By default, this value is false.

#### Prepare Agent Properties

| Name | Type | Required | Description |
|---|---|---|---|
| shouldPrepareAgent | boolean | No | Whether to automatically update the DRAFT version of the agent after making changes. Defaults to false |

Creating an agent alias will not prepare the agent, so if you create an alias using the `AgentAlias` resource then you should set `shouldPrepareAgent` to ***true***.

### Prompt Override Configuration

Bedrock Agents allows you to customize the prompts and LLM configuration for different steps in the agent sequence. The implementation provides type-safe configurations for each step type, ensuring correct usage at compile time.

#### Prompt Override Configuration Properties

| Name | Type | Required | Description |
|---|---|---|---|
| steps | PromptStepConfiguration[] | Yes | Array of step configurations for different parts of the agent sequence |
| parser | lambda.IFunction | No | Lambda function for custom parsing of agent responses |

#### Prompt Step Configuration Properties

Each step in the `steps` array supports the following properties:

| Name | Type | Required | Description |
|---|---|---|---|
| stepType | AgentStepType | Yes | The type of step being configured (PRE_PROCESSING, ORCHESTRATION, POST_PROCESSING, ROUTING_CLASSIFIER, MEMORY_SUMMARIZATION, KNOWLEDGE_BASE_RESPONSE_GENERATION) |
| stepEnabled | boolean | No | Whether this step is enabled. Defaults to true |
| customPromptTemplate | string | No | Custom prompt template to use for this step |
| inferenceConfig | InferenceConfiguration | No | Configuration for model inference parameters |
| foundationModel | BedrockFoundationModel | No | Alternative foundation model to use for this step (only valid for ROUTING_CLASSIFIER step) |
| useCustomParser | boolean | No | Whether to use a custom parser for this step. Requires parser to be provided in PromptOverrideConfiguration |

#### Inference Configuration Properties

When providing `inferenceConfig`, the following properties are supported:

| Name | Type | Required | Description |
|---|---|---|---|
| temperature | number | No | Controls randomness in the model's output (0.0-1.0) |
| topP | number | No | Controls diversity via nucleus sampling (0.0-1.0) |
| topK | number | No | Controls diversity by limiting the cumulative probability |
| maximumLength | number | No | Maximum length of generated text |
| stopSequences | string[] | No | Sequences where the model should stop generating |

The following steps can be configured:

* PRE_PROCESSING: Prepares the user input for orchestration
* ORCHESTRATION: Main step that determines the agent's actions
* POST_PROCESSING: Refines the agent's response
* ROUTING_CLASSIFIER: Classifies and routes requests to appropriate collaborators
* MEMORY_SUMMARIZATION: Summarizes conversation history for memory retention
* KNOWLEDGE_BASE_RESPONSE_GENERATION: Generates responses using knowledge base content

Example with pre-processing configuration:

```python
agent = bedrock.Agent(self, "Agent",
    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
    instruction="You are a helpful assistant.",
    prompt_override_configuration=bedrock.PromptOverrideConfiguration.from_steps([
        step_type=bedrock.AgentStepType.PRE_PROCESSING,
        step_enabled=True,
        custom_prompt_template="Your custom prompt template here",
        inference_config=bedrock.InferenceConfiguration(
            temperature=0,
            top_p=1,
            top_k=250,
            maximum_length=1,
            stop_sequences=["\n\nHuman:"]
        )

    ])
)
```

Example with routing classifier and foundation model:

```python
agent = bedrock.Agent(self, "Agent",
    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
    instruction="You are a helpful assistant.",
    prompt_override_configuration=bedrock.PromptOverrideConfiguration.from_steps([
        step_type=bedrock.AgentStepType.ROUTING_CLASSIFIER,
        step_enabled=True,
        custom_prompt_template="Your routing template here",
        foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2

    ])
)
```

Using a custom Lambda parser:

```python
parser_function = lambda_.Function(self, "ParserFunction",
    runtime=lambda_.Runtime.PYTHON_3_10,
    handler="index.handler",
    code=lambda_.Code.from_asset("lambda")
)

agent = bedrock.Agent(self, "Agent",
    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
    instruction="You are a helpful assistant.",
    prompt_override_configuration=bedrock.PromptOverrideConfiguration.with_custom_parser(
        parser=parser_function,
        pre_processing_step=bedrock.PromptPreProcessingConfigCustomParser(
            step_type=bedrock.AgentStepType.PRE_PROCESSING,
            use_custom_parser=True
        )
    )
)
```

Foundation models can only be specified for the ROUTING_CLASSIFIER step.

### Memory Configuration

Agents can maintain context across multiple sessions and recall past interactions using memory. This feature is useful for creating a more coherent conversational experience.

#### Memory Configuration Properties

| Name | Type | Required | Description |
|---|---|---|---|
| maxRecentSessions | number | No | Maximum number of recent session summaries to retain |
| memoryDuration | Duration | No | How long to retain session summaries |

Example:

```python
agent = bedrock.Agent(self, "MyAgent",
    agent_name="MyAgent",
    instruction="Your instruction here",
    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
    memory=Memory.session_summary(
        max_recent_sessions=10,  # Keep the last 10 session summaries
        memory_duration=Duration.days(20)
    )
)
```

### Agent Collaboration

Agent Collaboration enables multiple Bedrock Agents to work together on complex tasks. This feature allows agents to specialize in different areas and collaborate to provide more comprehensive responses to user queries.

#### Agent Collaboration Properties

| Name | Type | Required | Description |
|---|---|---|---|
| type | AgentCollaboratorType | Yes | Type of collaboration (SUPERVISOR or PEER) |
| collaborators | AgentCollaborator[] | Yes | List of agent collaborators |

#### Agent Collaborator Properties

| Name | Type | Required | Description |
|---|---|---|---|
| agentAlias | AgentAlias | Yes | The agent alias to collaborate with |
| collaborationInstruction | string | Yes | Instructions for how to collaborate with this agent |
| collaboratorName | string | Yes | Name of the collaborator |
| relayConversationHistory | boolean | No | Whether to relay conversation history to the collaborator. Defaults to false |

Example:

```python
# Create a specialized agent
customer_support_agent = bedrock.Agent(self, "CustomerSupportAgent",
    instruction="You specialize in answering customer support questions.",
    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1
)

# Create an agent alias
customer_support_alias = bedrock.AgentAlias(self, "CustomerSupportAlias",
    agent=customer_support_agent,
    agent_alias_name="production"
)

# Create a main agent that collaborates with the specialized agent
main_agent = bedrock.Agent(self, "MainAgent",
    instruction="You route specialized questions to other agents.",
    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
    agent_collaboration={
        "type": bedrock.AgentCollaboratorType.SUPERVISOR,
        "collaborators": [
            bedrock.AgentCollaborator(
                agent_alias=customer_support_alias,
                collaboration_instruction="Route customer support questions to this agent.",
                collaborator_name="CustomerSupport",
                relay_conversation_history=True
            )
        ]
    }
)
```

### Custom Orchestration

Custom Orchestration allows you to override the default agent orchestration flow with your own Lambda function. This enables more control over how the agent processes user inputs and invokes action groups.

When you provide a customOrchestrationExecutor, the agent's orchestrationType is automatically set to CUSTOM_ORCHESTRATION. If no customOrchestrationExecutor is provided, the orchestrationType defaults to DEFAULT, using Amazon Bedrock's built-in orchestration.

#### Custom Orchestration Properties

| Name | Type | Required | Description |
|---|---|---|---|
| function | lambda.IFunction | Yes | The Lambda function that implements the custom orchestration logic |

Example:

```python
orchestration_function = lambda_.Function(self, "OrchestrationFunction",
    runtime=lambda_.Runtime.PYTHON_3_10,
    handler="index.handler",
    code=lambda_.Code.from_asset("lambda/orchestration")
)

agent = bedrock.Agent(self, "CustomOrchestrationAgent",
    instruction="You are a helpful assistant with custom orchestration logic.",
    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
    custom_orchestration_executor=bedrock.CustomOrchestrationExecutor.from_lambda(orchestration_function)
)
```

### Agent Alias

After you have sufficiently iterated on your working draft and are satisfied with the behavior of your agent, you can set it up for deployment and integration into your application by creating aliases.

To deploy your agent, you need to create an alias. During alias creation, Amazon Bedrock automatically creates a version of your agent. The alias points to this newly created version. You can point the alias to a previously created version if necessary. You then configure your application to make API calls to that alias.

By default, the Agent resource creates a test alias named 'AgentTestAlias' that points to the 'DRAFT' version. This test alias is accessible via the `testAlias` property of the agent. You can also create additional aliases for different environments using the AgentAlias construct.

#### Agent Alias Properties

| Name | Type | Required | Description |
|---|---|---|---|
| agent | Agent | Yes | The agent to create an alias for |
| agentAliasName | string | No | The name of the agent alias. Defaults to a name generated by CDK |
| description | string | No | A description of the agent alias. Defaults to no description |
| routingConfiguration | AgentAliasRoutingConfiguration | No | Configuration for routing traffic between agent versions |
| agentVersion | string | No | The version of the agent to use. If not specified, a new version is created |

When redeploying an agent with changes, you must ensure the agent version is updated to avoid deployment failures with "agent already exists" errors. The recommended way to handle this is to include the `lastUpdated` property in the agent's description, which automatically updates whenever the agent is modified. This ensures a new version is created on each deployment.

Example:

```python
agent = bedrock.Agent(self, "Agent",
    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,
    instruction="You are a helpful and friendly agent that answers questions about literature."
)

agent_alias = bedrock.AgentAlias(self, "myAlias",
    agent_alias_name="production",
    agent=agent,
    description=f"Production version of my agent. Created at {agent.lastUpdated}"
)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aws/aws-cdk",
    "name": "aws-cdk.aws-bedrock-alpha",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Amazon Web Services",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/49/29/808efa179117588ea8821582ec5cf9631b612580f1ae2f674db9b827fcc1/aws_cdk_aws_bedrock_alpha-2.206.0a0.tar.gz",
    "platform": null,
    "description": "# Amazon Bedrock Construct Library\n\n<!--BEGIN STABILITY BANNER-->---\n\n\n![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)\n\n> The APIs of higher level constructs in this module are experimental and under active development.\n> They are subject to non-backward compatible changes or removal in any future version. These are\n> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be\n> announced in the release notes. This means that while you may use them, you may need to update\n> your source code when upgrading to a newer version of this package.\n\n---\n<!--END STABILITY BANNER-->\n\n| **Language**                                                                                   | **Package**                             |\n| :--------------------------------------------------------------------------------------------- | --------------------------------------- |\n| ![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) TypeScript | `@aws-cdk/aws-bedrock-alpha` |\n\n[Amazon Bedrock](https://aws.amazon.com/bedrock/) is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies and Amazon through a single API, along with a broad set of capabilities you need to build generative AI applications with security, privacy, and responsible AI.\n\nThis construct library facilitates the deployment of Bedrock Agents, enabling you to create sophisticated AI applications that can interact with your systems and data sources.\n\n## Table of contents\n\n* [Agents](#agents)\n\n  * [Create an Agent](#create-an-agent)\n  * [Action groups](#action-groups)\n  * [Prepare the Agent](#prepare-the-agent)\n  * [Prompt Override Configuration](#prompt-override-configuration)\n  * [Memory Configuration](#memory-configuration)\n  * [Agent Collaboration](#agent-collaboration)\n  * [Custom Orchestration](#custom-orchestration)\n  * [Agent Alias](#agent-alias)\n\n## Agents\n\nAmazon Bedrock Agents allow generative AI applications to automate complex, multistep tasks by seamlessly integrating with your company's systems, APIs, and data sources. It uses the reasoning of foundation models (FMs), APIs, and data to break down user requests, gather relevant information, and efficiently complete tasks.\n\n### Create an Agent\n\nBuilding an agent is straightforward and fast.\nThe following example creates an Agent with a simple instruction and default prompts:\n\n```python\nagent = bedrock.Agent(self, \"Agent\",\n    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,\n    instruction=\"You are a helpful and friendly agent that answers questions about literature.\"\n)\n```\n\n### Agent Properties\n\nThe Bedrock Agent class supports the following properties.\n\n| Name | Type | Required | Description |\n|---|---|---|---|\n| name | string | No | The name of the agent. Defaults to a name generated by CDK |\n| instruction | string | Yes | The instruction used by the agent that determines how it will perform its task. Must have a minimum of 40 characters |\n| foundationModel | IBedrockInvokable | Yes | The foundation model used for orchestration by the agent |\n| existingRole | iam.IRole | No | The existing IAM Role for the agent to use. Must have a trust policy allowing Bedrock service to assume the role. Defaults to a new created role |\n| shouldPrepareAgent | boolean | No | Specifies whether to automatically update the `DRAFT` version of the agent after making changes. Defaults to false |\n| idleSessionTTL | Duration | No | How long sessions should be kept open for the agent. Session expires if no conversation occurs during this time. Defaults to 1 hour |\n| kmsKey | kms.IKey | No | The KMS key of the agent if custom encryption is configured. Defaults to AWS managed key |\n| description | string | No | A description of the agent. Defaults to no description |\n| actionGroups | AgentActionGroup[] | No | The Action Groups associated with the agent |\n| promptOverrideConfiguration | PromptOverrideConfiguration | No | Overrides some prompt templates in different parts of an agent sequence configuration |\n| userInputEnabled | boolean | No | Select whether the agent can prompt additional information from the user when it lacks enough information. Defaults to false |\n| codeInterpreterEnabled | boolean | No | Select whether the agent can generate, run, and troubleshoot code when trying to complete a task. Defaults to false |\n| forceDelete | boolean | No | Whether to delete the resource even if it's in use. Defaults to true |\n| agentCollaboration | AgentCollaboration | No | Configuration for agent collaboration settings, including type and collaborators. This property allows you to define how the agent collaborates with other agents and what collaborators it can work with. Defaults to no agent collaboration configuration |\n| customOrchestrationExecutor | CustomOrchestrationExecutor | No | The Lambda function to use for custom orchestration. If provided, orchestrationType is set to CUSTOM_ORCHESTRATION. If not provided, orchestrationType defaults to DEFAULT. Defaults to default orchestration |\n\n### Action Groups\n\nAn action group defines functions your agent can call. The functions are Lambda functions. The action group uses an OpenAPI schema to tell the agent what your functions do and how to call them.\n\n#### Action Group Properties\n\nThe AgentActionGroup class supports the following properties.\n\n| Name | Type | Required | Description |\n|---|---|---|---|\n| name | string | No | The name of the action group. Defaults to a name generated in the format 'action_group_quick_start_UUID' |\n| description | string | No | A description of the action group |\n| apiSchema | ApiSchema | No | The OpenAPI schema that defines the functions in the action group |\n| executor | ActionGroupExecutor | No | The Lambda function that executes the actions in the group |\n| enabled | boolean | No | Whether the action group is enabled. Defaults to true |\n| forceDelete | boolean | No | Whether to delete the resource even if it's in use. Defaults to false |\n| functionSchema | FunctionSchema | No | Defines functions that each define parameters that the agent needs to invoke from the user |\n| parentActionGroupSignature | ParentActionGroupSignature | No | The AWS Defined signature for enabling certain capabilities in your agent |\n\nThere are three ways to provide an API schema for your action group:\n\nFrom a local asset file (requires binding to scope):\n\n```python\naction_group_function = lambda_.Function(self, \"ActionGroupFunction\",\n    runtime=lambda_.Runtime.PYTHON_3_12,\n    handler=\"index.handler\",\n    code=lambda_.Code.from_asset(path.join(__dirname, \"../lambda/action-group\"))\n)\n\n# When using ApiSchema.fromLocalAsset, you must bind the schema to a scope\nschema = bedrock.ApiSchema.from_local_asset(path.join(__dirname, \"action-group.yaml\"))\nschema.bind(self)\n\naction_group = bedrock.AgentActionGroup(\n    name=\"query-library\",\n    description=\"Use these functions to get information about the books in the library.\",\n    executor=bedrock.ActionGroupExecutor.from_lambda(action_group_function),\n    enabled=True,\n    api_schema=schema\n)\n\nagent = bedrock.Agent(self, \"Agent\",\n    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,\n    instruction=\"You are a helpful and friendly agent that answers questions about literature.\"\n)\n\nagent.add_action_group(action_group)\n```\n\nFrom an inline OpenAPI schema:\n\n```python\ninline_schema = bedrock.ApiSchema.from_inline(\"\"\"\n    openapi: 3.0.3\n    info:\n      title: Library API\n      version: 1.0.0\n    paths:\n      /search:\n        get:\n          summary: Search for books\n          operationId: searchBooks\n          parameters:\n            - name: query\n              in: query\n              required: true\n              schema:\n                type: string\n    \"\"\")\n\naction_group_function = lambda_.Function(self, \"ActionGroupFunction\",\n    runtime=lambda_.Runtime.PYTHON_3_12,\n    handler=\"index.handler\",\n    code=lambda_.Code.from_asset(path.join(__dirname, \"../lambda/action-group\"))\n)\n\naction_group = bedrock.AgentActionGroup(\n    name=\"query-library\",\n    description=\"Use these functions to get information about the books in the library.\",\n    executor=bedrock.ActionGroupExecutor.from_lambda(action_group_function),\n    enabled=True,\n    api_schema=inline_schema\n)\n\nagent = bedrock.Agent(self, \"Agent\",\n    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,\n    instruction=\"You are a helpful and friendly agent that answers questions about literature.\"\n)\n\nagent.add_action_group(action_group)\n```\n\nFrom an existing S3 file:\n\n```python\nbucket = s3.Bucket.from_bucket_name(self, \"ExistingBucket\", \"my-schema-bucket\")\ns3_schema = bedrock.ApiSchema.from_s3_file(bucket, \"schemas/action-group.yaml\")\n\naction_group_function = lambda_.Function(self, \"ActionGroupFunction\",\n    runtime=lambda_.Runtime.PYTHON_3_12,\n    handler=\"index.handler\",\n    code=lambda_.Code.from_asset(path.join(__dirname, \"../lambda/action-group\"))\n)\n\naction_group = bedrock.AgentActionGroup(\n    name=\"query-library\",\n    description=\"Use these functions to get information about the books in the library.\",\n    executor=bedrock.ActionGroupExecutor.from_lambda(action_group_function),\n    enabled=True,\n    api_schema=s3_schema\n)\n\nagent = bedrock.Agent(self, \"Agent\",\n    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,\n    instruction=\"You are a helpful and friendly agent that answers questions about literature.\"\n)\n\nagent.add_action_group(action_group)\n```\n\n### Using FunctionSchema with Action Groups\n\nAs an alternative to using OpenAPI schemas, you can define functions directly using the `FunctionSchema` class. This approach provides a more structured way to define the functions that your agent can call.\n\n```python\naction_group_function = lambda_.Function(self, \"ActionGroupFunction\",\n    runtime=lambda_.Runtime.PYTHON_3_12,\n    handler=\"index.handler\",\n    code=lambda_.Code.from_asset(path.join(__dirname, \"../lambda/action-group\"))\n)\n\n# Define a function schema with parameters\nfunction_schema = bedrock.FunctionSchema(\n    functions=[bedrock.FunctionProps(\n        name=\"searchBooks\",\n        description=\"Search for books in the library catalog\",\n        parameters={\n            \"query\": bedrock.FunctionParameterProps(\n                type=bedrock.ParameterType.STRING,\n                required=True,\n                description=\"The search query string\"\n            ),\n            \"maxResults\": bedrock.FunctionParameterProps(\n                type=bedrock.ParameterType.INTEGER,\n                required=False,\n                description=\"Maximum number of results to return\"\n            ),\n            \"includeOutOfPrint\": bedrock.FunctionParameterProps(\n                type=bedrock.ParameterType.BOOLEAN,\n                required=False,\n                description=\"Whether to include out-of-print books\"\n            )\n        },\n        require_confirmation=bedrock.RequireConfirmation.DISABLED\n    ), bedrock.FunctionProps(\n        name=\"getBookDetails\",\n        description=\"Get detailed information about a specific book\",\n        parameters={\n            \"bookId\": bedrock.FunctionParameterProps(\n                type=bedrock.ParameterType.STRING,\n                required=True,\n                description=\"The unique identifier of the book\"\n            )\n        },\n        require_confirmation=bedrock.RequireConfirmation.ENABLED\n    )\n    ]\n)\n\n# Create an action group using the function schema\naction_group = bedrock.AgentActionGroup(\n    name=\"library-functions\",\n    description=\"Functions for interacting with the library catalog\",\n    executor=bedrock.ActionGroupExecutor.from_lambda(action_group_function),\n    function_schema=function_schema,\n    enabled=True\n)\n\nagent = bedrock.Agent(self, \"Agent\",\n    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,\n    instruction=\"You are a helpful and friendly agent that answers questions about literature.\",\n    action_groups=[action_group]\n)\n```\n\nThe `FunctionSchema` approach offers several advantages:\n\n* Type-safe definition of functions and parameters\n* Built-in validation of parameter names, descriptions, and other properties\n* Clear structure that maps directly to the AWS Bedrock API\n* Support for parameter types including string, number, integer, boolean, array, and object\n* Option to require user confirmation before executing specific functions\n\nIf you chose to load your schema file from S3, the construct will provide the necessary permissions to your agent's execution role to access the schema file from the specific bucket. Similar to performing the operation through the console, the agent execution role will get a permission like:\n\n```json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Sid\": \"AmazonBedrockAgentS3PolicyProd\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"s3:GetObject\"\n            ],\n            \"Resource\": [\n                \"arn:aws:s3:::<BUCKET_NAME>/<OBJECT_KEY>\"\n            ],\n            \"Condition\": {\n                \"StringEquals\": {\n                    \"aws:ResourceAccount\": \"ACCOUNT_NUMBER\"\n                }\n            }\n        }\n    ]\n}\n```\n\n```python\n# create a bucket containing the input schema\nschema_bucket = s3.Bucket(self, \"SchemaBucket\",\n    enforce_sSL=True,\n    versioned=True,\n    public_read_access=False,\n    block_public_access=s3.BlockPublicAccess.BLOCK_ALL,\n    encryption=s3.BucketEncryption.S3_MANAGED,\n    removal_policy=RemovalPolicy.DESTROY,\n    auto_delete_objects=True\n)\n\n# deploy the local schema file to S3\ndeployement = aws_s3_deployment.BucketDeployment(self, \"DeployWebsite\",\n    sources=[aws_s3_deployment.Source.asset(path.join(__dirname, \"../inputschema\"))],\n    destination_bucket=schema_bucket,\n    destination_key_prefix=\"inputschema\"\n)\n\n# create the agent\nagent = bedrock.Agent(self, \"Agent\",\n    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0,\n    instruction=\"You are a helpful and friendly agent that answers questions about literature.\",\n    user_input_enabled=True,\n    should_prepare_agent=True\n)\n\n# create a lambda function\naction_group_function = lambda_.Function(self, \"ActionGroupFunction\",\n    runtime=lambda_.Runtime.PYTHON_3_12,\n    handler=\"index.handler\",\n    code=lambda_.Code.from_asset(path.join(__dirname, \"../lambda/action-group\"))\n)\n\n# create an action group and read the schema file from S3\naction_group = bedrock.AgentActionGroup(\n    name=\"query-library\",\n    description=\"Use these functions to get information about the books in the library.\",\n    executor=bedrock.ActionGroupExecutor.from_lambda(action_group_function),\n    enabled=True,\n    api_schema=bedrock.ApiSchema.from_s3_file(schema_bucket, \"inputschema/action-group.yaml\")\n)\n\n# add the action group to the agent\nagent.add_action_group(action_group)\n\n# add dependency for the agent on the s3 deployment\nagent.node.add_dependency(deployement)\n```\n\n### Prepare the Agent\n\nThe `Agent` constructs take an optional parameter `shouldPrepareAgent` to indicate that the Agent should be prepared after any updates to an agent or action group. This may increase the time to create and update those resources. By default, this value is false.\n\n#### Prepare Agent Properties\n\n| Name | Type | Required | Description |\n|---|---|---|---|\n| shouldPrepareAgent | boolean | No | Whether to automatically update the DRAFT version of the agent after making changes. Defaults to false |\n\nCreating an agent alias will not prepare the agent, so if you create an alias using the `AgentAlias` resource then you should set `shouldPrepareAgent` to ***true***.\n\n### Prompt Override Configuration\n\nBedrock Agents allows you to customize the prompts and LLM configuration for different steps in the agent sequence. The implementation provides type-safe configurations for each step type, ensuring correct usage at compile time.\n\n#### Prompt Override Configuration Properties\n\n| Name | Type | Required | Description |\n|---|---|---|---|\n| steps | PromptStepConfiguration[] | Yes | Array of step configurations for different parts of the agent sequence |\n| parser | lambda.IFunction | No | Lambda function for custom parsing of agent responses |\n\n#### Prompt Step Configuration Properties\n\nEach step in the `steps` array supports the following properties:\n\n| Name | Type | Required | Description |\n|---|---|---|---|\n| stepType | AgentStepType | Yes | The type of step being configured (PRE_PROCESSING, ORCHESTRATION, POST_PROCESSING, ROUTING_CLASSIFIER, MEMORY_SUMMARIZATION, KNOWLEDGE_BASE_RESPONSE_GENERATION) |\n| stepEnabled | boolean | No | Whether this step is enabled. Defaults to true |\n| customPromptTemplate | string | No | Custom prompt template to use for this step |\n| inferenceConfig | InferenceConfiguration | No | Configuration for model inference parameters |\n| foundationModel | BedrockFoundationModel | No | Alternative foundation model to use for this step (only valid for ROUTING_CLASSIFIER step) |\n| useCustomParser | boolean | No | Whether to use a custom parser for this step. Requires parser to be provided in PromptOverrideConfiguration |\n\n#### Inference Configuration Properties\n\nWhen providing `inferenceConfig`, the following properties are supported:\n\n| Name | Type | Required | Description |\n|---|---|---|---|\n| temperature | number | No | Controls randomness in the model's output (0.0-1.0) |\n| topP | number | No | Controls diversity via nucleus sampling (0.0-1.0) |\n| topK | number | No | Controls diversity by limiting the cumulative probability |\n| maximumLength | number | No | Maximum length of generated text |\n| stopSequences | string[] | No | Sequences where the model should stop generating |\n\nThe following steps can be configured:\n\n* PRE_PROCESSING: Prepares the user input for orchestration\n* ORCHESTRATION: Main step that determines the agent's actions\n* POST_PROCESSING: Refines the agent's response\n* ROUTING_CLASSIFIER: Classifies and routes requests to appropriate collaborators\n* MEMORY_SUMMARIZATION: Summarizes conversation history for memory retention\n* KNOWLEDGE_BASE_RESPONSE_GENERATION: Generates responses using knowledge base content\n\nExample with pre-processing configuration:\n\n```python\nagent = bedrock.Agent(self, \"Agent\",\n    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,\n    instruction=\"You are a helpful assistant.\",\n    prompt_override_configuration=bedrock.PromptOverrideConfiguration.from_steps([\n        step_type=bedrock.AgentStepType.PRE_PROCESSING,\n        step_enabled=True,\n        custom_prompt_template=\"Your custom prompt template here\",\n        inference_config=bedrock.InferenceConfiguration(\n            temperature=0,\n            top_p=1,\n            top_k=250,\n            maximum_length=1,\n            stop_sequences=[\"\\n\\nHuman:\"]\n        )\n\n    ])\n)\n```\n\nExample with routing classifier and foundation model:\n\n```python\nagent = bedrock.Agent(self, \"Agent\",\n    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,\n    instruction=\"You are a helpful assistant.\",\n    prompt_override_configuration=bedrock.PromptOverrideConfiguration.from_steps([\n        step_type=bedrock.AgentStepType.ROUTING_CLASSIFIER,\n        step_enabled=True,\n        custom_prompt_template=\"Your routing template here\",\n        foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2\n\n    ])\n)\n```\n\nUsing a custom Lambda parser:\n\n```python\nparser_function = lambda_.Function(self, \"ParserFunction\",\n    runtime=lambda_.Runtime.PYTHON_3_10,\n    handler=\"index.handler\",\n    code=lambda_.Code.from_asset(\"lambda\")\n)\n\nagent = bedrock.Agent(self, \"Agent\",\n    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,\n    instruction=\"You are a helpful assistant.\",\n    prompt_override_configuration=bedrock.PromptOverrideConfiguration.with_custom_parser(\n        parser=parser_function,\n        pre_processing_step=bedrock.PromptPreProcessingConfigCustomParser(\n            step_type=bedrock.AgentStepType.PRE_PROCESSING,\n            use_custom_parser=True\n        )\n    )\n)\n```\n\nFoundation models can only be specified for the ROUTING_CLASSIFIER step.\n\n### Memory Configuration\n\nAgents can maintain context across multiple sessions and recall past interactions using memory. This feature is useful for creating a more coherent conversational experience.\n\n#### Memory Configuration Properties\n\n| Name | Type | Required | Description |\n|---|---|---|---|\n| maxRecentSessions | number | No | Maximum number of recent session summaries to retain |\n| memoryDuration | Duration | No | How long to retain session summaries |\n\nExample:\n\n```python\nagent = bedrock.Agent(self, \"MyAgent\",\n    agent_name=\"MyAgent\",\n    instruction=\"Your instruction here\",\n    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,\n    memory=Memory.session_summary(\n        max_recent_sessions=10,  # Keep the last 10 session summaries\n        memory_duration=Duration.days(20)\n    )\n)\n```\n\n### Agent Collaboration\n\nAgent Collaboration enables multiple Bedrock Agents to work together on complex tasks. This feature allows agents to specialize in different areas and collaborate to provide more comprehensive responses to user queries.\n\n#### Agent Collaboration Properties\n\n| Name | Type | Required | Description |\n|---|---|---|---|\n| type | AgentCollaboratorType | Yes | Type of collaboration (SUPERVISOR or PEER) |\n| collaborators | AgentCollaborator[] | Yes | List of agent collaborators |\n\n#### Agent Collaborator Properties\n\n| Name | Type | Required | Description |\n|---|---|---|---|\n| agentAlias | AgentAlias | Yes | The agent alias to collaborate with |\n| collaborationInstruction | string | Yes | Instructions for how to collaborate with this agent |\n| collaboratorName | string | Yes | Name of the collaborator |\n| relayConversationHistory | boolean | No | Whether to relay conversation history to the collaborator. Defaults to false |\n\nExample:\n\n```python\n# Create a specialized agent\ncustomer_support_agent = bedrock.Agent(self, \"CustomerSupportAgent\",\n    instruction=\"You specialize in answering customer support questions.\",\n    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1\n)\n\n# Create an agent alias\ncustomer_support_alias = bedrock.AgentAlias(self, \"CustomerSupportAlias\",\n    agent=customer_support_agent,\n    agent_alias_name=\"production\"\n)\n\n# Create a main agent that collaborates with the specialized agent\nmain_agent = bedrock.Agent(self, \"MainAgent\",\n    instruction=\"You route specialized questions to other agents.\",\n    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,\n    agent_collaboration={\n        \"type\": bedrock.AgentCollaboratorType.SUPERVISOR,\n        \"collaborators\": [\n            bedrock.AgentCollaborator(\n                agent_alias=customer_support_alias,\n                collaboration_instruction=\"Route customer support questions to this agent.\",\n                collaborator_name=\"CustomerSupport\",\n                relay_conversation_history=True\n            )\n        ]\n    }\n)\n```\n\n### Custom Orchestration\n\nCustom Orchestration allows you to override the default agent orchestration flow with your own Lambda function. This enables more control over how the agent processes user inputs and invokes action groups.\n\nWhen you provide a customOrchestrationExecutor, the agent's orchestrationType is automatically set to CUSTOM_ORCHESTRATION. If no customOrchestrationExecutor is provided, the orchestrationType defaults to DEFAULT, using Amazon Bedrock's built-in orchestration.\n\n#### Custom Orchestration Properties\n\n| Name | Type | Required | Description |\n|---|---|---|---|\n| function | lambda.IFunction | Yes | The Lambda function that implements the custom orchestration logic |\n\nExample:\n\n```python\norchestration_function = lambda_.Function(self, \"OrchestrationFunction\",\n    runtime=lambda_.Runtime.PYTHON_3_10,\n    handler=\"index.handler\",\n    code=lambda_.Code.from_asset(\"lambda/orchestration\")\n)\n\nagent = bedrock.Agent(self, \"CustomOrchestrationAgent\",\n    instruction=\"You are a helpful assistant with custom orchestration logic.\",\n    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,\n    custom_orchestration_executor=bedrock.CustomOrchestrationExecutor.from_lambda(orchestration_function)\n)\n```\n\n### Agent Alias\n\nAfter you have sufficiently iterated on your working draft and are satisfied with the behavior of your agent, you can set it up for deployment and integration into your application by creating aliases.\n\nTo deploy your agent, you need to create an alias. During alias creation, Amazon Bedrock automatically creates a version of your agent. The alias points to this newly created version. You can point the alias to a previously created version if necessary. You then configure your application to make API calls to that alias.\n\nBy default, the Agent resource creates a test alias named 'AgentTestAlias' that points to the 'DRAFT' version. This test alias is accessible via the `testAlias` property of the agent. You can also create additional aliases for different environments using the AgentAlias construct.\n\n#### Agent Alias Properties\n\n| Name | Type | Required | Description |\n|---|---|---|---|\n| agent | Agent | Yes | The agent to create an alias for |\n| agentAliasName | string | No | The name of the agent alias. Defaults to a name generated by CDK |\n| description | string | No | A description of the agent alias. Defaults to no description |\n| routingConfiguration | AgentAliasRoutingConfiguration | No | Configuration for routing traffic between agent versions |\n| agentVersion | string | No | The version of the agent to use. If not specified, a new version is created |\n\nWhen redeploying an agent with changes, you must ensure the agent version is updated to avoid deployment failures with \"agent already exists\" errors. The recommended way to handle this is to include the `lastUpdated` property in the agent's description, which automatically updates whenever the agent is modified. This ensures a new version is created on each deployment.\n\nExample:\n\n```python\nagent = bedrock.Agent(self, \"Agent\",\n    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,\n    instruction=\"You are a helpful and friendly agent that answers questions about literature.\"\n)\n\nagent_alias = bedrock.AgentAlias(self, \"myAlias\",\n    agent_alias_name=\"production\",\n    agent=agent,\n    description=f\"Production version of my agent. Created at {agent.lastUpdated}\"\n)\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "The CDK Construct Library for Amazon Bedrock",
    "version": "2.206.0a0",
    "project_urls": {
        "Homepage": "https://github.com/aws/aws-cdk",
        "Source": "https://github.com/aws/aws-cdk.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "025a07ee5b889c442b5e7fb9c9a5cf884b52cf77efed6ca66f9b75473e031c56",
                "md5": "e6df857cf0563700a9b0c17a2d05318a",
                "sha256": "2572a7678b90b5a5b8f5d38a5d9816f993f246eead01190ce97f34d76a8a6d39"
            },
            "downloads": -1,
            "filename": "aws_cdk_aws_bedrock_alpha-2.206.0a0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e6df857cf0563700a9b0c17a2d05318a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.9",
            "size": 271419,
            "upload_time": "2025-07-16T12:47:54",
            "upload_time_iso_8601": "2025-07-16T12:47:54.052701Z",
            "url": "https://files.pythonhosted.org/packages/02/5a/07ee5b889c442b5e7fb9c9a5cf884b52cf77efed6ca66f9b75473e031c56/aws_cdk_aws_bedrock_alpha-2.206.0a0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4929808efa179117588ea8821582ec5cf9631b612580f1ae2f674db9b827fcc1",
                "md5": "e8867d7c6ce910ffffb5448d39c3d6a0",
                "sha256": "264270fdc89990cef1ec30f8b0ba26f45929d4a00f7cd5135c6d2aec6836a638"
            },
            "downloads": -1,
            "filename": "aws_cdk_aws_bedrock_alpha-2.206.0a0.tar.gz",
            "has_sig": false,
            "md5_digest": "e8867d7c6ce910ffffb5448d39c3d6a0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.9",
            "size": 279998,
            "upload_time": "2025-07-16T12:48:39",
            "upload_time_iso_8601": "2025-07-16T12:48:39.598373Z",
            "url": "https://files.pythonhosted.org/packages/49/29/808efa179117588ea8821582ec5cf9631b612580f1ae2f674db9b827fcc1/aws_cdk_aws_bedrock_alpha-2.206.0a0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-16 12:48:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aws",
    "github_project": "aws-cdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aws-cdk.aws-bedrock-alpha"
}
        
Elapsed time: 1.01179s