mirror of
https://github.com/bitbaum/causius.git
synced 2026-12-04 05:07:50 +01:00
fix(agent): two corrections, each answered by the next model
Agent check on 8639cc8: groq gpt-oss-20b computed the tax deadline,
was told to record it, and answered again without recording it; the
rent answer claimed '(recorded)' with nothing recorded. A model that
ignored the rule ignores its correction too. Every correction now moves
the serving link to the back of the chain, and a turn gets up to two.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Lem7GyhyyjKhmwjG8G7Ud
This commit is contained in:
4 files changed
+19
-15
No files matched your search
+1
-1
@@ -21,7 +21,7 @@ brackets, it is the pull request to read for the detail.
|
||||
it should have made written into the answer as text. Every answer is now
|
||||
checked: one that cites law without a source, describes calls instead of
|
||||
making them, or gives a deadline without recording it, is sent back once
|
||||
(a model that wrote its calls out hands the retry to the next model); if it still fails it is shown marked
|
||||
(up to twice, each time to the next model in the chain); if it still fails it is shown marked
|
||||
"unverified". {#no-unsourced-law}
|
||||
|
||||
## 2026-10-21
|
||||
|
||||
+14
-11
@@ -67,6 +67,8 @@ import { answerProblems, repairPrompt, withoutNarration } from "./answer-check";
|
||||
|
||||
const health = createHealthTracker();
|
||||
const MAX_ROUNDS = 6;
|
||||
/** Corrections per turn (answer-check.ts); each goes to the next model in the chain. */
|
||||
const MAX_CORRECTIONS = 2;
|
||||
const HISTORY = 30;
|
||||
const DOC_BUDGET = 24_000;
|
||||
|
||||
@@ -585,7 +587,7 @@ async function runTurnLocked(input: {
|
||||
const read = input.read ?? readPage;
|
||||
let servedBy = "";
|
||||
let finalText = "";
|
||||
let repaired = false;
|
||||
let corrections = 0;
|
||||
let unverified = false;
|
||||
let recorded = 0;
|
||||
let chain = models.chain;
|
||||
@@ -634,17 +636,18 @@ async function runTurnLocked(input: {
|
||||
sources: sources.length,
|
||||
deadlines: recorded + view.items.filter((i) => i.kind === "deadline").length,
|
||||
});
|
||||
if (problems.length && !repaired && round < MAX_ROUNDS - 2) {
|
||||
repaired = true;
|
||||
if (problems.length && corrections < MAX_CORRECTIONS && round < MAX_ROUNDS - 2) {
|
||||
corrections++;
|
||||
const narrated = problems.includes("narrated");
|
||||
if (narrated) {
|
||||
// Half the free chain cannot call tools natively. The model that just
|
||||
// wrote its calls out goes to the back for the rest of the turn, and
|
||||
// the correction alone carries the text protocol: in the system
|
||||
// prompt it made native callers switch to text and fail (run 5).
|
||||
const served = (l: Link) => `${l.provider.id}/${l.model}` === turn.id;
|
||||
chain = [...chain.filter((l) => !served(l)), ...chain.filter(served)];
|
||||
}
|
||||
// A model that ignored the rule tends to ignore its correction too
|
||||
// (Agent check, 2026-10-22: gpt-oss-20b computed the deadline, was
|
||||
// told to record it, and answered again without recording it). So
|
||||
// the serving link goes to the back and the next model takes the
|
||||
// correction. Only the correction for a narrated answer carries the
|
||||
// text protocol: in the system prompt it made native callers switch
|
||||
// to text and fail.
|
||||
const served = (l: Link) => `${l.provider.id}/${l.model}` === turn.id;
|
||||
chain = [...chain.filter((l) => !served(l)), ...chain.filter(served)];
|
||||
conversation.push(
|
||||
{ role: "assistant", content: turn.text },
|
||||
{
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
* 2026" correctly and never call record_deadline, so the
|
||||
* reminder the person relies on was never set
|
||||
*
|
||||
* The agent gets one precise correction per problem and tries again; an answer
|
||||
* still failing is stored with a visible "not checked against a source" step,
|
||||
* never silently.
|
||||
* The agent gets a precise correction (at most two per turn, each answered by
|
||||
* the next model in the chain) and tries again; an answer still failing is
|
||||
* stored with a visible "unverified" step, never silently.
|
||||
*/
|
||||
import { stripToolCallLines } from "@bitbaum/ai-kit";
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ describe.skipIf(!available)("a real model works a matter", () => {
|
||||
for (const i of view.items) console.log(`[agent] item ${i.kind} ${i.due} ${i.label}`);
|
||||
console.log(`[agent] answer ${answer && answer.kind === "message" ? answer.text.slice(0, 600).replace(/\n/g, " ") : "-"}`);
|
||||
const sent = seen.join("\n");
|
||||
console.log(`[agent] corrections ${seen.filter((b) => b.includes("Do not apologise or mention this message")).length ? "yes" : "none"}`);
|
||||
console.log(`[agent] model requests ${seen.length}; name sent: ${/Erika|Muster/.test(sent)}; served by ${outcome.ok ? outcome.servedBy : "-"}`);
|
||||
|
||||
expect(outcome.ok).toBe(true);
|
||||
|
||||
Reference in new issue
Block a user