mirror of
https://github.com/bitbaum/causius.git
synced 2026-12-04 05:07:50 +01:00
fix(agent): a turn never ends with nothing; cantonal letters mean the canton's act
Agent check on 2a4221e: the tax turn's only reply came in round 6, too
late for a correction, and was just '(called note_fact)'; the deadline
was recorded but the person saw 'could not finish'. Such a turn now gets
one more round without tools, to answer in words.
The model also never read Zürich's StG: the matter's canton was set
mid-turn, after the jurisdiction note was written. The system prompt now
says a cantonal authority's letter rests on the canton's own act, to be
read with read_law.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Lem7GyhyyjKhmwjG8G7Ud
This commit is contained in:
2 files changed
+29
-1
No files matched your search
@@ -345,3 +345,20 @@ describe("an answer lost to its correction", () => {
|
||||
expect(answer && answer.kind === "message" ? answer.text : "").toContain("Your objection is due 4 November 2026");
|
||||
});
|
||||
});
|
||||
|
||||
describe("a turn that would end with nothing", () => {
|
||||
it("gets one more round, without tools, to answer in words", async () => {
|
||||
const id = await matter();
|
||||
const model = scriptedModel([
|
||||
...Array.from({ length: 6 }, () => ({ tools: [["note_fact", { fact: "x" }]] as [string, unknown][] })),
|
||||
{ text: "(called note_fact)" },
|
||||
{ text: "Your deadline is recorded: 4 November 2026." },
|
||||
]);
|
||||
await runTurn({ db, master: MASTER, matterId: id, sub: OWNER, env: ENV, fetchImpl: model.impl, text: "When?" });
|
||||
const view = (await loadMatter(db, MASTER, id, OWNER))!;
|
||||
const answer = view.events.filter((e) => e.kind === "message" && e.role === "assistant").at(-1);
|
||||
expect(answer && answer.kind === "message" ? answer.text : "").toContain("4 November 2026");
|
||||
expect(model.seen.at(-1)).toContain("Answer the person now, without calling more tools.");
|
||||
expect(model.seen.at(-1)).not.toContain('"tools"');
|
||||
});
|
||||
});
|
||||
+12
-1
@@ -88,6 +88,7 @@ How you work:
|
||||
- Be concrete and practical. Say what the person should do, in what order, by when.
|
||||
- Ground statements of law in sources. For Swiss federal, cantonal and Liechtenstein law, read the provision itself with read_law (act "OR", article "270b") before you state it: it returns the official text in force today with its [n]. Use web_search and read_page for cantonal law, decisions and official guidance, and cite them as [n] using the numbers given in the results. Every sentence that states a rule of law ends with its [n]; a rule you could not find a source for is marked as unverified. Prefer the official text (the statute, the authority's own page) over commentary. Never invent a statute, article, decision or deadline, and do not overstate how widely a rule applies. If you are unsure, say so and say how to find out.
|
||||
- Distinguish levels of law (national, and regional where regions make their own law). The notes on this matter's jurisdiction, if any, say what applies there.
|
||||
- A letter from a cantonal authority (a cantonal tax office, a cantonal migration office) rests on the canton's own act: read it with read_law (canton and act, e.g. canton ZH, act StG), not only the federal one.
|
||||
- Record every deadline you find or compute with record_deadline, quoting the text it comes from. If a deadline depends on a rule (e.g. "30 days from notification"), say which rule and what you assumed.
|
||||
- In your first turn on a new matter, call update_matter to give it a clear title, its area of law and its jurisdiction code. Record important facts with note_fact.
|
||||
- Write documents (letters, submissions, contracts, objections) with draft_document, complete and ready to use, with [square-bracket placeholders] only for facts you do not have.
|
||||
@@ -638,6 +639,9 @@ async function runTurnLocked(input: {
|
||||
let servedBy = "";
|
||||
let finalText = "";
|
||||
let bestAnswer = "";
|
||||
// Set when a turn would otherwise end with nothing to show: one more round,
|
||||
// without tools, to answer in words.
|
||||
let mustAnswer = false;
|
||||
let corrections = 0;
|
||||
let unverified = false;
|
||||
let recorded = 0;
|
||||
@@ -650,7 +654,7 @@ async function runTurnLocked(input: {
|
||||
let jurisdiction = view.jurisdiction;
|
||||
|
||||
for (let round = 0; round < MAX_ROUNDS; round++) {
|
||||
const last = round === MAX_ROUNDS - 1;
|
||||
const last = round === MAX_ROUNDS - 1 || mustAnswer;
|
||||
let turn;
|
||||
try {
|
||||
turn = await complete({
|
||||
@@ -724,6 +728,13 @@ async function runTurnLocked(input: {
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (!substance && !bestAnswer && !last && round < MAX_ROUNDS - 1) {
|
||||
// Agent check, 2026-10-22: the only reply was "(called note_fact)",
|
||||
// too late in the turn for a correction; the person saw nothing.
|
||||
mustAnswer = true;
|
||||
conversation.push({ role: "assistant", content: turn.text });
|
||||
continue;
|
||||
}
|
||||
unverified = problems.includes("unsourced") || problems.includes("narrated");
|
||||
finalText = problems.includes("narrated") ? substance || bestAnswer : turn.text;
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user