Skip to content

Commit 9e2cd39

Browse files
authored
Merge branch 'main' into fix-agentcore-policy
2 parents 27da5b2 + a38afc9 commit 9e2cd39

File tree

60 files changed

+10816
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+10816
-232
lines changed

.github/workflows/codebuild-pr-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
sudo sysctl -w vm.max_map_count=2251954
7171
7272
- name: Build
73-
run: /bin/bash ./build.sh --ci
73+
run: /bin/bash ./build.sh --ci --concurrency 10
7474

7575
- name: Run Rosetta
7676
run: /bin/bash ./scripts/run-rosetta.sh

.github/workflows/pr-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
sudo sysctl -w vm.max_map_count=2251954
6666
6767
- name: Build
68-
run: /bin/bash ./build.sh --ci --concurrency=10
68+
run: /bin/bash ./build.sh --ci --concurrency 10
6969

7070
- name: Run Rosetta
7171
run: /bin/bash ./scripts/run-rosetta.sh

allowed-breaking-changes.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,3 @@ removed:aws-cdk-lib.lambda_layer_kubectl.KubectlLayer
966966
# Fixing the JsonSchema interface to be consistent with JSON Schema spec
967967
changed-type:aws-cdk-lib.aws_apigateway.JsonSchema.additionalItems
968968
strengthened:aws-cdk-lib.aws_apigateway.JsonSchema
969-
970-
# Revert a failing change
971-
strengthened:aws-cdk-lib.aws_stepfunctions.StateMachineProps

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
"fs-extra": "^9.1.0",
2727
"graceful-fs": "^4.2.11",
2828
"jest-junit": "^13.2.0",
29-
"jsii-diff": "1.116.0",
30-
"jsii-pacmak": "1.116.0",
31-
"jsii-reflect": "1.116.0",
29+
"jsii-diff": "1.118.0",
30+
"jsii-pacmak": "1.118.0",
31+
"jsii-reflect": "1.118.0",
3232
"lerna": "^8.2.4",
3333
"nx": "^20",
3434
"semver": "^7.7.2",

packages/@aws-cdk/aws-bedrock-agentcore-alpha/README.md

Lines changed: 325 additions & 3 deletions
Large diffs are not rendered by default.

packages/@aws-cdk/aws-bedrock-agentcore-alpha/agentcore/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
export * from './memory/memory';
2+
export * from './memory/strategies/managed-strategy';
3+
export * from './memory/strategies/self-managed-strategy';
4+
export * from './memory/memory-strategy';
15
// ===================================
26
// Network Configuration
37
// ===================================
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
5+
* with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
10+
* OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
11+
* and limitations under the License.
12+
*/
13+
14+
import * as bedrockagentcore from 'aws-cdk-lib/aws-bedrockagentcore';
15+
import * as iam from 'aws-cdk-lib/aws-iam';
16+
// Internal libs
17+
import { ManagedMemoryStrategy, ManagedStrategyProps } from './strategies/managed-strategy';
18+
import { SelfManagedMemoryStrategy, SelfManagedStrategyProps } from './strategies/self-managed-strategy';
19+
20+
/******************************************************************************
21+
* CONSTANTS
22+
*****************************************************************************/
23+
/**
24+
* Minimum length for memory strategy name
25+
* @internal
26+
*/
27+
export const MEMORY_NAME_MIN_LENGTH = 1;
28+
/**
29+
* Maximum length for memory strategy name
30+
* @internal
31+
*/
32+
export const MEMORY_NAME_MAX_LENGTH = 48;
33+
34+
/**
35+
* Long-term memory extraction strategy types.
36+
*/
37+
export enum MemoryStrategyType {
38+
/**
39+
* Summarization strategy - extracts concise summaries to preserve critical context and key insights
40+
*/
41+
SUMMARIZATION = 'SUMMARIZATION',
42+
/**
43+
* Semantic memory strategy - extracts general factual knowledge, concepts and meanings from raw conversations
44+
* using vector embeddings for similarity search.
45+
*/
46+
SEMANTIC = 'SEMANTIC',
47+
/**
48+
* User preferences strategy - extracts user behavior patterns from raw conversations.
49+
*/
50+
USER_PREFERENCE = 'USER_PREFERENCE',
51+
/**
52+
* Customize memory processing through custom foundation model and prompt templates.
53+
*/
54+
CUSTOM = 'CUSTOM',
55+
}
56+
57+
/******************************************************************************
58+
* Common
59+
*****************************************************************************/
60+
/**
61+
* Configuration parameters common for any memory strategy
62+
*/
63+
export interface MemoryStrategyCommonProps {
64+
/**
65+
* The name for the strategy
66+
* @required - Yes
67+
*/
68+
readonly name: string;
69+
/**
70+
* The description of the strategy
71+
* @default No description
72+
* @required - No
73+
*/
74+
readonly description?: string;
75+
}
76+
77+
/******************************************************************************
78+
* Interface
79+
*****************************************************************************/
80+
/**
81+
* Interface for Memory strategies
82+
*/
83+
export interface IMemoryStrategy {
84+
/**
85+
* The name of the memory strategy
86+
*/
87+
readonly name: string;
88+
/**
89+
* The description of the memory strategy
90+
*/
91+
readonly description?: string;
92+
/**
93+
* The type of memory strategy
94+
*/
95+
readonly strategyType: MemoryStrategyType;
96+
/**
97+
* Renders internal attributes to CloudFormation
98+
*/
99+
render(): bedrockagentcore.CfnMemory.MemoryStrategyProperty;
100+
/**
101+
* Grants the necessary permissions to the role
102+
* @param grantee - The grantee to grant permissions to
103+
* @returns The Grant object for chaining
104+
*/
105+
grant(grantee: iam.IGrantable): iam.Grant | undefined;
106+
}
107+
108+
/******************************************************************************
109+
* Factory
110+
*****************************************************************************/
111+
/**
112+
* Factory class for creating memory strategies
113+
* If you need long-term memory for context recall across sessions, you can setup memory extraction strategies to extract the relevant memory from the raw events.
114+
* Use built-in strategies for quick setup, use built-in strategies with override to specify models and prompt templates.
115+
*
116+
* @see https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/memory-strategies.html
117+
*/
118+
export class MemoryStrategy {
119+
/**
120+
* Default strategies for organizing and extracting memory data, each optimized for specific use cases.
121+
* This strategy compresses conversations into concise overviews, preserving essential context and key insights for quick recall.
122+
* Extracted memory example: Users confused by cloud setup during onboarding.
123+
* @returns A ManagedMemoryStrategy.
124+
*/
125+
public static usingBuiltInSummarization(): ManagedMemoryStrategy {
126+
return new ManagedMemoryStrategy(MemoryStrategyType.SUMMARIZATION, {
127+
name: 'summary_builtin_cdkGen0001',
128+
description: 'Summarize interactions to preserve critical context and key insights',
129+
namespaces: ['/strategies/{memoryStrategyId}/actors/{actorId}/sessions/{sessionId}'],
130+
});
131+
}
132+
/**
133+
* Default strategies for organizing and extracting memory data, each optimized for specific use cases.
134+
* Distills general facts, concepts, and underlying meanings from raw conversational data, presenting the information in a context-independent format.
135+
* Extracted memory example: In-context learning = task-solving via examples, no training needed.
136+
* @returns A ManagedMemoryStrategy.
137+
*/
138+
public static usingBuiltInSemantic(): ManagedMemoryStrategy {
139+
return new ManagedMemoryStrategy(MemoryStrategyType.SEMANTIC, {
140+
name: 'semantic_builtin_cdkGen0001',
141+
description:
142+
'Extract general factual knowledge, concepts and meanings from raw conversations in a context-independent format.',
143+
namespaces: ['/strategies/{memoryStrategyId}/actors/{actorId}'],
144+
});
145+
}
146+
/**
147+
* Default strategies for organizing and extracting memory data, each optimized for specific use cases.
148+
* Captures individual preferences, interaction patterns, and personalized settings to enhance future experiences.
149+
* Extracted memory example: User needs clear guidance on cloud storage account connection during onboarding.
150+
* @returns A ManagedMemoryStrategy.
151+
*/
152+
public static usingBuiltInUserPreference(): ManagedMemoryStrategy {
153+
return new ManagedMemoryStrategy(MemoryStrategyType.USER_PREFERENCE, {
154+
name: 'preference_builtin_cdkGen0001',
155+
description: 'Capture individual preferences, interaction patterns, and personalized settings to enhance future experiences.',
156+
namespaces: ['/strategies/{memoryStrategyId}/actors/{actorId}'],
157+
});
158+
}
159+
/**
160+
* Creates a semantic memory strategy with custom configuration.
161+
* Distills general facts, concepts, and underlying meanings from raw conversational data, presenting the information in a context-independent format.
162+
* Extracted memory example: In-context learning = task-solving via examples, no training needed.
163+
* @param config - The configuration for the semantic memory strategy.
164+
* @returns A ManagedMemoryStrategy.
165+
*/
166+
public static usingSemantic(config: ManagedStrategyProps): ManagedMemoryStrategy {
167+
return new ManagedMemoryStrategy(MemoryStrategyType.SEMANTIC, config);
168+
}
169+
/**
170+
* Creates a user preference memory strategy with custom configuration.
171+
* Captures individual preferences, interaction patterns, and personalized settings to enhance future experiences.
172+
* Extracted memory example: User needs clear guidance on cloud storage account connection during onboarding.
173+
* @param config - The configuration for the user preference memory strategy.
174+
* @returns A ManagedMemoryStrategy.
175+
*/
176+
public static usingUserPreference(config: ManagedStrategyProps): ManagedMemoryStrategy {
177+
return new ManagedMemoryStrategy(MemoryStrategyType.USER_PREFERENCE, config);
178+
}
179+
/**
180+
* Creates a summarization memory strategy with custom configuration.
181+
* This strategy compresses conversations into concise overviews, preserving essential context and key insights for quick recall.
182+
* Extracted memory example: Users confused by cloud setup during onboarding.
183+
* @param config - The configuration for the summarization memory strategy.
184+
* @returns A ManagedMemoryStrategy.
185+
*/
186+
public static usingSummarization(config: ManagedStrategyProps): ManagedMemoryStrategy {
187+
return new ManagedMemoryStrategy(MemoryStrategyType.SUMMARIZATION, config);
188+
}
189+
/**
190+
* Creates a self-managed memory strategy.
191+
* A self-managed strategy gives you complete control over your memory extraction and consolidation pipelines.
192+
* @param config - The configuration for the self-managed memory strategy.
193+
* @returns A SelfManagedMemoryStrategy.
194+
*/
195+
public static usingSelfManaged(config: SelfManagedStrategyProps): SelfManagedMemoryStrategy {
196+
// Scope is passed for future use in permission granting
197+
return new SelfManagedMemoryStrategy(MemoryStrategyType.CUSTOM, config);
198+
}
199+
}

0 commit comments

Comments
 (0)