Skip to main content
Version: 11.5.0

Policy Examples

Every example on this page is a complete HYPR AgentPass™ policy in miniature. It gives the intent, the phase and action to choose in the New policy wizard, the condition to paste, and what to watch for before you promote it from Observe.

The page has three kinds of example:

  • The built-in examples on the wizard's Logic step
  • The common guardrails, templates on the wizard's Start step
  • Recipes for the attributes the AI does not write

Publish every one of these in Observe first, and read its matches on the policy's Decisions tab. See Observe First, Then Enforce.

The Built-In Examples​

The wizard's Logic step offers these eleven conditions under Examples. Click one to replace the expression in the editor with it, then adjust it.

ExampleIntentPhase · ActionConditionWatch for
Block DELETEsStop any HTTP DELETE through a REST connectorPre-Request · DENYrequest.method == "DELETE"Scope it to the connector you mean. Unscoped, it applies to every connector
Large token requestsCap how much a model may be asked to generatePre-Request · DENYhas(request.body.max_tokens) && request.body.max_tokens > 50000A body with no max_tokens is a non-match either way. The has() guard makes that intent explicit
Specific pathGovern one part of an APIPre-Request · DENY or REQUIRE_APPROVALrequest.path.startsWith("/v1/admin")Paths are compared as sent. Check the Request log for the exact prefix
Error responsesRecord backend failuresPost-Response · ALLOWresponse.status >= 500response.* is empty during Pre-Request, so this must be a Post-Response rule
Specific agentApply a rule to one agentPre-Request · anyrequest.agent.name == "my-agent"request.agent is empty when the caller is unauthenticated, so this never matches anonymous traffic
Slow responsesRecord slow backendsPost-Response · ALLOWresponse.latency_ms > 10000Post-Response only, as for error responses
Bedrock: unattributed callerBlock a Bedrock call the gateway could not attribute to a named developerPre-Request · DENYconnector.template == "AWS_BEDROCK" && connector.aws.bedrock.identity_source != "CLOUDTRAIL"Safe by construction: identity_source is always present on a Bedrock request
Bedrock: no MFAFlag identified sessions that were not MFA-backedPre-Request · DENYconnector.aws.bedrock.mfa_authenticated == falsemfa_authenticated is present only when the caller was identified. Pair it with the unattributed-caller example to catch the unidentified
M365: Copilot Studio agents onlyApply a rule to turns with a Copilot Studio agentPre-Request · anyconnector.m365.copilot.surface == "copilot_studio"surface is the one Copilot attribute that is always present. Lead every Copilot rule with it
Files: confidential attachmentStop a document marked confidential from reaching an agentPre-Request · DENYrequest.files.exists(f, f.text.contains("CONFIDENTIAL"))text holds at upload and on the send, so you can enforce it at either
Files: over 10 MBRefuse large attachmentsPre-Request · DENYrequest.files.exists(f, f.size_bytes > 10485760)Size is the gateway's own measurement only at upload. On the send, it is what the caller says. Enforce at upload

The Common Guardrails​

The New policy wizard offers these six templates under Or start from a common guardrail. A template fills in the whole policy, including a fixed condition that you can read and change before you publish. No AI writes it. See Creating a Policy.

Every template reads the conversation on an inference connector, so its condition matches only there. Each one denies, with a message telling the agent what was refused.

TemplatePolicy nameChecksWatch for
Block destructive shell commandsblock-destructive-shell-commandsThe replyMatches the text of the command. A plain rm of one file does not match
Block reads of credential filesblock-credential-readsThe replyMatches any tool input naming one of the files, whichever tool asks
Block writes outside the projectblock-writes-outside-projectThe replyCovers Write and Edit calls only. A read of the same path does not match
Block secrets pasted into a promptblock-secrets-in-promptsThe requestPattern-based. Back-test it against your own traffic before you enforce it
Block personal data in promptsblock-personal-data-in-promptsThe requestPattern-based. Back-test it against your own traffic before you enforce it
Block production system accessblock-production-accessThe replyHost naming differs by organization. Adapt the patterns to your own

The four reply-side templates are caught in the reply. The agent runs tools on its own machine, so the command appears only in the model's request to run it. Enforcing one of them cuts the reply short at that tool call. See Governing Inference Traffic.

Block destructive shell commands — the reply
inference.tool_uses.exists(t,
t.input_json.contains('rm -rf') ||
t.input_json.contains('mkfs') ||
t.input_json.contains('dd if='))
Block reads of credential files — the reply
inference.tool_uses.exists(t,
t.input_json.contains('.env') ||
t.input_json.contains('.aws/credentials') ||
t.input_json.contains('id_rsa') ||
t.input_json.contains('id_ed25519') ||
t.input_json.contains('.keychain'))
Block writes outside the project — the reply
inference.tool_uses.exists(t,
(t.name == 'Write' || t.name == 'Edit') &&
(t.input_json.contains('"/etc/') ||
t.input_json.contains('"/usr/') ||
t.input_json.contains('/.ssh/')))
Block secrets pasted into a prompt — the request
inference.latest_turn.text.contains('PRIVATE KEY-----') ||
inference.latest_turn.text.matches('AKIA[0-9A-Z]{16}') ||
inference.latest_turn.text.matches('[Bb]earer [A-Za-z0-9._-]{20,}')
Block personal data in prompts — the request
inference.latest_turn.text.matches('(^|[^0-9])[0-9]{3}-[0-9]{2}-[0-9]{4}([^0-9]|$)') ||
inference.latest_turn.text.matches('(^|[^A-Z])[A-Z]{2} ?[0-9]{2} ?[0-9]{2} ?[0-9]{2} ?[A-D]([^A-Za-z0-9]|$)') ||
inference.latest_turn.text.matches('(^|[^0-9])[0-9]{4}[ -]?[0-9]{4}[ -]?[0-9]{4}[ -]?[0-9]{4}([^0-9]|$)')
Block production system access — the reply
inference.tool_uses.exists(t,
t.input_json.matches('(prod|production)[.-][A-Za-z0-9.-]*[.](internal|local|com|net|io)') ||
t.input_json.matches('(postgres|postgresql|mysql|mongodb)://[^ "]*prod') ||
t.input_json.matches('--context[= ]prod'))

Attached Files​

Files reach the gateway through the Agent Portal, and are checked twice: at upload, and again on the message that sends them. Name, type, size and checksum are the gateway's own measurement at upload only. text is the content that actually reaches the agent, so it holds on both.

Block PDF attachments over roughly one megabyte — enforce at upload
request.files.exists(f, f.mime_type == "application/pdf" && f.size_bytes > 1000000)
Act only on requests that carry a file
request.file_count > 0

request.file_count is always present, so it is the safe way to ask whether a request carried a file at all. request.files itself is absent when there are none. That makes request.files.exists(…) a non-match on ordinary traffic, which is correct, and worth knowing.

Sensitivity Labels​

request.files[].sensitivity_label carries the Microsoft Purview sensitivity label an uploaded document holds, as AgentPass read it from the document itself. It is present on an Agent Portal upload, and absent on the message that sends a file onward. Every rule in this group therefore acts at upload. See The Document's Sensitivity Label.

Block documents marked Highly Confidential. The first form reads clearly. Enforce the second, because a label can be renamed in Microsoft Purview and an identifier cannot.

Block a document marked Highly Confidential — readable form
request.files.exists(f, f.sensitivity_label.name == "Highly Confidential")
The same rule written on the label's identifier — prefer this to enforce
request.files.exists(f, f.sensitivity_label.id == "00000000-0000-0000-0000-000000000000")

Require every Office document to be classified. state is present on every upload, and not_applicable covers the formats that cannot carry a label at all. This rule therefore reaches unclassified Word, Excel and PowerPoint documents, without touching a text file, a CSV or a PDF.

Refuse an Office document that carries no sensitivity label
request.files.exists(f, f.sensitivity_label.state == "unlabeled")

Block a whole branch of your label taxonomy. parent_id is set on a sub-label. One rule on the parent's identifier covers every sub-label under it, and needs no editing when the taxonomy grows.

Block anything under one label, sub-labels included
request.files.exists(f, f.sensitivity_label.parent_id == "00000000-0000-0000-0000-000000000000")

Insist on Microsoft Purview's own stamp. source separates a label Purview applied from a plain sensitivity name some other tool wrote, which has no identifier and nothing to verify it against.

Flag a document whose marking did not come from Microsoft Purview
request.files.exists(f,
f.sensitivity_label.state == "labeled" && f.sensitivity_label.source != "msip_properties")

Publish each of these in Observe first. Run it for a few days, and read the matches to see which of your documents actually carry which labels, before a rule starts refusing uploads.

The Signed-In Person​

request.user is the email of the person the gateway verified at sign-in, never a value the caller asserted. It is absent when nobody signed in.

Act only on requests from your own organization
request.user.endsWith("@example.com")
A block written only on request.user lets anonymous requests through
Do not write a rule this way
!request.user.endsWith("@example.com")

This blocks the outsiders it names, and allows every request that carried no identity, because a condition on a missing attribute is never true. Make the missing case match too, and say which traffic the rule governs:

The same intent, written safely
connector.template == "M365_COPILOT" && (!has(request.user) || !request.user.endsWith("@example.com"))

The !has(request.user) branch is what catches a request that carried no identity.

Requiring a sign-in in the first place is the connector's job, not the policy's.

The Connector​

Every request carries connector.name, connector.template and connector.onboarding_mode. Lead a template-specific rule with the template, so the intent is clear to whoever reads it next:

Guard a Bedrock-specific rule
connector.template == "AWS_BEDROCK" && connector.aws.bedrock.mfa_authenticated == false
Apply a rule to one connector by name
connector.name == "prod-anthropic" && request.path.startsWith("/v1/messages")

The Connector field in the wizard scopes the policy the same way. The guard in the expression states the scope in the rule itself.

The AWS Caller Behind a Bedrock Request​

On an AWS Bedrock connector, connector.aws.bedrock.* describes the developer behind the call, as far as the gateway could identify them. Only identity_source, credential_type and has_security_token are always present, so build a block on those. Bedrock Caller Policies explains the attribution and the safe pattern.

Block calls that cannot be attributed to a named developer
connector.template == "AWS_BEDROCK" && connector.aws.bedrock.identity_source != "CLOUDTRAIL"
Flag identified sessions that were not MFA-backed
connector.template == "AWS_BEDROCK" && connector.aws.bedrock.mfa_authenticated == false
Block long-term IAM keys, allowing only SSO sessions
connector.template == "AWS_BEDROCK" && connector.aws.bedrock.credential_type == "LONG_TERM"
Require an AWS SSO session, blocking Bedrock API keys
connector.template == "AWS_BEDROCK" && connector.aws.bedrock.credential_type != "TEMPORARY"
Restrict a connector to developers from one email domain
connector.template == "AWS_BEDROCK"
&& connector.aws.bedrock.identity_source == "CLOUDTRAIL"
&& !connector.aws.bedrock.user_email.endsWith("@example.com")

The last acts only on callers the gateway identified. Pair it with the first, so the unidentified are caught too.

Approval-based onboarding on a Bedrock connector holds SSO sign-ins only. The fourth rule is therefore how you reach API-key callers. A policy is evaluated on every Bedrock request, whichever credential it carried.

Microsoft 365 Copilot​

On a Microsoft 365 Copilot connector, connector.m365.copilot.surface is always present. The Copilot Studio agent attributes arrive on copilot_studio turns only. Microsoft 365 Copilot Policies explains the surfaces.

Block turns with one Copilot Studio agent
connector.template == "M365_COPILOT"
&& connector.m365.copilot.surface == "copilot_studio"
&& connector.m365.copilot.agent_id == "00000000-0000-0000-0000-000000000000"
Apply a rule to Microsoft 365 Copilot chat but not to your agents
connector.template == "M365_COPILOT" && connector.m365.copilot.surface == "default_copilot"
Restrict a connector to people from one email domain
connector.template == "M365_COPILOT"
&& connector.m365.copilot.surface == "copilot_studio"
&& !connector.m365.copilot.user_email.endsWith("@example.com")
Block a confidential document at upload
connector.template == "M365_COPILOT"
&& connector.m365.copilot.surface == "attachment_upload"
&& request.files.exists(f, f.text.contains("CONFIDENTIAL"))
Block a reply that quotes a document marked confidential — Post-Response
connector.template == "M365_COPILOT" && inference.completion.text.contains("CONFIDENTIAL")

Prefer agent_id to agent_name in a rule you enforce. The name changes if someone renames the agent, and a rule on the old name quietly stops matching.

The last example is a reply-side rule. On a Copilot connector, any enabled reply-side rule makes replies arrive complete instead of streaming, for every conversation on that connector.

Recipes Across Namespaces​

One agent, one part of an API. Combine the calling agent with the path so the rule is about a specific agent doing a specific thing:

Require approval when the deploy agent touches production endpoints — Pre-Request
request.agent.name == "deploy-agent" && request.path.startsWith("/v1/prod/")

Guard an inference rule with the connector. An inference.* condition is a non-match on a connector that reaches no model, so scoping is already safe. The guard makes the intent readable:

Block prompts to one provider that mention an internal project — Pre-Request
connector.template == "ANTHROPIC" && inference.latest_turn.text.contains("Project Redwood")

Reading inference.latest_turn.text, not the whole conversation, makes this fire once, on the turn that introduced the phrase, instead of on every turn after it.

Files at upload, files at send. Write the metadata rule for upload, and the content rule for both:

Refuse a large attachment where the size is the gateway's own measurement — upload
connector.m365.copilot.surface == "attachment_upload" && request.files.exists(f, f.size_bytes > 10485760)
Stop confidential text reaching any agent — upload or send
request.files.exists(f, f.text.contains("CONFIDENTIAL"))

A daily spend cap. Create a spend limit instead of writing this by hand. It writes the rule, sends the approval to the limit's owner, and lets the owner raise the limit for a day. The usage attributes it reads are in the Attribute Reference.