Files
CatoandClaude Opus 5.5 6cf21ce9e7 feat(agent): read the law of all 26 cantons through LexFind (#44)
* feat(agent): read the law of all 26 cantons through LexFind

lib/law/lexfind.ts finds a cantonal act by abbreviation (StG), systematic
number (631.1) or title through LexFind's public API (Institute of
Federalism, University of Fribourg), reads the canton's official PDF
with unpdf, drops repeated page headers, rejoins hyphenated words and
cuts out one § or Art., stopping at the next heading but not at a
reference to it. The source link is the canton's own page.

read_law reads a non-federal act from the matter's canton, or from one
named with the new canton field. Checked live: ZH StG § 140, BE StG
Art. 187, VD LI Art. 1 (and LU, GE by hand).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Lem7GyhyyjKhmwjG8G7Ud

* fix(agent): a runaway reply runs 8 calls, a turn 12 law reads; point the agent at read_law

Agent check on d13d436: one model reply asked for read_law ~150 times and
the turn failed; in the tax case the model searched instead of reading
Zürich's StG and answered too late to be corrected.

- One reply runs at most 8 tool calls; the rest, and any exact repeat,
  are answered 'not run' so the model can ask again.
- Per turn: read_law 12, web_search 8, read_page 8 (with the writes).
- The Swiss and Liechtenstein market notes now tell the agent read_law
  reads federal, cantonal and Liechtenstein acts, with an example.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Lem7GyhyyjKhmwjG8G7Ud

* fix(agent): keep the turn's real answer when a correction ends in a call note

Agent check on 51ac8c7: the tax answer (a table with the deadline) was
flagged for narrating a call; two corrections later the last reply was
only '(called add_task)', so the person saw 'could not finish' although
the deadline was recorded. The turn now keeps its best real answer,
narration removed, and stores that when the last reply has nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Lem7GyhyyjKhmwjG8G7Ud

* 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

* fix(agent): a turn with no answer gets one rescue round, by another model

Agent check on 4126c2e: the agent now reads Zürich's StG, but the
tool-less last round was answered by a text-protocol model with a TOOL
line, so the person saw 'could not finish'. A turn that has produced no
real answer at all now gets one more round, past the limit if need be,
by the next model in the chain, told that tools are gone and to answer
in words from what they returned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Lem7GyhyyjKhmwjG8G7Ud

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-22 18:59:29 +02:00
..