Skip to content

Commit aa8e049

Browse files
Merge pull request #1288 from aws/fix/harness-memory-configuration
fix: align harness memory config with Smithy API model
2 parents cfadd35 + 329a4ad commit aa8e049

4 files changed

Lines changed: 37 additions & 22 deletions

File tree

src/cli/aws/agentcore-harness.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,15 @@ export interface HarnessSkill {
3737
path: string;
3838
}
3939

40+
export interface HarnessAgentCoreMemoryConfiguration {
41+
arn: string;
42+
actorId?: string;
43+
messagesCount?: number;
44+
retrievalConfig?: Record<string, { topK?: number; relevanceScore?: number; strategyId?: string }>;
45+
}
46+
4047
export interface HarnessMemoryConfiguration {
41-
memoryArn?: string;
48+
agentCoreMemoryConfiguration: HarnessAgentCoreMemoryConfiguration;
4249
}
4350

4451
export interface HarnessTruncationConfiguration {

src/cli/operations/deploy/imperative/deployers/__tests__/harness-mapper.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,9 @@ describe('mapHarnessSpecToCreateOptions', () => {
380380
});
381381

382382
expect(result.memory).toEqual({
383-
memoryArn: 'arn:aws:bedrock-agentcore:us-east-1:123456789012:memory/mem-123',
383+
agentCoreMemoryConfiguration: {
384+
arn: 'arn:aws:bedrock-agentcore:us-east-1:123456789012:memory/mem-123',
385+
},
384386
});
385387
});
386388

@@ -391,7 +393,9 @@ describe('mapHarnessSpecToCreateOptions', () => {
391393
const result = await mapHarnessSpecToCreateOptions({ ...BASE_OPTIONS, harnessSpec: spec });
392394

393395
expect(result.memory).toEqual({
394-
memoryArn: 'arn:aws:bedrock-agentcore:us-east-1:123456789012:memory/custom-mem',
396+
agentCoreMemoryConfiguration: {
397+
arn: 'arn:aws:bedrock-agentcore:us-east-1:123456789012:memory/custom-mem',
398+
},
395399
});
396400
});
397401

src/cli/operations/deploy/imperative/deployers/harness-deployer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export class HarnessDeployer implements ImperativeDeployer<HarnessDeployedStateM
192192
roleArn: executionRoleArn,
193193
status: finalHarness.status,
194194
agentRuntimeArn: extractRuntimeArn(finalHarness),
195-
memoryArn: createOptions.memory?.memoryArn,
195+
memoryArn: createOptions.memory?.agentCoreMemoryConfiguration?.arn,
196196
configHash,
197197
};
198198
notes.push(`Updated harness "${entry.name}"`);
@@ -216,7 +216,7 @@ export class HarnessDeployer implements ImperativeDeployer<HarnessDeployedStateM
216216
roleArn: executionRoleArn,
217217
status: finalHarness.status,
218218
agentRuntimeArn: extractRuntimeArn(finalHarness),
219-
memoryArn: createOptions.memory?.memoryArn,
219+
memoryArn: createOptions.memory?.agentCoreMemoryConfiguration?.arn,
220220
configHash,
221221
};
222222
notes.push(`Created harness "${entry.name}"`);

src/cli/operations/deploy/imperative/deployers/harness-mapper.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -270,33 +270,37 @@ function mapMemory(
270270
deployedResources?: DeployedResourceState,
271271
cdkOutputs?: Record<string, string>
272272
): HarnessMemoryConfiguration | undefined {
273+
let arn: string | undefined;
274+
273275
// Direct ARN takes precedence
274276
if (memory.arn) {
275-
return { memoryArn: memory.arn };
276-
}
277-
278-
// Resolve by name from deployed state or CDK outputs
279-
if (memory.name) {
280-
// Try deployed state first
277+
arn = memory.arn;
278+
} else if (memory.name) {
279+
// Resolve by name from deployed state or CDK outputs
281280
const deployedMemory = deployedResources?.memories?.[memory.name];
282281
if (deployedMemory) {
283-
return { memoryArn: deployedMemory.memoryArn };
282+
arn = deployedMemory.memoryArn;
283+
} else if (cdkOutputs) {
284+
arn = resolveMemoryArnFromOutputs(memory.name, cdkOutputs);
284285
}
285286

286-
// Fall back to CDK outputs
287-
if (cdkOutputs) {
288-
const memoryArn = resolveMemoryArnFromOutputs(memory.name, cdkOutputs);
289-
if (memoryArn) {
290-
return { memoryArn };
291-
}
287+
if (!arn) {
288+
throw new Error(
289+
`Memory "${memory.name}" referenced by harness is not in deployed state. Ensure the memory is defined in agentcore.json and has been deployed.`
290+
);
292291
}
292+
}
293293

294-
throw new Error(
295-
`Memory "${memory.name}" referenced by harness is not in deployed state. Ensure the memory is defined in agentcore.json and has been deployed.`
296-
);
294+
if (!arn) {
295+
return undefined;
297296
}
298297

299-
return undefined;
298+
return {
299+
agentCoreMemoryConfiguration: {
300+
arn,
301+
...(memory.actorId && { actorId: memory.actorId }),
302+
},
303+
};
300304
}
301305

302306
/**

0 commit comments

Comments
 (0)