Safeguard
AI Security•

Prompt rules vs deterministic controls for AI agents

A prompt that says never do X is a request, not a control. Which agent limits belong in code and policy, and which can safely stay in the prompt.

Safeguard Security Team
3 min read

A rule written in a prompt is a request the model usually follows. A rule enforced in code or policy is a limit the model cannot talk its way past. Put anything with real consequences, such as which tools run, which data is reachable and what needs approval, into deterministic controls, and use the prompt for style and guidance.

The difference in one example

Prompt rule: "Never send customer data outside the company." If the agent reads a hostile document that says otherwise, the model may comply with it.

Deterministic control: the agent's send tool only accepts recipients on an allowlist, and the call is rejected in code otherwise. The model can ask for anything; the call fails.

The UK NCSC makes the same point: assume the model can be manipulated and use deterministic, non-LLM controls to bound what the system can do. It also warns against deny lists of attack phrases, since attackers rephrase.

What belongs where

ConcernPromptCode or policy
Tone, format, languageYesNo
Task instructions and examplesYesNo
Which tools can runNoYes
Which recipients, domains or pathsNoYes
Spend and rate limitsNoYes
Approval for risky actionsNoYes
Access to dataNoYes
LoggingNoYes

A useful test: if a failure would cost money, leak data or change a record, it needs more than a sentence.

Types of deterministic control

  • Allowlists of tools, domains, repositories and recipients.
  • Argument validation. Reject malformed or out of range values before the call runs.
  • Scoped credentials. The token simply cannot do more.
  • Rate and spend caps.
  • Approval gates on defined actions.
  • Output handling. Treat model output as untrusted before rendering or executing it.
  • Sandboxing of code execution and file access.

Keep the prompt honest too

Prompts still help. A clear prompt reduces mistakes and can make attacks harder. Just do not count it as the barrier. The same applies to tagging external content as data: it makes attacks harder, but it does not remove the risk.

How to review an agent

  1. List every sentence in the prompt that starts with "never" or "always".
  2. For each, ask what enforces it outside the model.
  3. Where the answer is nothing, add a control or accept the risk in writing.

Try it yourself

Click through it at your own pace, or open it full screen. Watch how a gate blocks a change on a rule, whatever anyone writes in the description.

Where Safeguard fits

Safeguard's policies, gates and guardrails enforce limits outside the model, and the MCP Guardrail applies them to MCP tool calls.

Quick check

Is a strong system prompt enough?

No. Use it for guidance, and enforce limits with code and policy.

What is the quickest win?

Scope the agent's credentials and tools so unwanted actions fail regardless of the prompt.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.