Skip to content

Keep the procedure lane on a lookup that names a change (refs #3784) - #3821

Merged
malibio merged 3 commits into
mainfrom
issue-3784-task-routing
Oct 15, 2026
Merged

malibio merged 3 commits into
mainfrom
issue-3784-task-routing

Conversation

@malibio

@malibio malibio commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

What

read_only_candidates takes a flag: when the user's own message names a change (asks_for_a_change, built on the existing closed asks_for_a_write list, now with answer/answered), the lane's procedure is kept on a lookup turn. The tool skills are narrowed as before.

Measured (E4B, isolated daemon, DB purged between reps, --runs 3)

Tried and not kept

  • Rewording Creating a Task / Addressing Review Findings (use_for, not_for): moved scores by under 0.03 and lowered Creating a Task on its own prompt. Reverted.
  • Procedure lane of up to 3 within 0.03 of the best: same eval:tasks aggregate (2.67/6), longer prompts and several turns at the 180s limit. Reverted.

Findings per hop are on the issue; #3784 stays open for the remaining scenarios.

🤖 Generated with Claude Code

@malibio

malibio commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

Review: PR #3821 (issue #3784, lookup keeps the procedure lane)

Verdict: COMMENT (no blockers; two findings worth a decision before merge).

Findings

🟡 packages/agent/src/local_agent/routing.rs:452-453 (answer/answered in WRITING): false positives on read questions. The list is read by is_lookup_shaped's question-word branch (line 346), lookup_without_stage1 (line 543) and decision_for_an_offered_option (line 581), not only by the new flag. "What did Anoop answer?" or "Which questions have been answered?" now (a) skips the no-Stage-1 lookup shortcut and pays a Stage 1 call, (b) loses the question-word lookup shape when there is no ?, and (c) once Stage 1 does call it a lookup, asks_for_a_change is true and the write-tool procedure (Answering a Question) is kept on what is a pure read. answer is both noun and verb, unlike the other words in the list. Suggest either a narrower trigger (answer only as a verb: after "get"/"have"/"it", or adjacent to "it"/"them"), or accepting it knowingly and adding negative tests for these phrasings in lookup_without_stage1 and is_lookup_shaped. The existing doc says a miss costs little, but a false positive here costs routing of a read.

🟡 routing.rs:1588 (read_only_candidates): the new branch sits before the pinned branch and returns the candidate with its write tools intact. A pinned Procedure on a lookup that names a change previously had its write tools stripped (ADR-090 §5, "a turn that only reads cannot write through it"); now it keeps them. Also the kept procedure's write tools reach Stage 2 unfiltered on a turn Stage 1 called a lookup, so any destructive tool in its whitelist is exposed on the strength of one word match. Consider ordering the check after the pinned case or stripping destructive tools, and state in the doc comment which is intended. No test covers pinned + asked_for_a_change = true.

🟢 routing.rs:1597: a kept procedure that clears the gate now makes read_only.iter().any(clears_score_gate) true, so the "nothing read-only clears the gate, keep what was retrieved" fallback no longer fires when only the procedure clears. Probably fine, but untested: add a case with a non-clearing read skill plus a clearing procedure.

🟢 Tests: asks_for_a_change is tested on two sentences only. Missing: "then"-style false positives on lookups ("find X, then show Y" was already a write), answer as a noun, and the agent_loop wiring (flag passed from the user message, not the blended query). The read_only_candidates unit test is good.

🟢 Standards: no lint suppression, no compat code, no node_type or lifecycle literals; WRITING length bumped to 39 correctly. asks_for_a_change duplicates the word-splitting block already repeated at lines 536-541 and 575-580; a small words_of(message) helper would remove three copies (Nit).

Nit: routing.rs:1565-1569: the doc comment embeds measured scores (1.07 vs 0.87) that go stale when skills or the embedding model change, and the user's eval sentence. State the mechanism and point to the issue for the numbers.

Requirements check

Fixes the lookup-path hop recorded on #3784 (answer-asks-user 0/3 to 3/3); explicitly leaves the other scenarios open, matching the issue's hop table. Scope is atomic.

Recommendation: COMMENT

Safe enough to land as a partial fix; address or consciously accept the answer/answered blast radius and the pinned-procedure write-tool exposure first.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: PR #3821 (issue #3784, lookup keeps the procedure lane)

Verdict: COMMENT (no blockers; two findings worth a decision before merge).

Findings

🟡 packages/agent/src/local_agent/routing.rs:452-453 (answer/answered in WRITING): false positives on read questions. The list is read by is_lookup_shaped's question-word branch (line 346), lookup_without_stage1 (line 543) and decision_for_an_offered_option (line 581), not only by the new flag. "What did Anoop answer?" or "Which questions have been answered?" now (a) skips the no-Stage-1 lookup shortcut and pays a Stage 1 call, (b) loses the question-word lookup shape when there is no ?, and (c) once Stage 1 does call it a lookup, asks_for_a_change is true and the write-tool procedure (Answering a Question) is kept on what is a pure read. answer is both noun and verb, unlike the other words in the list. Suggest either a narrower trigger (answer only as a verb: after "get"/"have"/"it", or adjacent to "it"/"them"), or accepting it knowingly and adding negative tests for these phrasings in lookup_without_stage1 and is_lookup_shaped. The existing doc says a miss costs little, but a false positive here costs routing of a read.

🟡 routing.rs:1588 (read_only_candidates): the new branch sits before the pinned branch and returns the candidate with its write tools intact. A pinned Procedure on a lookup that names a change previously had its write tools stripped (ADR-090 §5, "a turn that only reads cannot write through it"); now it keeps them. Also the kept procedure's write tools reach Stage 2 unfiltered on a turn Stage 1 called a lookup, so any destructive tool in its whitelist is exposed on the strength of one word match. Consider ordering the check after the pinned case or stripping destructive tools, and state in the doc comment which is intended. No test covers pinned + asked_for_a_change = true.

🟢 routing.rs:1597: a kept procedure that clears the gate now makes read_only.iter().any(clears_score_gate) true, so the "nothing read-only clears the gate, keep what was retrieved" fallback no longer fires when only the procedure clears. Probably fine, but untested: add a case with a non-clearing read skill plus a clearing procedure.

🟢 Tests: asks_for_a_change is tested on two sentences only. Missing: "then"-style false positives on lookups ("find X, then show Y" was already a write), answer as a noun, and the agent_loop wiring (flag passed from the user message, not the blended query). The read_only_candidates unit test is good.

🟢 Standards: no lint suppression, no compat code, no node_type or lifecycle literals; WRITING length bumped to 39 correctly. asks_for_a_change duplicates the word-splitting block already repeated at lines 536-541 and 575-580; a small words_of(message) helper would remove three copies (Nit).

Nit: routing.rs:1565-1569: the doc comment embeds measured scores (1.07 vs 0.87) that go stale when skills or the embedding model change, and the user's eval sentence. State the mechanism and point to the issue for the numbers.

Requirements check

Fixes the lookup-path hop recorded on #3784 (answer-asks-user 0/3 to 3/3); explicitly leaves the other scenarios open, matching the issue's hop table. Scope is atomic.

Recommendation: COMMENT

Safe enough to land as a partial fix; address or consciously accept the answer/answered blast radius and the pinned-procedure write-tool exposure first.

@malibio

malibio commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the review (commit on the branch):

  • ✅ 🟡 answer/answered blast radius: removed from the shared WRITING list. asks_for_a_change now adds a narrow check (a leading command answer …, after please/could you, or get it answered), so is_lookup_shaped, lookup_without_stage1 and decision_for_an_offered_option read exactly what they read before. Negative tests: "What did Anoop answer?", "Which questions have been answered?", "Show me the answer to …".
  • ✅ 🟡 Pinned procedure: the pinned rule now runs first, so a pinned procedure still loses its write tools on a lookup (ADR-090 §5). Test added for pinned + flag.
  • ✅ 🟢 Fallback: documented and tested that a clearing procedure beside a non-clearing read skill narrows to those two when a change is named, and keeps the retrieved set when none is.
  • ✅ 🟢 Doc comment states the mechanism; the measured scores are on The local agent does not follow the task procedures (eval:tasks fails 4 of 5 scenarios) #3784.
  • ⏭️ Nit: shared words_of helper. Two other copies sit in lookup_without_stage1 and the option path with different borrows of the lowered string; touching them is outside this fix. Revisit if a fourth appears.
  • ⏭️ Wiring test that the flag reads user_message: the call site is one expression in agent_loop; covered by the eval (answer-asks-user, 3/3) rather than a stubbed turn.

bun run test:changed passes. The eval sentence still names a change ("get it answered"), so the measured behaviour is unchanged; it was not re-run.

@malibio

malibio commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

Re-review: PR #3821 (commits 04f84db..efafe7b)

Verdict: APPROVE (no blockers; one small false-positive worth a follow-up in this PR if cheap).

Earlier findings

  • answer/answered blast radius: addressed. WRITING is back to its original list, so is_lookup_shaped, lookup_without_stage1 and decision_for_an_offered_option read exactly what they did before. The new check lives only in asks_for_a_change. Negative tests cover the noun phrasings.
  • Pinned procedure: addressed. The pinned branch now runs first and strips write tools; the new test asserts ["run_query"] with the flag true. An unpinned procedure keeps its tools only when the flag is set and role == Procedure.
  • Fallback: addressed and tested (clearing procedure + non-clearing read skill, flag true and false). The behaviour is reasonable: with a change named, the lookup narrows to read skills plus the procedure, and the clearing procedure satisfies the gate. Side effect worth knowing: a high-scoring write tool skill (Node Deletion 0.99) is dropped in favour of a 0.01 read skill. That is the intended read-only narrowing, not a regression.
  • Doc comment: addressed (mechanism stated, numbers moved to the issue).

New findings

🟡 packages/agent/src/local_agent/routing.rs (asks_for_a_change, get/got ... answered): the "got" arm false-positives on realistic reads: "What questions got answered yesterday?", "Get all answered questions", "Get the answered questions". Each has get/got followed within 3 words by answered. The effect is mild (an unpinned write-tool procedure is kept on a lookup), but it re-opens the exact class the earlier finding closed. Suggest requiring the object pronoun: get|got|have + (it|them|this|that) then answered, and drop got or require it. Add "What questions got answered?" and "Get the answered questions" to answer_as_a_noun_or_a_read_names_no_change.
🟢 False negatives: "Find the question and answer it", "I need to answer Anoop's question" are missed because only a leading answer counts. Consistent with the documented "a miss is cheap" stance; acceptable.
🟢 split_request_opening is private and the new public fn is reached only via the one call site; fine.

Nits you skipped

  • words_of helper: agree, defer; now four copies is the point to extract (this one plus the two existing ones plus is_lookup_shaped callers), so do it with the next touch.
  • Wiring test for user_message: agree. One expression at the call site; low value. Note the flag reads the raw user message, not the blended query, which is correct.

Recommendation: APPROVE

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review: PR #3821 (commits 04f84db..efafe7b)

Verdict: APPROVE (no blockers; one small false-positive worth a follow-up in this PR if cheap).

Earlier findings

  • answer/answered blast radius: addressed. WRITING is back to its original list, so is_lookup_shaped, lookup_without_stage1 and decision_for_an_offered_option read exactly what they did before. The new check lives only in asks_for_a_change. Negative tests cover the noun phrasings.
  • Pinned procedure: addressed. The pinned branch now runs first and strips write tools; the new test asserts ["run_query"] with the flag true. An unpinned procedure keeps its tools only when the flag is set and role == Procedure.
  • Fallback: addressed and tested (clearing procedure + non-clearing read skill, flag true and false). The behaviour is reasonable: with a change named, the lookup narrows to read skills plus the procedure, and the clearing procedure satisfies the gate. Side effect worth knowing: a high-scoring write tool skill (Node Deletion 0.99) is dropped in favour of a 0.01 read skill. That is the intended read-only narrowing, not a regression.
  • Doc comment: addressed (mechanism stated, numbers moved to the issue).

New findings

🟡 packages/agent/src/local_agent/routing.rs (asks_for_a_change, get/got ... answered): the "got" arm false-positives on realistic reads: "What questions got answered yesterday?", "Get all answered questions", "Get the answered questions". Each has get/got followed within 3 words by answered. The effect is mild (an unpinned write-tool procedure is kept on a lookup), but it re-opens the exact class the earlier finding closed. Suggest requiring the object pronoun: get|got|have + (it|them|this|that) then answered, and drop got or require it. Add "What questions got answered?" and "Get the answered questions" to answer_as_a_noun_or_a_read_names_no_change.
🟢 False negatives: "Find the question and answer it", "I need to answer Anoop's question" are missed because only a leading answer counts. Consistent with the documented "a miss is cheap" stance; acceptable.
🟢 split_request_opening is private and the new public fn is reached only via the one call site; fine.

Nits you skipped

  • words_of helper: agree, defer; now four copies is the point to extract (this one plus the two existing ones plus is_lookup_shaped callers), so do it with the next touch.
  • Wiring test for user_message: agree. One expression at the call site; low value. Note the flag reads the raw user message, not the blended query, which is correct.

Recommendation: APPROVE

@malibio

malibio commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the re-review (one commit):

  • ✅ 🟡 get/got … answered false positives: the arm now needs an object pronoun (it/them/this/that) right after get/got, then answered within two words. Added "What questions got answered yesterday?", "Get all answered questions", "Get the answered questions" to the negative test.
  • ⏭️ 🟢 False negatives ("Find the question and answer it"): left, per the documented stance that a miss costs a narrowed turn, and the next message routes on its own.
  • ⏭️ Nits (words_of, wiring test): reviewer agreed with the skips.

routing tests: 152 passed; quality:fix clean.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: the reviewer recommended APPROVE; the only change since is the one tightening the reviewer asked for, a single added condition with tests, no new behaviour. The eval sentence ("get it answered") still matches.

malibio and others added 3 commits October 15, 2026 10:11
A lookup narrows to read-only skills, which dropped the lane's procedure even
when the user's own message asked for a change: 'take the question that is
waiting on me and get it answered' ranked Answering a Question first (1.07
against 0.87) and the model never saw it. A message that names a change now
keeps the lane's procedure; the tool skills are still narrowed.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…write tools off (refs #3784)

- 'answer'/'answered' leave the shared write-verb list (they are nouns in
  reads); asks_for_a_change recognises a command to answer or 'get it
  answered' on its own, so no question shape changes.
- A pinned procedure is handled by the pinned rule before the new one, so it
  still loses its write tools on a lookup (ADR-090 section 5).
- Tests: pinned + flag, a clearing procedure beside a non-clearing read skill,
  noun uses of 'answer'.
- Doc comment states the mechanism and drops the measured scores.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
'got answered' and 'get the answered questions' are reads. The arm now needs
get/got + it/them/this/that before 'answered'.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@malibio
malibio force-pushed the issue-3784-task-routing branch from 1fed426 to c5d5a7a Compare October 15, 2026 08:11
@malibio
malibio merged commit 1046b70 into main Oct 15, 2026
@malibio
malibio deleted the issue-3784-task-routing branch October 15, 2026 08:11
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.

1 participant