Setup: gogcli v0.47.1 built with ./build-safe.sh and a safety profile with locked-flags: {sanitize-content: true, wrap-untrusted: true, no-input: true}, the hardening recommended for agents (Headless agent Gmail access: Testing-mode OAuth tokens die in 7 days; publish the app unverified and enforce no-send in the tool, not the scope).
Symptom: the bot was asked to build a draft that reused the data-room and memo links from an earlier email. It reported that "the mail tool removes every URL" and left [LINK] placeholders in the draft.
Cause (internal/cmd/gmail_sanitize.go):
sanitizeGmailTextapplieshttps?://[^\s<>"'])]+->[url removed]` to bodies and headers.extractSanitizedHTMLTextkeeps only text tokens, so<a href>targets disappear even before the regex.- The flag help says so ("strip HTML, remove HTTP(S) URLs, and omit raw Gmail payloads"), but the profile docs present locking it as the safe default without naming that cost.
- Locked means
--sanitize-content=falseis an error, not an override. No--keep-urlsoption exists in v0.47.1 or v0.48.0.
What URL removal buys: injected instructions still arrive as text, so it only takes away ready-made links. If drafts already need human approval and a human sends, that may not be worth losing links.
Options:
- Carry a small patch in the safe build so the sanitizer keeps URLs (and renders
<a href>astext (url)). The lock, HTML stripping, and payload omission stay. - Unlock
sanitize-content. The model can then also request--format rawand full HTML payloads. - Keep the lock and have a human supply links.
Check before patching: Gmail's own replies put links in text/plain (the part the sanitizer prefers), so keeping URLs in plain text alone was enough for the threads I tested.