My agent had one rule, only answer about production. That rule was a sentence in its prompt, and a sentence is only a request. So I added a real check at the door of the tool, and the same call for staging was refused.
An AgentCore Gateway is the front door to an agent's tools. A policy is a rule at that door that checks every call before the tool runs. The agent cannot talk its way past it, because the check happens outside the agent's code.
What was holding it back before
In my last post I ran my CloudOps agent as my own code. I asked it about staging, and it said it could only help with production.
That answer came from its prompt. The model chose to refuse. Nothing stopped the tool call itself.
I added one rule to the Gateway. It says: the deployment status tool is allowed, but only when the call asks about production. That is the whole rule.
It took three steps. I wrote the rule in a small file, added it to a policy engine with the AgentCore command line tool, and deployed. AWS writes these rules in a language called Cedar, but you do not need it to follow the idea.
Anything the rule does not allow is refused, because the default is no. I never wrote a rule about staging at all.
Staging: refused at the door
I called the Gateway directly, skipping the model, so the prompt could not be the reason. Here is the error that came back:
Tool Execution Denied: Tool call not allowed due to policy enforcement [No policy applies to the request (denied by default).] Read that last part carefully. It does not say a rule blocked staging. It says no rule allowed it. That is why a short list of what is allowed is enough.
Production: same door, door open
The same direct call with production returned healthy data: version 2026.09.20.1, and 3 of 3 instances running. Then I asked the agent "Is production healthy?" and it answered with those details.
So the rule did not break the normal path. One tool, two environments, and the Gateway decided which one got through.
When I would use a policy and not a prompt
I would keep the prompt, because it shapes what the agent says. But for anything that must never happen, I would not rely on a sentence. A prompt is for what you want, and a policy is for what you require.



