Skip to content

Commit 2bfb3d6

Browse files
committed
fix(import): filter API-internal namespace patterns from memory import
Memory strategies like SUMMARIZATION and USER_PREFERENCE include auto-generated namespace patterns (e.g. /strategies/{memoryStrategyId}/...) that are API-internal and should not be written to local agentcore.json. Constraint: Only filters namespaces containing {memoryStrategyId} template var Rejected: Strip all namespaces for non-SEMANTIC strategies | would lose user-defined namespaces Confidence: high Scope-risk: narrow
1 parent 4bb17f2 commit 2bfb3d6

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/cli/commands/import/import-memory.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,27 @@ function mapStrategyType(apiType: string): string {
4646
return mapping[apiType] ?? apiType;
4747
}
4848

49+
/**
50+
* Filter out API-internal namespace patterns that are auto-generated
51+
* and should not be included in local config.
52+
* These patterns contain template variables like {memoryStrategyId}, {actorId}, etc.
53+
*/
54+
function filterInternalNamespaces(namespaces: string[]): string[] {
55+
return namespaces.filter(ns => !ns.includes('{memoryStrategyId}'));
56+
}
57+
4958
/**
5059
* Map an AWS GetMemory response to the CLI Memory format.
5160
*/
5261
function toMemorySpec(memory: MemoryDetail, localName: string): Memory {
5362
const strategies: Memory['strategies'] = memory.strategies.map(s => {
5463
const mappedType = mapStrategyType(s.type);
64+
const filteredNamespaces = s.namespaces ? filterInternalNamespaces(s.namespaces) : [];
5565
return {
5666
type: mappedType as Memory['strategies'][number]['type'],
5767
...(s.name && { name: s.name }),
5868
...(s.description && { description: s.description }),
59-
...(s.namespaces && s.namespaces.length > 0 && { namespaces: s.namespaces }),
69+
...(filteredNamespaces.length > 0 && { namespaces: filteredNamespaces }),
6070
...(s.reflectionNamespaces &&
6171
s.reflectionNamespaces.length > 0 && { reflectionNamespaces: s.reflectionNamespaces }),
6272
};

0 commit comments

Comments
 (0)