Files
loki/scripts/test/plan-as-answer.ts
T
CatoandClaude Fable 5.1 b8aea45988 fix(loki): the Groq fallback answers, it does not narrate its plan (#709)
Asked "what projects do we have, name the three pillars" with the fleet map
in context, the fallback (openai/gpt-oss-20b at low effort, 1024 tokens)
replied "We need to answer: … We must cite each claim … Let's go through
each:" and spent the whole budget describing how it would answer. No
<think> tags, so stripReasoning let it through; grounding passed, because a
plan makes no claims. Probed on Groq directly: gpt-oss keeps its reasoning in
a separate field — this was the FINAL channel, the model thinking out loud
because low effort gave it nowhere else to.

- effort "medium" with a 2048-token budget, raised together as groq.ts
  documents, so the thinking happens in the hidden channel.
- looksLikePlan() (pure, tested on the verbatim leak) catches a reply that
  addresses the model instead of the operator; one retry with an answer-only
  instruction, after a stream reset so the plan does not stay on screen.


Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-14 04:38:53 -07:00

49 lines
2.0 KiB
TypeScript

/**
* The plan-as-answer detector (lib/loki/plan-as-answer.ts).
*
* The fixture is the verbatim opening of the 2026-09-14 reply: the Groq
* fallback narrated how it would answer and never answered. It must be caught;
* real answers — including ones that mention "we" — must not.
* Run: npx tsx scripts/test/plan-as-answer.ts
*/
import assert from "node:assert/strict";
import { looksLikePlan } from "@/lib/loki/plan-as-answer";
let pass = 0;
function check(name: string, fn: () => void) {
fn();
pass++;
console.log(` ✓ ${name}`);
}
const leak = `We need to answer: "What projects do we have, which are live, and what is each one for? Name the three pillars."
We must cite record IDs for each claim. The records include many projects (F2-F36). We need to list projects, which are live (status active?), and what each one for (description). Also name the three pillars (from fleet map: Pillar orangecat (economic layer), Pillar loki (capability layer), Pillar solon (governance layer)). Must cite record IDs for each claim.
We need to ensure we only use facts from records.`;
check("the 2026-09-14 leak is a plan", () => assert.equal(looksLikePlan(leak), true));
check("a plan spread over the opening paragraph is a plan", () =>
assert.equal(
looksLikePlan(
"The user asks for the pillars. We must cite F1. We should list them in order.\n- loki",
),
true,
),
);
check("a real answer is not a plan", () => {
assert.equal(
looksLikePlan(
"The three pillars are OrangeCat (economic layer) [F1], Loki (capability layer) [F1] and Solon (governance layer) [F1].\n\nLive: loki, orangecat, solon, datacat…",
),
false,
);
});
check("'we' in the operator's own voice is not a plan", () => {
assert.equal(looksLikePlan("We have 35 projects; 14 are live [F1]. We ship from Loki."), false);
assert.equal(looksLikePlan("Not in your data."), false);
assert.equal(looksLikePlan(""), false);
});
console.log(`\nplan-as-answer: ${pass} passed`);