Skip to content

feat(gmail): add --gmail-no-send flag to block send operations#454

Open
veteranbv wants to merge 1 commit intosteipete:mainfrom
veteranbv:feat/gmail-no-send
Open

feat(gmail): add --gmail-no-send flag to block send operations#454
veteranbv wants to merge 1 commit intosteipete:mainfrom
veteranbv:feat/gmail-no-send

Conversation

@veteranbv
Copy link

Motivation

gmail.modify is the right OAuth scope for an agent that needs to read, label,
and create drafts — but it also permits send. Google provides no scope that
grants modify-level access without send capability. This means there is no way
to give an AI agent read/label/draft access while maintaining a hard block on
send.

A prompt-level guardrail is not sufficient: if safety instructions are compacted
away during a long session, an agent operating on gmail.modify could send
email on behalf of the user. The block needs to live in the binary itself, below
the instruction layer, where context compaction cannot reach it.

Closes #453

Summary

  • Add --gmail-no-send global flag and GOG_GMAIL_NO_SEND env var
  • Block all four send paths: send, gmail send, gmail drafts send,
    gmail autoreply
  • Enforce centrally in Execute() using the same pattern as
    enforceEnabledCommands — post-parse, pre-Run(), exit code 2
  • Error message directs users to gog gmail drafts create as the
    non-send alternative

Test plan

  • TestIsGmailSendCommand — unit coverage for all send and non-send
    command strings
  • TestGmailNoSendBlocksViaCLI — integration test: all four send paths
    blocked via --gmail-no-send
  • TestGmailNoSendAllowsNonSendCommands — non-send commands pass through
  • TestGmailNoSendEnvVarGOG_GMAIL_NO_SEND=1 blocks send
  • TestGmailNoSendNotSetAllowsSend — without flag, send is not blocked
  • go test ./... — full suite passes, no regressions
  • make lint — clean

Add a CLI-layer kill switch (--gmail-no-send / GOG_GMAIL_NO_SEND=1)
that blocks all send operations in the gmail command group, regardless
of OAuth scopes.

gmail.modify is the right scope for an agent that needs to read, label,
and create drafts, but it also permits send. Google provides no scope
that grants modify-level access without send capability. This flag gives
agent operators a hard invariant: deploy gog with GOG_GMAIL_NO_SEND=1
and send is impossible, full stop, regardless of what the agent is told
or forgets.

Blocked paths: send, gmail send, gmail drafts send, gmail autoreply.
Enforced centrally in Execute() using the same pattern as
enforceEnabledCommands — post-parse, pre-Run(), exit code 2.
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.

feat(gmail): add --gmail-no-send flag for agent safety

1 participant