diff --git a/src/cli/aws/agentcore-harness.ts b/src/cli/aws/agentcore-harness.ts index cca371fbc..70684f1d2 100644 --- a/src/cli/aws/agentcore-harness.ts +++ b/src/cli/aws/agentcore-harness.ts @@ -37,8 +37,15 @@ export interface HarnessSkill { path: string; } +export interface HarnessAgentCoreMemoryConfiguration { + arn: string; + actorId?: string; + messagesCount?: number; + retrievalConfig?: Record; +} + export interface HarnessMemoryConfiguration { - memoryArn?: string; + agentCoreMemoryConfiguration: HarnessAgentCoreMemoryConfiguration; } export interface HarnessTruncationConfiguration { diff --git a/src/cli/operations/deploy/imperative/deployers/__tests__/harness-mapper.test.ts b/src/cli/operations/deploy/imperative/deployers/__tests__/harness-mapper.test.ts index 8d5e033d9..a2ee5256b 100644 --- a/src/cli/operations/deploy/imperative/deployers/__tests__/harness-mapper.test.ts +++ b/src/cli/operations/deploy/imperative/deployers/__tests__/harness-mapper.test.ts @@ -380,7 +380,9 @@ describe('mapHarnessSpecToCreateOptions', () => { }); expect(result.memory).toEqual({ - memoryArn: 'arn:aws:bedrock-agentcore:us-east-1:123456789012:memory/mem-123', + agentCoreMemoryConfiguration: { + arn: 'arn:aws:bedrock-agentcore:us-east-1:123456789012:memory/mem-123', + }, }); }); @@ -391,7 +393,9 @@ describe('mapHarnessSpecToCreateOptions', () => { const result = await mapHarnessSpecToCreateOptions({ ...BASE_OPTIONS, harnessSpec: spec }); expect(result.memory).toEqual({ - memoryArn: 'arn:aws:bedrock-agentcore:us-east-1:123456789012:memory/custom-mem', + agentCoreMemoryConfiguration: { + arn: 'arn:aws:bedrock-agentcore:us-east-1:123456789012:memory/custom-mem', + }, }); }); diff --git a/src/cli/operations/deploy/imperative/deployers/harness-deployer.ts b/src/cli/operations/deploy/imperative/deployers/harness-deployer.ts index 3f000e5d0..ea5b31d5f 100644 --- a/src/cli/operations/deploy/imperative/deployers/harness-deployer.ts +++ b/src/cli/operations/deploy/imperative/deployers/harness-deployer.ts @@ -192,7 +192,7 @@ export class HarnessDeployer implements ImperativeDeployer ): HarnessMemoryConfiguration | undefined { + let arn: string | undefined; + // Direct ARN takes precedence if (memory.arn) { - return { memoryArn: memory.arn }; - } - - // Resolve by name from deployed state or CDK outputs - if (memory.name) { - // Try deployed state first + arn = memory.arn; + } else if (memory.name) { + // Resolve by name from deployed state or CDK outputs const deployedMemory = deployedResources?.memories?.[memory.name]; if (deployedMemory) { - return { memoryArn: deployedMemory.memoryArn }; + arn = deployedMemory.memoryArn; + } else if (cdkOutputs) { + arn = resolveMemoryArnFromOutputs(memory.name, cdkOutputs); } - // Fall back to CDK outputs - if (cdkOutputs) { - const memoryArn = resolveMemoryArnFromOutputs(memory.name, cdkOutputs); - if (memoryArn) { - return { memoryArn }; - } + if (!arn) { + throw new Error( + `Memory "${memory.name}" referenced by harness is not in deployed state. Ensure the memory is defined in agentcore.json and has been deployed.` + ); } + } - throw new Error( - `Memory "${memory.name}" referenced by harness is not in deployed state. Ensure the memory is defined in agentcore.json and has been deployed.` - ); + if (!arn) { + return undefined; } - return undefined; + return { + agentCoreMemoryConfiguration: { + arn, + ...(memory.actorId && { actorId: memory.actorId }), + }, + }; } /**