Skip to content

Replace a reply that claims a record was created when every create failed (closes #3819) - #3829

Merged
malibio merged 3 commits into
mainfrom
issue-3819-reply-claims-guard
Oct 15, 2026
Merged

malibio merged 3 commits into
mainfrom
issue-3819-reply-claims-guard

Conversation

@malibio

@malibio malibio commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

What

The tool-failure surfacing guard passed any reply that contained an error word (error, fail, couldn't, unable), so a reply could name a failure and still claim the record it was asked for: "I couldn't assign it, but I have successfully created the question task" after create_node had refused.

Now, when a create tool (create_node, create_nodes_from_markdown, create_schema, create_question_task) failed unrecovered in the turn, no create landed, and the reply says a record was created, the reply is replaced by what failed (the same sentence the guard already writes).

  • A claim about a link ("I created a link from Anoop to…") is not a record claim.
  • A create that landed grounds the claim, whatever else failed ("I created it but couldn't assign it" is left as the model wrote it).
  • An honest failure account is left alone.

This is acceptance 3 of the issue.

Measured

  • 4 new unit tests in agent_loop.rs (false claim replaced though it names an error; landed create grounds the claim; link claim not a record claim; honest account untouched) and the existing failure-surfacing tests pass.
  • test:changed passes.

Not measured

  • No live E4B run for this change: the guard acts on the structure of a turn's tool results, not on model output, and the question-task path (the landed create_question_task) is untouched by it. The whole tasks suite was not re-run.
  • It does not catch a claim that overreaches a landed create (e.g. 'assigned to Anoop' when only the task was made). That needs the claim parsed against the specific links made, which this does not attempt.

closes #3819

🤖 Generated with Claude Code

@malibio

malibio commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

Verdict: COMMENT (initial review; no blockers, two improvements worth doing before merge). The mechanism is sound and well scoped: it reuses the existing surfacing block, the failure/landed predicates are the right ones, and byte handling is correct (to_ascii_lowercase preserves byte length; the match anchor "creat" and every split char are ASCII, so all slice offsets are char boundaries; the 40-byte window backs off to a boundary). The weak part is the link-word shield, which is a substring test over a window that starts at "creat", and it exempts the very sentence shape the issue is about.

Findings

Critical Issues

None.

Suggested Improvements

  • claims_a_record_was_created link shield (agent_loop.rs, LINK_WORDS / 40-byte window): false negatives on the target scenario.
    • "I have successfully created the question task and linked it to Anoop." The window from "creat" is created the question task and linked it (40 bytes), which contains "link", so it is judged a link claim and the false record claim is accepted. Same for "created a task mentioning Anoop" ("mention") and "created the task with a connection to ...".
    • contains is a substring match: "edge" matches "knowledge"/"acknowledge" ("I created a knowledge note"), "link" matches "linked/linking".
    • Suggest: match whole words, and shield only when the link word is the object of "creat…" (e.g. the next 1-3 tokens after "creat…" are [a|an|the|new]* link-word). A task name followed by "and linked" should still count as a record claim. A test for "created the question task and linked it to Anoop" with a failed create would pin it.
  • Same-turn partial failure with an earlier-turn or sibling record (false positive): "I created the first task earlier but couldn't create the second." After a failed create_node this turn and no landed create this turn, the reply is replaced although the claim is about a prior turn's record. all_tool_executions is per turn (declared in run_turn), so earlier-turn creations are invisible to the guard. Rare, and the replacement is still a truthful account of what failed, so I would accept it, but state it as a known limitation next to the "different record" one in the PR body.
  • Verbs other than "creat…": "I made the question task" / "I added the task" never enter claims_a_record_was_created (anchor is the substring "creat"), even though contains_action_claim lists them. The anchor is narrower than the guard's stated purpose ("says a record was created"). Either document it or anchor on the same verbs.
  • Negation in the passive branch: "No task was created." / "The task was not created" is protected only by the NEGATORS list (no node, not , nothing ); "No task was created." matches "was created" with no negator, so an honest sentence is judged a claim. Impact is bounded because the reply is replaced by the guard's own truthful failure sentence, but it is a false positive against an honest reply. Cheap fix: a " no " negator in the sentence, or pin it in a test.
  • creates_a_record (agent_loop.rs ~2943): a hand-written list of four tools duplicates knowledge held in the tool registry (is_write_call, created_record_lines, resolves_entities_tool are the neighbours). A fifth create-like tool will silently be missed. Prefer deriving it from the same source created_record_lines / claims_update_after_only_creating use, so the guards cannot drift.

Answers to the focus questions

  1. False positives: see above. Read-only turns cannot reach the block (needs a failed create). A failed create followed by a later successful create of the same tool is excluded from failed_tools, so a retry that landed is never replaced. A failed create_node followed by a landed create_nodes_from_markdown is covered by the landed-create check. Multi-sentence replies are judged per sentence, which is correct. Non-ASCII is safe.
  2. False negatives: "unrecovered" is correct, and the extra landed_write scan over all_tool_executions is not redundant: failed_tools only drops a failure followed by a later success of the same tool, whereas the grounding check covers a different create tool or an earlier success. A landed create_node for record B grounding a claim about failed record A is an acknowledged limitation; fine. Note the converse: a held (is_held_deletion) result is excluded by landed_write, fine for creates.
  3. Neighbours: ordering is fine. No-op and created-not-updated both fire only when a create landed or all writes were empty; the new condition requires no landed create, and NOTHING_SAVED_NOTICE / the created-not-updated notice contain none of the claim phrases, so there is no double replacement or self-trigger. The block's header comment ("appending would be contradictory") still reads correctly; the new comment is accurate. One wording nit: the warn! message says "not surfaced in model response" even when the reply did mention an error, but the new record_claim_is_false field disambiguates it.
  4. Tests: test 1 would fail on main (reply contains "couldn't", so it was passed through); good. Tests 2-4 are guards against over-correction and would pass on main, which is fine. The scripted executor is adequate. Gaps: no test for "created X and linked it", for a retry-recovered create, or for a later landed create_nodes_from_markdown grounding.
  5. AGENTS.md: no issue numbers in the new code comments (the closes #3819 is in the PR body, allowed), no literal node_type comparisons (Tool::from_name), no suppression, no compat code. Clean.
  6. PR body: honest; it says no live run and states the overreach limitation. Minor: "test:changed passes" and "the existing failure-surfacing tests pass" are unverifiable from the PR itself; fine as author statements. Add the link-shield and earlier-turn limitations.

Nitpicks

  • Nit: the 40 was chosen without a stated reason; name it (LINK_WINDOW_BYTES) and say why.
  • Nit: claims_a_record_was_created re-lowercases and rescans per "creat" occurrence; negligible but the sentence split already exists in contains_action_claim and could be shared.

@malibio

malibio commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed review.

Done:

  • Link shield exempted the target scenario: 'created the question task and linked it to Anoop' was judged a link claim. The claim is now read on the verb's object (the first noun after 'created/added/made'), so only 'created a link …' or 'the link was created' is shielded; a link mentioned later in the sentence is not. Test added for the exact shape.
  • Base form ('couldn't create the task') no longer counts as a claim: past forms only. This was a regression of my own in the first rewrite, caught by the existing link test.
  • 'No task was created.': a ' no ' / ' nothing ' sentence is not a claim (test added; its reply names a failure so the older branch does not apply).
  • Anchors now include 'added' and 'made', not only 'created'.
  • Registry-derived: Tool::makes_a_record is an exhaustive match in tools.rs, so a new tool has to be classified.
  • Tests added: link mentioned after the claim (replaced), no-record statement (left alone), a create retried into success (grounds the claim).

Limitation, recorded in the doc comment: results are the turn's, so a reply describing an earlier turn's record in a turn whose own create failed is read as a claim about this turn. The replacement is still truthful.

Not done: a test for a landed create_nodes_from_markdown grounding the claim (the registry predicate covers it; no scripted tool for it).

RE-REVIEW NEEDED: the claim detector was reworked, not just reworded.

@malibio

malibio commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

Re-review (commit 1c114bb)

Verdict: COMMENT. The five prior items are addressed and the design (read the verb's object, derive record tools from the registry) is right. No blockers. Two real holes in the new code worth fixing before merge, both cheap.

Verified

  • Slicing is safe: to_ascii_lowercase preserves byte length, every match_indices hit and every split char is ASCII, so lower[..at], lower[at..] and the sentence slices are on char boundaries. The old 40-byte window and its boundary back-off are gone.
  • Tool::makes_a_record is an exhaustive match (no _), classification is right: CreateNode, CreateNodesFromMarkdown, CreateSchema, CreateQuestionTask true; links/updates/deletes false. The removes_user_data doc block is intact and still directly above its fn.
  • Wider verbs: the guard still requires an unrecovered failed create AND no landed create in the turn AND a sentence passing contains_action_claim, so "made"/"added" matter only in the failed-create turn, where the replacement is the truthful failure text. Widening is justified: "I made the question task" is the same false claim. Cost is only false positives, bounded to that turn.

Suggested Improvements

  • \" no \" negator is sentence-wide and produces a false negative on the target shape: "I created the question task with no assignee yet." / "I created the task, no due date." contains no, so it is judged not a claim and the false record claim passes. Negation should scope to the claim: only when no/nothing/not precedes the verb in the sentence (lower[sentence_start..at]), which is what "No task was created" needs. Add a test for "created the question task with no assignee".
  • Passive shield misses "has/have been": for "The link has been created" the token before been is has, so the subject test never sees link; the sentence is judged a record claim and an honest reply is replaced. Look at the last non-auxiliary token before the verb (skip was/were/been/has/have/had/is/are) instead of fixed [.., subject, was|were|been].
  • Verb matching is substring, not word: recreated, padded, homemade, remade match. Only reachable when the sentence also has an action phrase, so rare ("I found the task was recreated earlier"). Require the match to start at a word boundary and end on a non-alphabetic (or check the token from split_whitespace after trimming punctuation).
  • made objects: "I made sure ...", "I made a note that ..." are read as record claims (object "sure"/"note" is not a link word). Honest-reply replacement in a failed-create turn only; acceptable, but an object stoplist ("sure", "note", "it", "progress") would remove the obvious ones. Also an object that is a link word shields "I created the link and the task" (false negative; accepted, rare).

Tests

  • a_record_claim_that_also_mentions_a_link... pins the issue scenario well (failed create, landed link, claim replaced).
  • a_statement_that_no_record_was_created... is meaningful: without the negator the reply would be replaced.
  • a_create_retried_into_success_grounds_the_claim is weak for the new code: the recovered failure leaves failed_tools empty, so claims_a_record_was_created is never reached (and the reply says "couldn't", so it passes the old path too). It pins the grounding/recovery, not the claim parser. Fine to keep, but the parser has no direct unit tests: add a small table test on claims_a_record_was_created covering made/added, passive link ("the link was created"/"has been created"), with no assignee, verb-last-word, and non-ASCII text.

AGENTS.md

No violations seen: no compatibility code, no node-type literals, no lifecycle reads, logging uses tracing. Nit: OBJECT_WORDS doc is fine.

@malibio

malibio commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed re-review.

Done:

  • Negation only counts before the verb: 'created the question task with no assignee yet' is a claim again; 'No task was created' is not.
  • Passive behind auxiliaries: 'the link has been created' reads its subject past has/have/had/been/was/…, so it is shielded.
  • Whole-word verbs: 'recreated', 'homemade', 'padded' no longer match.
  • Table test for the detector itself (8 claims incl. non-ASCII and 10 non-claims), which also stands in for the retry test's gap noted by the reviewer.

Left as is: 'I made sure …' / 'I made a note …' read as claims. Bounded to a turn where a create failed and none landed, where the replacement is the truthful failure text; an object stoplist would be guesswork. 'I created the link and the task' is shielded by its first object (rare false negative), noted.

All changes are in the detector and pinned by the new table test; test:changed passes. NO RE-REVIEW NEEDED.

malibio and others added 3 commits October 15, 2026 23:37
…iled (refs #3819)

The tool-failure surfacing guard let a reply through whenever it named an
error, so 'I couldn't assign it, but I have successfully created the question
task' reached the user after create_node had refused. When a create failed and
none landed in the turn, a claim that a record was made is replaced by what
failed. A claim about a link is not a record claim, and a landed create
grounds the claim as before.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…; passive subjects; registry-derived record tools (refs #3819)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…liaries, whole-word verbs, table test (refs #3819)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@malibio
malibio force-pushed the issue-3819-reply-claims-guard branch from 3a83954 to b15a64c Compare October 15, 2026 21:37
@malibio
malibio merged commit cd70579 into main Oct 15, 2026
@malibio
malibio deleted the issue-3819-reply-claims-guard branch October 15, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local agent links the stopped task instead of creating the question task

1 participant