another fix for human choices

This commit is contained in:
Dorian
2026-03-11 00:13:31 +00:00
parent 112bcde515
commit bbe656929c
7 changed files with 42 additions and 22 deletions
+9 -4
View File
@@ -190,6 +190,11 @@ const CREATIVE_POOLS: Record<string, { good: string[]; medium: string[]; bad: st
}
function generateChoices(challenge: Challenge): string[] {
// Use pre-built choices from templateToChallenge if available (hand-picked distractors)
if (challenge.choices && challenge.choices.length >= 2) {
return shuffle([...challenge.choices])
}
if (challenge.scoring === 'factual' && challenge.answers && challenge.answers.length > 0) {
const correct = challenge.answers[0]
const num = Number(correct)
@@ -237,8 +242,9 @@ export function waitForHumanResponse(
botId: string,
challenge: Challenge,
roundNumber: number,
): Promise<{ answer: string | null; trashTalk?: string; timedOut: boolean }> {
return new Promise((resolve) => {
): { promise: Promise<{ answer: string | null; trashTalk?: string; timedOut: boolean }>; choices: string[] } {
const choices = generateChoices(challenge)
const promise = new Promise<{ answer: string | null; trashTalk?: string; timedOut: boolean }>((resolve) => {
const key = `${fightId}:${botId}`
const timeoutMs = challenge.timeout_ms || DEFAULT_HUMAN_TIMEOUT_MS
@@ -248,8 +254,6 @@ export function waitForHumanResponse(
resolve({ answer: null, timedOut: true })
}, timeoutMs)
const choices = generateChoices(challenge)
pending.set(key, {
fightId,
botId,
@@ -267,6 +271,7 @@ export function waitForHumanResponse(
logger.info('human', `waiting: ${key} round=${roundNumber} type=${challenge.type} choices=${choices.length}`)
})
return { promise, choices }
}
export function submitHumanResponse(