mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 02:26:12 +02:00
test(grok): reject reasoning projected as task replies
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
768d4e7755
commit
766369c68f
3 files changed
+37
-1
No files matched your search
@@ -81,6 +81,19 @@ function record(value: unknown): Record<string, unknown> {
|
||||
: {};
|
||||
}
|
||||
|
||||
export function reasoningProjectionFailures(events: readonly ObservableRunEvent[]): string[] {
|
||||
const misclassified = events.filter((event) => {
|
||||
const envelope = record(record(event.payload).prpEvent);
|
||||
const payload = record(envelope.payload);
|
||||
return envelope.eventType === "item.delta" &&
|
||||
payload.kind === "agentMessage" &&
|
||||
record(payload.update).kind === "reasoning";
|
||||
});
|
||||
return misclassified.length === 0 ? [] : [
|
||||
`provider reasoning was projected as assistant text in ${misclassified.length} durable events`,
|
||||
];
|
||||
}
|
||||
|
||||
export function isNonExecutingReviewFenceRun(run: ObservableRunState) {
|
||||
return (
|
||||
run.status === "cancelled" &&
|
||||
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
isOpenRouterDeepSeekHelloTerminalVariance,
|
||||
numberedPlanStepCount,
|
||||
providerSessionContinuityFailures,
|
||||
reasoningProjectionFailures,
|
||||
} from "./run-observations.js";
|
||||
import { resolveRunnerE2ESource } from "./source.js";
|
||||
import { isValidNativePrpEnvelope } from "./native-event-envelope.js";
|
||||
@@ -1732,7 +1733,9 @@ for (const execution of executions) {
|
||||
const pendingInteractions = terminal.interactions.filter(
|
||||
(interaction) => interaction.status === "pending",
|
||||
);
|
||||
const invariantFailures: string[] = [];
|
||||
const invariantFailures: string[] = reasoningProjectionFailures(
|
||||
runEventsByRun.flatMap((entry) => entry.events),
|
||||
);
|
||||
if (pendingInteractions.length > 0)
|
||||
invariantFailures.push(
|
||||
`expected no unresolved interaction; observed ${pendingInteractions.length}`,
|
||||
|
||||
@@ -44,10 +44,30 @@ import {
|
||||
isOpenRouterDeepSeekHelloTerminalVariance,
|
||||
numberedPlanStepCount,
|
||||
providerSessionContinuityFailures,
|
||||
reasoningProjectionFailures,
|
||||
} from "./run-observations.js";
|
||||
import { runnerE2EWebServerCommand } from "./web-server-command.js";
|
||||
|
||||
const cleanupDirectories: string[] = [];
|
||||
|
||||
it("rejects reasoning mislabeled as assistant text without echoing private content", () => {
|
||||
const reasoning = {
|
||||
eventType: "item.delta",
|
||||
payload: { prpEvent: {
|
||||
eventType: "item.delta",
|
||||
payload: { kind: "agentMessage", text: "PRIVATE_THOUGHT", update: { kind: "reasoning" } },
|
||||
} },
|
||||
};
|
||||
expect(reasoningProjectionFailures([reasoning])).toEqual([
|
||||
"provider reasoning was projected as assistant text in 1 durable events",
|
||||
]);
|
||||
const correctlyTyped = structuredClone(reasoning);
|
||||
correctlyTyped.payload.prpEvent.payload.kind = "reasoning";
|
||||
expect(reasoningProjectionFailures([correctlyTyped])).toEqual([]);
|
||||
const assistant = structuredClone(reasoning);
|
||||
assistant.payload.prpEvent.payload.update.kind = "agentMessage";
|
||||
expect(reasoningProjectionFailures([assistant])).toEqual([]);
|
||||
});
|
||||
afterEach(async () => {
|
||||
vi.unstubAllEnvs();
|
||||
vi.unstubAllGlobals();
|
||||
|
||||
Reference in new issue
Block a user