mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 01:39:51 +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>
71 lines
4.0 KiB
TypeScript
71 lines
4.0 KiB
TypeScript
import type { ContinuationCheckpoint } from "./continuation-scoring.js";
|
|
import { includesSubmittedReference } from "./submitted-reference.js";
|
|
|
|
type Row = Record<string, any>;
|
|
const questions = (checkpoint?: ContinuationCheckpoint): Row[] =>
|
|
(checkpoint?.interactions ?? []).filter((value: any) => value.kind === "ask_user_questions") as Row[];
|
|
function form(row?: Row) {
|
|
const payload = row?.payload;
|
|
const canonical = payload?.questionSet?.questions;
|
|
if (canonical) return canonical;
|
|
return (payload?.questions ?? []).map((q: Row) => ({
|
|
...q, answerMode: q.selectionMode === "multi" ? "multi_select" : "single_select",
|
|
}));
|
|
}
|
|
|
|
/** Checks real recorded forms, responses, and native task inputs; no model judge. */
|
|
export function gradeQuestionDocumentation(checkpoints: ContinuationCheckpoint[], marker: string) {
|
|
const initial = checkpoints.find(c => c.phase === "initial");
|
|
const middle = checkpoints.find(c => c.phase === "answered");
|
|
const final = checkpoints.find(c => c.phase === "final");
|
|
const first = questions(initial)[0];
|
|
const next = questions(middle).filter(q => q.status === "pending");
|
|
const choice = form(first)[0];
|
|
const text = form(next[0])[0];
|
|
const options: Row[] = choice?.options ?? [];
|
|
const afternoon = options.find(o => /^afternoon\b/i.test(String(o.label).trim()));
|
|
const firstAnswer = questions(final).find(q => q.id === first?.id);
|
|
const secondAnswer = questions(final).find(q => q.id === next[0]?.id);
|
|
const inputs = (final?.runs ?? []).map((run: any) => run.runnerProfileJson?.nativeExecutionInput?.task?.prompt);
|
|
const checks = [
|
|
{
|
|
id: "meaningful-choice-form",
|
|
passed: questions(initial).length === 1 && first?.status === "pending" && form(first).length === 1
|
|
&& choice?.answerMode === "single_select" && options.length >= 2
|
|
&& new Set(options.map(o => o.id)).size === options.length
|
|
&& options.some(o => /^morning\b/i.test(String(o.label).trim())) && Boolean(afternoon),
|
|
detail: "The first card must show one single-choice question with distinct Morning and Afternoon options.",
|
|
},
|
|
{
|
|
id: "text-form-after-choice",
|
|
passed: questions(middle).length === 2 && next.length === 1 && form(next[0]).length === 1
|
|
&& next[0]?.id !== first?.id && text?.answerMode === "text"
|
|
&& !text?.options?.length && !text?.customAnswer
|
|
&& questions(middle).some(q => q.id === first?.id && q.status === "answered"),
|
|
detail: "Only after the choice is answered may the second, text-only question appear.",
|
|
},
|
|
{
|
|
id: "actual-question-answers",
|
|
passed: questions(final).length === 2 && firstAnswer?.status === "answered" && secondAnswer?.status === "answered"
|
|
&& firstAnswer?.result?.answers?.some((a: Row) => a.questionId === choice?.id && a.optionIds?.includes(afternoon?.id))
|
|
&& secondAnswer?.result?.answers?.some((a: Row) => a.questionId === text?.id && a.otherText?.includes(marker)),
|
|
detail: "Both real UI submissions must be persisted against their original question IDs, with no duplicate question cards.",
|
|
},
|
|
{
|
|
id: "question-guidance-not-in-wake",
|
|
passed: inputs.length >= 3 && inputs.every(prompt => typeof prompt === "string"
|
|
&& prompt.includes("Use Paperclip's request_human_input for durable task questions.")
|
|
&& !prompt.includes("## Questions that need a user response")
|
|
&& !prompt.includes("payload.questionSet")
|
|
&& !prompt.includes("Create a durable human question or approval card on the current Paperclip task bound to this run")),
|
|
detail: "Every recorded native turn must retain the short routing hint without the old question block or copied tool-format instructions.",
|
|
},
|
|
{
|
|
id: "both-answers-in-output",
|
|
passed: Boolean(final?.documents.some(d => d.key !== "plan" && includesSubmittedReference(d.body, marker) && /\bafternoon\b/i.test(d.body))),
|
|
detail: "The saved note must use both the selected time and the literal reference supplied in the text answer.",
|
|
},
|
|
];
|
|
return checks.map(check => ({ ...check, passed: Boolean(check.passed) }));
|
|
}
|