Repository navigation
Humanize tool names in agent fallback responses (#1092) - #1127
Conversation
When the model fails to produce text alongside tool calls — either at max iterations or after a final tool round — the agent loop synthesizes a fallback message so the chat UI never goes blank. Previously these messages embedded raw internal identifiers like `create_schema` and `update_node`, surfacing implementation detail to end users. Map known tool names to user-facing phrases (e.g. "schema creation", "node update") and route unknowns through a generic "the requested action" so no raw identifier can leak. The max-iterations branch also deduplicates the bullet list since repeated calls to the same tool produced repeated bullets. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Code Review SummaryThis PR cleanly addresses issue #1092: raw tool identifiers no longer leak into either fallback message path. The implementation is small, well-contained, and well-tested. The humanizer table covers all 13 tools currently dispatched by The change is a net positive and meets the acceptance criteria. I have one structural concern about long-term drift between the dispatch table and the humanizer, and a few smaller observations below — none are blockers. Verdict: Approve with one improvement suggestion (drift-prevention test) and a couple of nits. Findings🟢 Critical IssuesNone. 🟡 Suggested Improvements
🟢 Nits
Scope checkThe author extended the fix to the post-tool empty-response synthesis path at RecommendationApprove with one suggested follow-up: add the drift-detector test (Improvement #1) before merge. The remaining improvements and nits are optional polish. |
malibio
left a comment
There was a problem hiding this comment.
Net positive change that meets issue #1092's acceptance criteria. See review comment for one suggested follow-up (drift-detector test) and minor polish nits — none are blockers. Full report: #1127 (comment)
- Add `humanize_tool_name_covers_all_registered_tools` drift detector that iterates `all_tool_definitions()` and asserts every registered tool has a non-generic humanized mapping. Without it, adding a new tool would silently degrade the chat UI to "the requested action". Made `all_tool_definitions` `pub(crate)` so the test can reach it. - Replace the brittle "node search" assertion in `max_iteration_limit` with invariant checks (no underscores, no raw `search_nodes` identifier). The phrase-level assertions live in `humanize_tool_name_known_tools` where they belong. - Preserve the retry diagnostic signal in the max-iterations fallback: repeated calls to the same tool now collapse to one bullet with a "(N×)" count suffix, so the message stays terse while still showing the agent looped on the same operation. The test now asserts the count is present. - Add a doc-comment breadcrumb pointing at `tools.rs` and the drift test. - Copy polish: "task status update" → "task update" (consistent with peers), "related-node lookup" → "related node lookup" (drops the awkward hyphen). Skipped per reviewer guidance: - O(n²) `Vec::contains` dedup — reviewer flagged as not worth changing at n=5. - The unrelated `cargo fmt` blank-line cleanup in `schema.rs` — already in the prior commit; reviewer said accept as-is. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Review feedback addressed in 8b87050✅ Addressed (4 substantive + 3 nits)🟡 Drift detector test — Added 🟡 Test brittleness — 🟡 Dedup loses retry signal — Repeated calls to the same tool now collapse to one bullet with a 🟢 Doc breadcrumb — Added "Keep arms in sync with 🟢 Copy polish — ⏭️ Skipped (2)🟡 O(n²) 🟢 Unrelated blank-line cleanup in Verification
🤖 Generated with Claude Code |
* Humanize tool names in agent fallback responses (#1092) When the model fails to produce text alongside tool calls — either at max iterations or after a final tool round — the agent loop synthesizes a fallback message so the chat UI never goes blank. Previously these messages embedded raw internal identifiers like `create_schema` and `update_node`, surfacing implementation detail to end users. Map known tool names to user-facing phrases (e.g. "schema creation", "node update") and route unknowns through a generic "the requested action" so no raw identifier can leak. The max-iterations branch also deduplicates the bullet list since repeated calls to the same tool produced repeated bullets. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Address review feedback on #1127 - Add `humanize_tool_name_covers_all_registered_tools` drift detector that iterates `all_tool_definitions()` and asserts every registered tool has a non-generic humanized mapping. Without it, adding a new tool would silently degrade the chat UI to "the requested action". Made `all_tool_definitions` `pub(crate)` so the test can reach it. - Replace the brittle "node search" assertion in `max_iteration_limit` with invariant checks (no underscores, no raw `search_nodes` identifier). The phrase-level assertions live in `humanize_tool_name_known_tools` where they belong. - Preserve the retry diagnostic signal in the max-iterations fallback: repeated calls to the same tool now collapse to one bullet with a "(N×)" count suffix, so the message stays terse while still showing the agent looped on the same operation. The test now asserts the count is present. - Add a doc-comment breadcrumb pointing at `tools.rs` and the drift test. - Copy polish: "task status update" → "task update" (consistent with peers), "related-node lookup" → "related node lookup" (drops the awkward hyphen). Skipped per reviewer guidance: - O(n²) `Vec::contains` dedup — reviewer flagged as not worth changing at n=5. - The unrelated `cargo fmt` blank-line cleanup in `schema.rs` — already in the prior commit; reviewer said accept as-is. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude <[email protected]>
Summary
humanize_tool_name()inpackages/agent/src/local_agent/agent_loop.rsmapping every supported tool (create_schema,update_node,search_semantic, etc.) to user-facing prose.Test plan
cargo test -p nodespace-agent --lib agent_loop::— 23/23 pass, including the updatedmax_iteration_limittest that now asserts the fallback contains no raw tool identifierbun run test— 128 files / 3918 tests passbun run quality:fix— clean (eslint, svelte-check, cargo fmt, clippy)Test status vs baseline
Closes #1092
🤖 Generated with Claude Code