2 Commits

Author SHA1 Message Date
6a17c0580a fix: give the agent an explicit way to decline drafting a reply
handleNewEmail's auto-draft fallback treated any text the model
returned, without calling draft_reply/draft_email, as an inline draft
to save to the Drafts folder. The default system prompt gave the model
no supported way to decline a reply, so when it correctly judged an
email as spam, a sales pitch, or a newsletter and explained why in
plain text instead of calling a tool, that explanation got passed
through verifyDraft and saved as a nonsense draft addressed to the
sender — one click from being sent back to the spammer.

Add a skip_email tool the model can call instead of draft_reply, with
a short reason. handleNewEmail now checks for that tool call (only
when draft_reply/draft_email was NOT also called in the same run, so
an already-created draft's side effect always takes priority) and
logs "Skipped: <reason>" to the agent chat instead of falling through
to the inline-text draft fallback. DEFAULT_SYSTEM_PROMPT now documents
when to use it.

Fixes cloudflare/agentic-inbox#73.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-20 15:50:36 +03:00
Thomas Gauvin
cff1a79a39 Agentic Inbox: self-hosted email client with AI agent on Cloudflare Workers 2026-04-16 00:54:30 -04:00