Repository navigation
fix(approvals): an approval card's reason is never the tool's instructions for the model - #404
Merged
Merged
Conversation
…tions for the model The reason is the describe_fn label when it says more than the risk (Purchase, Unlocks a door), else empty so the card writes its own line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #398
What changes
approval_request.reasonused to bef"{plugin}: {tool.description[:160]}": the tool's instructions for the model, cut off mid-word ("browser: Click the element with this ref (from browser_snapshot), e.g. "e12". Buttons that buy, pay, send, post, delete or confirm need the user's approval. Never type p").It's now
approval_reason(wording, risk)insentient/tools/base.py:describe_fngives a label that says more than the risk alone, the reason is that label. Examples: "Purchase", "Deletes", "Posts publicly" and "Signs up" from the browser, "Unlocks a door" from Home Assistant, "Takes a photo" from devices."", and the card writes its own line ("... using browser_click").That covers every tool that reaches this path. Built-in plugin tools, integrations and MCP tools all went through the same line, and now none of them show their model-facing description.
Side effect on the heading (desktop
approvalRisk.ts, untouched here). The card guesses its heading from the tool name plusreason. The old description text held "buy, pay, send, post, delete", so a send-risk browser click always read Purchase. Now it reads "Sends", unless the browser's own label says Purchase, Deletes or Posts publicly. That label now arrives inreason, so the heading still matches it.The one thing lost: an MCP tool whose purpose shows only in its description (not its name) gets the generic heading for its risk. Open PR #367 moves headings to
risk_label, which is the long-term fix.Changes are limited to the engine reason line,
docs/API.md(theapproval_requestrow) and CHANGELOG.ApprovalCard.tsxandapprovalRisk.tsaren't touched, because #367 changes them. The doc comment inapprovalRisk.tsstill saysreasonis the tool's description. #367 or a follow-up can update it.Tests
tests/test_approval_reason.py:approval_reasonkeeps only labels that say more than the risk.run_turnwith a plugin tool whose description is model text and whosedescribe_fnlabels the call. The approval requests carryreason"" for a plain send and "Purchase" for "Place order", and the model text appears nowhere in the event.tests/test_agent_loop.py,tests/browser, Home Assistant and terminal tests pass. Full suite: 2372 passed, 2 skipped. Ruff is clean, and desktop typecheck and build are clean.Real test
Built app from this branch (
npm run build), freshSENTIENT_HOME, modelsclaude-code/sonnet(fastclaude-code/haiku). The app was driven over a DevTools port this run opened (9351), on its own window only. The page was local:http://127.0.0.1:8786/, "Maya's book club", with a "Send message" button.I asked: "Open http://127.0.0.1:8786/ in the browser and click the Send message button to post my note to the book club." Sonnet called
browser_open, then asked in words whether to send. I answered "Yes, click Send message now."The approval card read, in full:
There's no model text in it ("Click the element with this ref", "Never type ..." are gone). The badge says "Sends", not "Purchase".
I pressed Deny. The step shows "Browser step not done · You declined: Clicking", and the reply is "That didn't go through, the click was declined, so the message was not sent."
Screenshots, which I looked at:
398-approval-card(the card above) and398-after-deny(the declined step and the reply).Notes for the owner
ApprovalCard.tsx(meta.done), which I left alone because of fix(desktop): use the engine risk_label for approval card headings #367. A small follow-up there could use therunningorwouldwording instead.Summary by CodeRabbit