mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 10:07:24 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The daily QA staging smoke runs the `question-answer-resume` product
journey against a real agent
> - The board answers the agent's reference question with the text `Use
<marker>.`
> - The grader required the literal text `Use <marker>.` in the saved
note
> - Agents read `Use X.` as an instruction. Some save `Use X.`, others
save only `X`. Both notes are correct
> - This pull request grades the saved note by the complete marker
token, not by the answer's instruction wording
> - The benefit is that the smoke case no longer fails at random on a
correct note
## Linked Issues or Issue Description
**Describe the bug**
The QA staging smoke case `question-answer-resume` failed with
`journey_operation_failed`. The failed checks were
`question-resume.complete-evidence` and `question-document-reloaded`.
**Steps to reproduce**
1. Run the QA staging smoke journeys (full run on 2026-11-25).
2. The agent asks for a reference. The board answers `Use
AMBERjourney179560441987913f9fa70.`
3. The agent saves `Welcome to the club meetup this afternoon — we're
glad you're here; reference: AMBERjourney179560441987913f9fa70.`
4. The grader fails the note because it does not contain the word `Use`.
**Expected behavior**
A note that contains the complete submitted reference and the selected
time passes. A second campaign on the same day passed only because that
agent kept `Use` in the note.
**Additional context**
The private record also showed 4 `Invalid JSON body` responses. They
come from one failed `POST /api/issues/{id}/interactions` call that the
agent made itself, before it retried with a valid body and got 201. That
call is not the cause of the failure. The journey and the server route
are correct.
## What Changed
- Add `includesSubmittedReference` in
`tests/runner-e2e/question-resume-scoring.ts`. It matches the complete
marker token with no extra letters or digits on either side.
- Use it in `question-resume.complete-evidence` and in
`question-document-reloaded`.
- `waitForClarificationDocument` waits for the complete marker
(`submittedReferencePattern`), not for `Use <marker>.`. Before, a
correct note without `Use` timed out in the browser readback.
- Change the old unit test that rejected a note with only the marker. It
now accepts that note. New cases reject a shortened marker, an extended
marker, and a prefixed marker.
## Verification
- Red: the new cases failed on the old grader (3 failed, 144 passed).
The new readback case timed out on the old wait (1 failed, 3 passed).
- Green: `pnpm exec vitest run --config
tests/runner-e2e/vitest.config.ts` on the question-resume,
clarification, and question-documentation tests: 6 files, 170 tests
pass.
- `pnpm test:e2e:runner:typecheck` passes.
- After merge: a single-case `qa-staging-smoke.yml` run for
`question-answer-resume` on the new harness pin.
## Risks
Low risk. Test code only. The grader still requires the full marker. The
marker is a unique nonce, so a truncated or changed reference still
fails.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and
code execution.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
82 lines
4.9 KiB
TypeScript
82 lines
4.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { gradeQuestionDocumentation } from "./question-documentation-scoring.js";
|
|
import type { ContinuationCheckpoint } from "./continuation-scoring.js";
|
|
import { runnerMatrix } from "./catalog.js";
|
|
|
|
function recording() {
|
|
const choice = { id: "time", prompt: "Which time?", answerMode: "single_select", options: [
|
|
{ id: "am", label: "Morning" }, { id: "pm", label: "Afternoon" },
|
|
] };
|
|
const text = { id: "reference", prompt: "What reference?", answerMode: "text" };
|
|
const first: any = { id: "first", kind: "ask_user_questions", status: "pending", payload: { questionSet: { questions: [choice] } } };
|
|
const second: any = { id: "second", kind: "ask_user_questions", status: "pending", payload: { questionSet: { questions: [text] } } };
|
|
const answeredFirst = { ...structuredClone(first), status: "answered", result: { answers: [{ questionId: "time", optionIds: ["pm"] }] } };
|
|
const answeredSecond = { ...structuredClone(second), status: "answered", result: { answers: [{ questionId: "reference", optionIds: [], otherText: "Use AMBER123." }] } };
|
|
const runs = [1, 2, 3].map(id => ({ id: String(id), status: "succeeded", runtimeMode: "native", runnerProfileJson: { nativeExecutionInput: { task: { prompt: "Use Paperclip's request_human_input for durable task questions." } } } }));
|
|
const checkpoint = (phase: ContinuationCheckpoint["phase"], interactions: any[], count: number): ContinuationCheckpoint => ({
|
|
phase, issue: { id: "task", status: phase === "final" ? "done" : "in_review" }, children: [], attachments: [], comments: [],
|
|
interactions, runs: runs.slice(0, count),
|
|
documents: phase === "final" ? [{ key: "note", latestRevisionId: "saved", body: "Welcome to the afternoon meetup, AMBER123." }] : [],
|
|
});
|
|
return [checkpoint("initial", [first], 1), checkpoint("answered", [answeredFirst, second], 2), checkpoint("final", [structuredClone(answeredFirst), answeredSecond], 3)];
|
|
}
|
|
const failed = (checkpoints: ContinuationCheckpoint[]) => gradeQuestionDocumentation(checkpoints, "AMBER123").filter(c => !c.passed).map(c => c.id);
|
|
|
|
describe("question tool documentation regression", () => {
|
|
it("runs against both native providers with production instructions", () => {
|
|
const cells = runnerMatrix.filter(c => c.task.id === "question-tool-documentation");
|
|
expect(cells.map(c => c.profile.id).sort()).toEqual(["runner-acpx-claude", "runner-codex"]);
|
|
for (const c of cells) {
|
|
const prompt = c.task.buildPrompt("nonce");
|
|
expect(prompt).not.toMatch(/request_human_input|questionSet|selectionMode|payload\./);
|
|
expect(c.suite.manualOnly).not.toBe(true);
|
|
}
|
|
});
|
|
it("passes real choices followed by a text field and both recorded answers", () => {
|
|
expect(failed(recording())).toEqual([]);
|
|
});
|
|
it("rejects a lone choice", () => {
|
|
const r = recording();
|
|
(r[0].interactions[0] as any).payload.questionSet.questions[0].options.shift();
|
|
expect(failed(r)).toContain("meaningful-choice-form");
|
|
});
|
|
it("rejects a lone Other choice instead of a text field", () => {
|
|
const r = recording();
|
|
Object.assign((r[1].interactions[1] as any).payload.questionSet.questions[0], { answerMode: "single_select", options: [{ id: "other", label: "Other" }] });
|
|
expect(failed(r)).toContain("text-form-after-choice");
|
|
});
|
|
it("rejects asking both questions before the first answer", () => {
|
|
const r = recording();
|
|
r[0].interactions.push(structuredClone(r[1].interactions[1]));
|
|
expect(failed(r)).toContain("meaningful-choice-form");
|
|
});
|
|
it("rejects fabricated or duplicated responses", () => {
|
|
const r = recording();
|
|
(r[2].interactions[0] as any).result.answers[0].optionIds = ["am"];
|
|
expect(failed(r)).toContain("actual-question-answers");
|
|
r[2].interactions.push(structuredClone(r[2].interactions[1]));
|
|
expect(failed(r)).toContain("actual-question-answers");
|
|
});
|
|
it("rejects the old instruction block copied into a later turn", () => {
|
|
const r = recording();
|
|
(r[2].runs[2] as any).runnerProfileJson.nativeExecutionInput.task.prompt += "\n## Questions that need a user response\npayload.questionSet";
|
|
expect(failed(r)).toContain("question-guidance-not-in-wake");
|
|
});
|
|
it("requires recorded inputs rather than assuming docs-only delivery", () => {
|
|
const r = recording();
|
|
delete (r[2].runs[2] as any).runnerProfileJson;
|
|
expect(failed(r)).toContain("question-guidance-not-in-wake");
|
|
});
|
|
it("requires both real answers in the saved result", () => {
|
|
const r = recording();
|
|
r[2].documents[0].body = "Welcome AMBER123.";
|
|
expect(failed(r)).toContain("both-answers-in-output");
|
|
});
|
|
it.each(["Welcome to the afternoon meetup, AMBER1234.", "Welcome to the afternoon meetup, AMBER123_old."])(
|
|
"rejects a changed reference token in the saved result: %s", body => {
|
|
const r = recording();
|
|
r[2].documents[0].body = body;
|
|
expect(failed(r)).toContain("both-answers-in-output");
|
|
});
|
|
});
|