Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/cli/aws/agentcore-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ export interface HarnessSkill {
path: string;
}

export interface HarnessAgentCoreMemoryConfiguration {
arn: string;
actorId?: string;
messagesCount?: number;
retrievalConfig?: Record<string, { topK?: number; relevanceScore?: number; strategyId?: string }>;
Comment thread
notgitika marked this conversation as resolved.
}

export interface HarnessMemoryConfiguration {
memoryArn?: string;
agentCoreMemoryConfiguration: HarnessAgentCoreMemoryConfiguration;
}

export interface HarnessTruncationConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
});
});

Expand All @@ -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',
},
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class HarnessDeployer implements ImperativeDeployer<HarnessDeployedStateM
roleArn: executionRoleArn,
status: finalHarness.status,
agentRuntimeArn: extractRuntimeArn(finalHarness),
memoryArn: createOptions.memory?.memoryArn,
memoryArn: createOptions.memory?.agentCoreMemoryConfiguration?.arn,
configHash,
};
notes.push(`Updated harness "${entry.name}"`);
Expand All @@ -216,7 +216,7 @@ export class HarnessDeployer implements ImperativeDeployer<HarnessDeployedStateM
roleArn: executionRoleArn,
status: finalHarness.status,
agentRuntimeArn: extractRuntimeArn(finalHarness),
memoryArn: createOptions.memory?.memoryArn,
memoryArn: createOptions.memory?.agentCoreMemoryConfiguration?.arn,
configHash,
};
notes.push(`Created harness "${entry.name}"`);
Expand Down
38 changes: 21 additions & 17 deletions src/cli/operations/deploy/imperative/deployers/harness-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,33 +270,37 @@ function mapMemory(
deployedResources?: DeployedResourceState,
cdkOutputs?: Record<string, string>
): 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 }),
},
};
}

/**
Expand Down
Loading