fix(tools): require permission before web_search requests#382
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
👮 Files not reviewed due to content moderation or server errors (2)
Warning Walkthrough skippedFile diffs could not be summarized. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR tightens web_search’s safety/permission behavior so that networked hosted search cannot execute until the normal permission flow approves it, aligning it with web_fetch while still keeping it visible to the model in auto mode.
Changes:
- Switch
web_searchsafety metadata fromPermissionAllowtoPermissionPromptand setAdvertiseInAuto: true. - Add/adjust tests to ensure permission is required before any backend call, and that approved runs still execute correctly.
- Update sandbox/agent-loop expectations to reflect prompting behavior for
web_searchunder network-deny shell egress policies.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/tools/web_search.go | Updates web_search safety metadata to prompt for permission while remaining advertised in auto mode. |
| internal/tools/web_search_test.go | Adds coverage ensuring permission is enforced before backend execution, and validated after grant. |
| internal/tools/registry_test.go | Updates core tool safety expectations for web_search to require prompt + auto advertisement. |
| internal/sandbox/engine_test.go | Adjusts sandbox evaluation expectations to prompt for web_search based on tool permission metadata. |
| internal/agent/loop_test.go | Adds agent-loop coverage to ensure permission is requested and denied calls do not execute web_search. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Vasanthdev2004
left a comment
There was a problem hiding this comment.
Verdict: Approve ✅ — correct, and it makes web_search consistent with web_fetch
Is it useful? Yes. web_search was the one first-party network tool that ran without a permission prompt (PermissionAllow), even though it ships model-generated query text — which can embed prompt/workspace context — to a hosted backend. Its sibling web_fetch already prompts for exactly this reason. I confirmed web_fetch's metadata is SideEffectNetwork + PermissionPrompt + AdvertiseInAuto: true (web_fetch.go:128-131) — this PR makes web_search byte-for-byte identical in posture. Closing that asymmetry is the right call.
Implementation is correct:
AdvertiseInAuto: trueis required and right — advertisement in auto mode is gated onPermission == PermissionAllow || AdvertiseInAuto(loop.go:2620/2628), so without it a now-PermissionPrompttool would vanish from the model's toolset in auto mode. With it,web_searchstays visible in auto and prompts only where the mode prompts — same asweb_fetch. ✔- The sandbox exemption is preserved correctly:
engine_test.gonow assertsweb_searchyieldsActionPrompt(from tool permission) rather thanReasonNetworkBlocked(shell egress), andActionAllowonce granted. So first-party network tools are still exempt from the shell egress policy and governed by their permission metadata — the intended design. ✔ - No stragglers: the web_search-specific
PermissionAllowassertions (registry/web_search/engine/loop tests) are all updated; I grepped the tree and found no missed reference.
Behavioral impact (worth the maintainer noting): this is a deliberate reversal of the old "read-only discovery action, allow without prompt" choice. Net effect — Ask mode now prompts before a search (previously frictionless); Auto mode is unchanged (still runs). Session/always grants remain the compatibility path, so it's one approval per session, not per query. Given it simply brings web_search in line with web_fetch, the trade-off is reasonable — flagging only so it's a conscious product decision, not a surprise.
Verification (branch checked out): go build ./... clean, gofmt clean on all five changed files, and the full tools + agent packages plus every new test pass. (The one sandbox failure — TestNewScopeNormalizesAndValidatesExtraRoots, "want default /tmp write root" — is a pre-existing Windows-only failure that reproduces identically on main; unrelated to this change.)
Approving. Thanks @GautamBytes — clean, well-tested, and the red-green permission test is exactly the right guard.
* fix(tools): gate web_search behind network permission * chore(tools): clarify web_search permission reason --------- Co-authored-by: Gautam Manchandani <gautammanch@Gautams-MacBook-Air.local>
Fixes #380
Summary
web_searchtool behind the normal permission flow before it sends queries to a configured backend.web_searchvisible in auto mode withAdvertiseInAuto: true, matching the existingweb_fetchpattern.Why
web_searchis marked as a network side-effecting tool, but it previously usedPermissionAllow. That let hosted search run without a permission prompt even though queries may include prompt or workspace context.