Skip to content

Commit 0771776

Browse files
committed
Specifiy extracting user role for eval
1 parent c8fcadd commit 0771776

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/evals/core/async-engine.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,19 @@ export class AsyncRunEngine implements RunEngine {
201201
return sampleData;
202202
}
203203

204+
// Extract from the latest user message only (not tool/function messages without roles)
204205
for (let idx = conversation.length - 1; idx >= 0; idx -= 1) {
205206
const entry = conversation[idx];
206-
if (!entry.role || entry.role === 'user') {
207+
if (entry.role === 'user') {
207208
const extracted = this.extractLatestInput(entry, sampleData);
208209
if (extracted.trim().length > 0) {
209210
return extracted;
210211
}
211212
}
212213
}
213214

214-
const fallback = conversation[conversation.length - 1];
215-
const extractedFallback = this.extractLatestInput(fallback, sampleData);
216-
return extractedFallback.trim().length > 0 ? extractedFallback : sampleData;
215+
// Fallback: if no user message found, return full sample data
216+
return sampleData;
217217
}
218218

219219
private guardrailUsesConversationHistory(guardrail: ConfiguredGuardrail): boolean {

0 commit comments

Comments
 (0)