Skip to content

Commit 1cadfc7

Browse files
committed
Revert "fix(import): auto-disable online eval configs to unlock evaluators during import"
This reverts commit 5839391.
1 parent 5839391 commit 1cadfc7

2 files changed

Lines changed: 26 additions & 128 deletions

File tree

src/cli/aws/agentcore-control.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ export interface GetEvaluatorResult {
458458
level: string;
459459
status: string;
460460
description?: string;
461-
lockedForModification?: boolean;
462461
evaluatorConfig?: {
463462
llmAsAJudge?: GetEvaluatorLlmConfig;
464463
codeBased?: GetEvaluatorCodeBasedConfig;
@@ -531,7 +530,6 @@ export async function getEvaluator(options: GetEvaluatorOptions): Promise<GetEva
531530
level: response.level ?? 'SESSION',
532531
status: response.status ?? 'UNKNOWN',
533532
description: response.description,
534-
lockedForModification: response.lockedForModification,
535533
evaluatorConfig,
536534
tags,
537535
};

src/cli/commands/import/import-evaluator.ts

Lines changed: 26 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import type { Evaluator } from '../../../schema';
22
import type { EvaluatorSummary, GetEvaluatorResult } from '../../aws/agentcore-control';
3-
import {
4-
getEvaluator,
5-
getOnlineEvaluationConfig,
6-
listAllEvaluators,
7-
listAllOnlineEvaluationConfigs,
8-
updateOnlineEvalExecutionStatus,
9-
} from '../../aws/agentcore-control';
3+
import { getEvaluator, listAllEvaluators } from '../../aws/agentcore-control';
104
import { ANSI } from './constants';
115
import { parseAndValidateArn } from './import-utils';
126
import { executeResourceImport } from './resource-import';
@@ -54,136 +48,42 @@ export function toEvaluatorSpec(detail: GetEvaluatorResult, localName: string):
5448
};
5549
}
5650

57-
/**
58-
* Create an evaluator descriptor with closed-over state for tracking
59-
* online eval configs that were temporarily disabled to unlock the evaluator.
60-
*/
61-
function createEvaluatorDescriptor(): {
62-
descriptor: ResourceImportDescriptor<GetEvaluatorResult, EvaluatorSummary>;
63-
getDisabledConfigs: () => { configId: string; configName: string }[];
64-
getRegion: () => string | undefined;
65-
} {
66-
const disabledConfigs: { configId: string; configName: string }[] = [];
67-
let resolvedRegion: string | undefined;
68-
69-
const descriptor: ResourceImportDescriptor<GetEvaluatorResult, EvaluatorSummary> = {
70-
resourceType: 'evaluator',
71-
displayName: 'evaluator',
72-
logCommand: 'import-evaluator',
73-
74-
listResources: region => listAllEvaluators({ region }),
75-
getDetail: (region, id) => getEvaluator({ region, evaluatorId: id }),
76-
parseResourceId: (arn, target) => parseAndValidateArn(arn, 'evaluator', target).resourceId,
77-
78-
extractSummaryId: s => s.evaluatorId,
79-
formatListItem: (s, i) =>
80-
` ${ANSI.dim}[${i + 1}]${ANSI.reset} ${s.evaluatorName}${s.status}\n ${ANSI.dim}${s.evaluatorArn}${ANSI.reset}`,
81-
formatAutoSelectMessage: s => `Found 1 evaluator: ${s.evaluatorName} (${s.evaluatorId}). Auto-selecting.`,
82-
83-
extractDetailName: d => d.evaluatorName,
84-
extractDetailArn: d => d.evaluatorArn,
85-
readyStatus: 'ACTIVE',
86-
extractDetailStatus: d => d.status,
51+
const evaluatorDescriptor: ResourceImportDescriptor<GetEvaluatorResult, EvaluatorSummary> = {
52+
resourceType: 'evaluator',
53+
displayName: 'evaluator',
54+
logCommand: 'import-evaluator',
8755

88-
getExistingNames: spec => (spec.evaluators ?? []).map(e => e.name),
89-
addToProjectSpec: (detail, localName, spec) => {
90-
(spec.evaluators ??= []).push(toEvaluatorSpec(detail, localName));
91-
},
56+
listResources: region => listAllEvaluators({ region }),
57+
getDetail: (region, id) => getEvaluator({ region, evaluatorId: id }),
58+
parseResourceId: (arn, target) => parseAndValidateArn(arn, 'evaluator', target).resourceId,
9259

93-
cfnResourceType: 'AWS::BedrockAgentCore::Evaluator',
94-
cfnNameProperty: 'EvaluatorName',
95-
cfnIdentifierKey: 'EvaluatorId',
60+
extractSummaryId: s => s.evaluatorId,
61+
formatListItem: (s, i) =>
62+
` ${ANSI.dim}[${i + 1}]${ANSI.reset} ${s.evaluatorName}${s.status}\n ${ANSI.dim}${s.evaluatorArn}${ANSI.reset}`,
63+
formatAutoSelectMessage: s => `Found 1 evaluator: ${s.evaluatorName} (${s.evaluatorId}). Auto-selecting.`,
9664

97-
buildDeployedStateEntry: (name, id, d) => ({ type: 'evaluator', name, id, arn: d.evaluatorArn }),
98-
99-
beforeConfigWrite: async ({ detail, target, onProgress, logger }) => {
100-
resolvedRegion = target.region;
101-
if (!detail.lockedForModification) return;
102-
103-
logger.startStep('Unlock evaluator');
104-
onProgress('Evaluator is locked. Finding referencing online eval configs...');
105-
106-
const allConfigs = await listAllOnlineEvaluationConfigs({ region: target.region });
107-
const enabledConfigs = allConfigs.filter(c => c.executionStatus === 'ENABLED');
108-
109-
for (const config of enabledConfigs) {
110-
const configDetail = await getOnlineEvaluationConfig({
111-
region: target.region,
112-
configId: config.onlineEvaluationConfigId,
113-
});
114-
if (configDetail.evaluatorIds?.includes(detail.evaluatorId)) {
115-
onProgress(`Disabling online eval config: ${config.onlineEvaluationConfigName}`);
116-
await updateOnlineEvalExecutionStatus({
117-
region: target.region,
118-
onlineEvaluationConfigId: config.onlineEvaluationConfigId,
119-
executionStatus: 'DISABLED',
120-
});
121-
disabledConfigs.push({
122-
configId: config.onlineEvaluationConfigId,
123-
configName: config.onlineEvaluationConfigName,
124-
});
125-
}
126-
}
65+
extractDetailName: d => d.evaluatorName,
66+
extractDetailArn: d => d.evaluatorArn,
67+
readyStatus: 'ACTIVE',
68+
extractDetailStatus: d => d.status,
12769

128-
if (disabledConfigs.length > 0) {
129-
onProgress(`Disabled ${disabledConfigs.length} online eval config(s) to unlock evaluator`);
130-
} else {
131-
onProgress('Evaluator is locked but no enabled online eval configs reference it');
132-
}
133-
logger.endStep('success');
134-
},
135-
};
70+
getExistingNames: spec => (spec.evaluators ?? []).map(e => e.name),
71+
addToProjectSpec: (detail, localName, spec) => {
72+
(spec.evaluators ??= []).push(toEvaluatorSpec(detail, localName));
73+
},
13674

137-
return {
138-
descriptor,
139-
getDisabledConfigs: () => [...disabledConfigs],
140-
getRegion: () => resolvedRegion,
141-
};
142-
}
75+
cfnResourceType: 'AWS::BedrockAgentCore::Evaluator',
76+
cfnNameProperty: 'EvaluatorName',
77+
cfnIdentifierKey: 'EvaluatorId',
14378

144-
/**
145-
* Re-enable online eval configs that were temporarily disabled during import.
146-
*/
147-
async function reEnableConfigs(
148-
configs: { configId: string; configName: string }[],
149-
region: string,
150-
onWarn: (msg: string) => void
151-
): Promise<void> {
152-
for (const config of configs) {
153-
try {
154-
await updateOnlineEvalExecutionStatus({
155-
region,
156-
onlineEvaluationConfigId: config.configId,
157-
executionStatus: 'ENABLED',
158-
});
159-
} catch (err) {
160-
onWarn(
161-
`Warning: Could not re-enable online eval config "${config.configName}" (${config.configId}): ${err instanceof Error ? err.message : String(err)}`
162-
);
163-
}
164-
}
165-
}
79+
buildDeployedStateEntry: (name, id, d) => ({ type: 'evaluator', name, id, arn: d.evaluatorArn }),
80+
};
16681

16782
/**
16883
* Handle `agentcore import evaluator`.
16984
*/
17085
export async function handleImportEvaluator(options: ImportResourceOptions): Promise<ImportResourceResult> {
171-
const { descriptor, getDisabledConfigs, getRegion } = createEvaluatorDescriptor();
172-
173-
try {
174-
const result = await executeResourceImport(descriptor, options);
175-
return result;
176-
} finally {
177-
const disabled = getDisabledConfigs();
178-
const region = getRegion();
179-
if (disabled.length > 0 && region) {
180-
await reEnableConfigs(disabled, region, msg => console.warn(msg));
181-
const names = disabled.map(c => c.configName).join(', ');
182-
console.warn(
183-
`\n${ANSI.yellow}Warning:${ANSI.reset} ${disabled.length} online eval config(s) were temporarily disabled to unlock this evaluator and have been re-enabled: ${names}`
184-
);
185-
}
186-
}
86+
return executeResourceImport(evaluatorDescriptor, options);
18787
}
18888

18989
/**

0 commit comments

Comments
 (0)