Skip to content

Commit 1506e14

Browse files
committed
fix(import): strip CDK project prefix from OEC service name when resolving agent
CDK constructs set the OEC service name as "{projectName}_{agentName}.DEFAULT". extractAgentName() strips ".DEFAULT" but not the project prefix, so the lookup fails against local runtime names. Now strips the prefix as a fast path before falling back to the deployed-state API lookup.
1 parent 7bf2aee commit 1506e14

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/cli/commands/import/import-online-eval.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,26 @@ function createOnlineEvalDescriptor(): ResourceImportDescriptor<GetOnlineEvalCon
116116
}
117117

118118
// Resolve the local agent name. The AWS name from the OEC service names
119-
// may differ from the local name if the runtime was imported with --name.
119+
// may differ from the local name if the runtime was imported with --name,
120+
// or it may include the CDK project prefix ("{projectName}_{agentName}").
120121
const agentNames = new Set((projectSpec.runtimes ?? []).map(r => r.name));
121122
let agentName: string | undefined;
122123

123124
if (agentNames.has(awsAgentName)) {
124125
// Direct match — local name equals AWS name
125126
agentName = awsAgentName;
126127
} else {
128+
// Strip CDK project prefix if present (service names use "{projectName}_{agentName}")
129+
const prefix = `${ctx.projectName}_`;
130+
if (awsAgentName.startsWith(prefix)) {
131+
const stripped = awsAgentName.slice(prefix.length);
132+
if (agentNames.has(stripped)) {
133+
agentName = stripped;
134+
}
135+
}
136+
}
137+
138+
if (!agentName) {
127139
// Look up the AWS runtime ID for the AWS name, then find the local name
128140
// that maps to it in deployed state.
129141
onProgress(`Agent "${awsAgentName}" not found by name, checking deployed state...`);

0 commit comments

Comments
 (0)