mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-24 10:13:11 +02:00
test: preserve complete question identity across an answer
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
9d322bfa21
commit
3d6d6d1bda
3 files changed
+7
-5
No files matched your search
@@ -49,6 +49,10 @@ describe("necessary free-text question journey", () => {
|
||||
["unrelated rendered card", (points: Row[]) => { points[0].questionPresentation.interactionId = "foreign"; }],
|
||||
["missing semantic receipt", (points: Row[]) => { points[0].runs[0].resultJson.semanticToolReceipts = {}; }],
|
||||
["foreign question", (points: Row[]) => { points[0].interactions[0].companyId = "foreign"; }],
|
||||
["foreign resolved company", (points: Row[]) => { points[1].interactions[0].companyId = "foreign"; }],
|
||||
["changed creator", (points: Row[]) => { points[1].interactions[0].createdByAgentId = "foreign"; }],
|
||||
["changed idempotency key", (points: Row[]) => { points[1].interactions[0].idempotencyKey = "foreign"; }],
|
||||
["changed continuation policy", (points: Row[]) => { points[1].interactions[0].continuationPolicy = "none"; }],
|
||||
["fabricated agent answer", (points: Row[]) => { points[1].interactions[0].resolvedByAgentId = "agent"; }],
|
||||
["wrong answer", (points: Row[]) => { points[1].interactions[0].result.answers[0].otherText = "invented"; }],
|
||||
["duplicate answer", (points: Row[]) => { points[1].interactions[0].result.answers.push(points[1].interactions[0].result.answers[0]); }],
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { isDeepStrictEqual } from "node:util";
|
||||
import { createHash } from "node:crypto";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { continuationScenario, continuationTasks, necessaryQuestionContract } from "./continuation-cases.js";
|
||||
import { questionResumedOnce, validResumeQuestionForm } from "./question-resume-scoring.js";
|
||||
import { questionResumedOnce, sameQuestion, validResumeQuestionForm } from "./question-resume-scoring.js";
|
||||
import type { ContinuationCheckpoint } from "./continuation-scoring.js";
|
||||
import type { RunnerTaskFixture } from "./types.js";
|
||||
|
||||
@@ -31,8 +30,7 @@ export function gradeNecessaryQuestion(checkpoints: ContinuationCheckpoint[], an
|
||||
check("necessary-question.visible", initial?.questionPresentation?.interactionId === question?.id &&
|
||||
initial?.questionPresentation?.promptVisible === true && initial?.questionPresentation?.contextVisible === true,
|
||||
"The browser must observe the actual question and context, not only its title."),
|
||||
check("necessary-question.answer", finished.length === 1 && resolved?.id === question?.id && resolved?.sourceRunId === question?.sourceRunId &&
|
||||
isDeepStrictEqual(question?.payload, resolved?.payload) && resolved?.status === "answered" &&
|
||||
check("necessary-question.answer", finished.length === 1 && !!question && sameQuestion(question, resolved) && resolved?.status === "answered" &&
|
||||
typeof resolved.resolvedByUserId === "string" && !!resolved.resolvedByUserId && !resolved.resolvedByAgentId &&
|
||||
Array.isArray(response) && response.length === 1 && response[0]?.questionId === field?.id && response[0]?.otherText === answer &&
|
||||
!response[0]?.optionIds?.length,
|
||||
|
||||
@@ -46,7 +46,7 @@ export function validResumeQuestionForm(checkpoint: ContinuationCheckpoint, i: R
|
||||
(fields.length === 1 || (path === "provider" && isSingleClaudeQuestion(fields)));
|
||||
}
|
||||
|
||||
function sameQuestion(a: Row, b?: Row) {
|
||||
export function sameQuestion(a: Row, b?: Row) {
|
||||
return !!b && ["id", "kind", "sourceRunId", "issueId", "companyId", "createdByAgentId", "idempotencyKey", "continuationPolicy"]
|
||||
.every(k => a[k] === b[k]) && isDeepStrictEqual(a.payload, b.payload);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user