Policy library
Sending external email
Email that leaves the company cannot be taken back. Watch for mass sends, files sent to outsiders, and domains you never want to mail.
What it guards#
| Tool | When an agent calls it |
|---|---|
send_email | To send a message from a company mailbox |
Params#
| Param | Type | Required | Meaning |
|---|---|---|---|
recipient_domains | list of strings | yes | Each distinct domain in To, Cc and Bcc, lowercase. ["example.com", "customer.test"] |
recipient_count | whole number | yes | Total recipients across To, Cc and Bcc |
has_attachment | boolean | yes | true if any file is attached |
Work these out in your code from the message you are about to send, not from what the model says it will send.
Outcomes#
| Request | Outcome | Policy id |
|---|---|---|
| Only internal domains, up to 50 recipients | allow | email-internal |
| Up to 3 recipients, no attachment | allow | email-external-small |
| Up to 500 recipients | ask_human | email-needs-approval |
| More than 500 recipients | block | email-mass-send |
| Any denied domain | block | email-denied-domains |
Tune it#
- Replace
"example.com"inemail-internalwith your own domains. - Edit the deny list in
email-denied-domains. - To make every outside email wait for a person, delete
email-external-small.
The policy#
This is email.cedar as it is in the repository.
// Sending email outside the company.
//
// Tool: send_email
// Params: recipient_domains (list of strings, one per distinct domain),
// recipient_count (whole number), has_attachment (boolean)
//
// only internal domains, up to 50 recipients allow
// up to 3 recipients, no attachment allow
// up to 500 recipients ask a human
// more than 500 recipients block
// any domain on the deny list block
@id("email-internal")
permit (principal, action == Action::"act", resource == Tool::"send_email")
when {
["example.com"].containsAll(context.recipient_domains) &&
context.recipient_count <= 50
};
@id("email-external-small")
permit (principal, action == Action::"act", resource == Tool::"send_email")
when { context.recipient_count <= 3 && !context.has_attachment };
@id("email-needs-approval")
permit (principal, action == Action::"act_with_approval", resource == Tool::"send_email")
when { context.recipient_count <= 500 };
@id("email-mass-send")
forbid (principal, action, resource == Tool::"send_email")
when { context.recipient_count > 500 };
@id("email-denied-domains")
forbid (principal, action, resource == Tool::"send_email")
when { context.recipient_domains.containsAny(["competitor.example", "pastebin.example"]) };