From 4be00c4f277bd2d6dd220fe74d2cfa5f7a57747b Mon Sep 17 00:00:00 2001 From: notgitika Date: Wed, 13 May 2026 17:38:49 -0400 Subject: [PATCH] fix(cdk): conditionally pass harnesses prop for CDK construct compat The vended cdk-stack.ts passes `harnesses` to AgentCoreApplication, but the npm-published @aws/agentcore-cdk package doesn't have this prop in its interface. TypeScript strict mode rejects the unknown property at compile time, causing synth to fail and deploy to error with "NoStack". Fix by building props dynamically and casting, so the property is only present when harnesses are configured. --- .../__snapshots__/assets.snapshot.test.ts.snap | 10 ++++++---- src/assets/cdk/lib/cdk-stack.ts | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap b/src/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap index c97e8e032..bf1d715db 100644 --- a/src/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +++ b/src/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap @@ -356,10 +356,12 @@ export class AgentCoreStack extends Stack { const { spec, mcpSpec, credentials, harnesses } = props; // Create AgentCoreApplication with all agents and harness roles - this.application = new AgentCoreApplication(this, 'Application', { - spec, - harnesses: harnesses?.length ? harnesses : undefined, - }); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const appProps: Record = { spec }; + if (harnesses?.length) { + appProps.harnesses = harnesses; + } + this.application = new AgentCoreApplication(this, 'Application', appProps as any); // Create AgentCoreMcp if there are gateways configured if (mcpSpec?.agentCoreGateways && mcpSpec.agentCoreGateways.length > 0) { diff --git a/src/assets/cdk/lib/cdk-stack.ts b/src/assets/cdk/lib/cdk-stack.ts index a89efc850..a823b4433 100644 --- a/src/assets/cdk/lib/cdk-stack.ts +++ b/src/assets/cdk/lib/cdk-stack.ts @@ -58,10 +58,12 @@ export class AgentCoreStack extends Stack { const { spec, mcpSpec, credentials, harnesses } = props; // Create AgentCoreApplication with all agents and harness roles - this.application = new AgentCoreApplication(this, 'Application', { - spec, - harnesses: harnesses?.length ? harnesses : undefined, - }); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const appProps: Record = { spec }; + if (harnesses?.length) { + appProps.harnesses = harnesses; + } + this.application = new AgentCoreApplication(this, 'Application', appProps as any); // Create AgentCoreMcp if there are gateways configured if (mcpSpec?.agentCoreGateways && mcpSpec.agentCoreGateways.length > 0) {