Skip to content

Commit 8abe669

Browse files
chore: gpt review and gpt fix
1 parent 29db3b4 commit 8abe669

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/commands/agent/test/run-eval.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,21 @@ async function callEvalApi(org: Org, payload: EvalPayload): Promise<{ results?:
6262

6363
async function resolveAgent(org: Org, apiName: string): Promise<{ agentId: string; versionId: string }> {
6464
const conn = org.getConnection();
65-
const botResult = await conn.query<{ Id: string }>(`SELECT Id FROM BotDefinition WHERE DeveloperName = '${apiName}'`);
65+
66+
// Escape single quotes to prevent SOQL injection
67+
const escapedApiName = apiName.replace(/'/g, "\\'");
68+
69+
const botResult = await conn.query<{ Id: string }>(
70+
`SELECT Id FROM BotDefinition WHERE DeveloperName = '${escapedApiName}'`
71+
);
6672
if (!botResult.records.length) {
6773
throw messages.createError('error.agentNotFound', [apiName]);
6874
}
6975
const agentId = botResult.records[0].Id;
7076

77+
// Filter to published/active versions only
7178
const versionResult = await conn.query<{ Id: string }>(
72-
`SELECT Id FROM BotVersion WHERE BotDefinitionId = '${agentId}' ORDER BY VersionNumber DESC LIMIT 1`
79+
`SELECT Id FROM BotVersion WHERE BotDefinitionId = '${agentId}' AND Status = 'Published' ORDER BY VersionNumber DESC LIMIT 1`
7380
);
7481
if (!versionResult.records.length) {
7582
throw messages.createError('error.agentVersionNotFound', [apiName]);

src/evalNormalizer.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,9 @@ export function normalizeEvaluatorFields(steps: EvalStep[]): EvalStep[] {
342342
normalizeScoringEvaluator(normalized, evalType);
343343
} else if (ASSERTION_EVALUATORS.has(evalType)) {
344344
normalizeAssertionEvaluator(normalized, evalType);
345-
} else if (!('metric_name' in normalized) && evalType.includes('.')) {
346-
// Unknown evaluator type -- just auto-inject metric_name
347-
normalized.metric_name = evalType.split('.')[1];
348345
}
346+
// Don't inject metric_name for unknown evaluator types to avoid API validation errors
347+
// Unknown evaluators like bot_response_rating and planner_topic_assertion don't use metric_name
349348

350349
return normalized as EvalStep;
351350
});

0 commit comments

Comments
 (0)