(args: {
client: OpencodeClient;
config: RunnerConfig;
question: LongMemEvalQuestion;
questionState: QuestionRunState;
state: RunnerStateFile;
})
| 523 | } |
| 524 | |
| 525 | async function replayHaystack(args: { |
| 526 | client: OpencodeClient; |
| 527 | config: RunnerConfig; |
| 528 | question: LongMemEvalQuestion; |
| 529 | questionState: QuestionRunState; |
| 530 | state: RunnerStateFile; |
| 531 | }): Promise<void> { |
| 532 | const { client, config, question, questionState, state } = args; |
| 533 | |
| 534 | for (let haystackIndex = questionState.currentHaystackSessionIndex; haystackIndex < question.haystack_sessions.length; haystackIndex += 1) { |
| 535 | const datasetSession = question.haystack_sessions[haystackIndex] ?? []; |
| 536 | const sessionProgress = questionState.haystackSessions[haystackIndex]!; |
| 537 | if (sessionProgress.completed) { |
| 538 | questionState.currentHaystackSessionIndex = haystackIndex + 1; |
| 539 | questionState.currentTurnIndex = 0; |
| 540 | continue; |
| 541 | } |
| 542 | |
| 543 | questionState.status = "replaying"; |
| 544 | questionState.currentHaystackSessionIndex = haystackIndex; |
| 545 | questionState.currentTurnIndex = sessionProgress.nextTurnIndex; |
| 546 | questionState.updatedAt = nowIso(); |
| 547 | state.inProgress[question.question_id] = questionState; |
| 548 | await persistState(config, state); |
| 549 | |
| 550 | const openCodeSessionId = await ensureReplaySession(client, config, question, questionState, sessionProgress, state); |
| 551 | await sendBannerIfNeeded({ |
| 552 | client, |
| 553 | config, |
| 554 | sessionId: openCodeSessionId, |
| 555 | questionState, |
| 556 | state, |
| 557 | questionId: question.question_id, |
| 558 | bannerText: buildSessionBanner(sessionProgress.date, sessionProgress.datasetSessionId), |
| 559 | markBannerSent: () => { |
| 560 | sessionProgress.bannerSent = true; |
| 561 | }, |
| 562 | alreadySent: sessionProgress.bannerSent, |
| 563 | operationLabel: `banner:${question.question_id}:${haystackIndex}`, |
| 564 | }); |
| 565 | |
| 566 | for (let turnIndex = sessionProgress.nextTurnIndex; turnIndex < datasetSession.length; turnIndex += 1) { |
| 567 | const turn = datasetSession[turnIndex]!; |
| 568 | if (turn.role !== "user") { |
| 569 | continue; |
| 570 | } |
| 571 | |
| 572 | const result = await sendPromptAndCapture(client, config, openCodeSessionId, turn.content, { |
| 573 | operationLabel: `replay:${question.question_id}:${haystackIndex}:${turnIndex}`, |
| 574 | tools: {}, |
| 575 | }); |
| 576 | addOpenCodeUsage(questionState, result.usage, result.actualCostUsd, config); |
| 577 | |
| 578 | sessionProgress.nextTurnIndex = turnIndex + 1; |
| 579 | questionState.currentTurnIndex = sessionProgress.nextTurnIndex; |
| 580 | questionState.updatedAt = nowIso(); |
| 581 | state.inProgress[question.question_id] = questionState; |
| 582 | await persistState(config, state); |
no test coverage detected