AWS Builder Center

Dogwood: Cedar That Can Look Back

Going beyond the current request to permit or deny a tool call, with temporal policies and guardrails in Amazon Bedrock AgentCore Policy.

Cedar and Dogwood express tool authorization the same way:  permit  and  forbid  rules over a principal, an action (the tool being called), and a resource (the gateway it arrived through), with deny by default and  forbid  overriding  permit . What separates them is how much a rule is allowed to look at.

Plain Cedar
Dogwood
What a rule can see
The current request only. The caller, the tool being invoked, and that call's arguments in  context.input .
The same, plus every earlier tool call and result in the session, plus values computed while the decision is being made.
So the rules you can write are
Who may call which tool, and bounds on the arguments of this call.
The same, plus rules of the form "this tool may run only if that tool ran first," and rules that consult a freshly computed signal.
What stays out of reach
Anything depending on what happened before this request, or on any fact the request does not carry.
Anything outside the session, or further back than 24 hours.
Relationship

A strict superset. Every Cedar policy is already a valid Dogwood policy.
Concretely, a single Dogwood policy can carry three kinds of condition, each in its own block, all under the same  permit  and  forbid  model.
Block
Decides on
 when { }  and  unless { } 
The current request. Principal, action, resource, and the call's arguments in  context.input . This is plain Cedar.
 when temporal { } 
Events recorded earlier in the same session.
 when guardrails { }  and  unless guardrails { } 
A signal an information provider computes at evaluation time, such as a Guardrails content-safety or prompt-attack score.
The first block is plain Cedar and it does not change. The second looks backwards, at history. The third looks sideways: it asks a provider to compute something during the decision itself.

A worked example

That is easier to follow in an example than in a table. We will take one small application and give it three requirements, one for each block, in the order a business would ask for them. The first is Cedar. The second needs history, which is where temporal policies come in. The third needs a judgment about free text, which is where guardrails come in.
The application is a retailer's customer service agent. A customer signs in, chats with it in plain language, and the agent can place an order, present the refund terms for one, and issue a refund on the customer's behalf. It runs on Amazon Bedrock AgentCore Runtime and reaches its tools through an AgentCore Gateway. That last detail is worth holding onto, because every tool call has to pass through the Gateway, which makes the Gateway the one place where all of them can be governed.
Three tools do the work. Each becomes an action named  RetailTarget___<tool> .
Tool
Inputs
Outputs
 place_order 
 customerId  (String),  sku  (String),  quantity  (Long)
 orderId  (String),  total  (Long),  status  (String)
 present_refund_terms 
 customerId  (String),  orderId  (String)
 orderId  (String),  accepted  (Bool),  status  (String)
 issue_refund 
 customerId  (String),  orderId  (String),  amount  (Long),  note  (String)
 refundId  (String),  status  (String)
Two fields matter later. Every tool takes a  customerId , which lets a policy check that the agent is acting on the caller's own account. And  issue_refund  takes a free-text  note , the customer's own reason for wanting the refund. Refunds move real money, and that reason is recorded on the refund and can be seen by staff later, so  issue_refund  is the call worth guarding.

The first requirement, in Cedar

1. A signed-in user may use the agent, and only ever act on their own account.
AgentCore Policy uses Cedar to make its permit and deny decisions. You create a policy engine, attach it to your Gateway, and write  permit  and  forbid  rules over a principal, an action, and a resource. The schema is generated from the Gateway's MCP tool manifest, so each tool becomes  AgentCore::Action::"ToolName"  and the resource is always  AgentCore::Gateway::"<gateway-arn>" .
The "signed-in" half needs no policy at all. The gateway is configured with  CUSTOM_JWT , so an unauthenticated caller never reaches policy evaluation in the first place. The "own account" half is a single-request check, and it is exactly the kind of thing Cedar is for. The caller's identity rides in the JWT, where the customer's ID is carried as a  customerId  claim and surfaces on the principal as a tag. The tool call carries a  customerId  argument. The rule requires the two to match.
permit (
principal,
action == AgentCore::Action::"RetailTarget___issue_refund",
resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/retail-gw"
)
when {
context.input.customerId == principal.getTag("customerId")
};
Everything the rule needs is on the one request: the argument in  context.input , the identity in  principal . No history, no external lookup. This is the identity check, and it is worth being clear about what it does and does not settle. It proves the agent is acting as the signed-in customer and cannot name a different one in the tool call parameter. It does not, by itself, prove that  ORD-8841  is that customer's order, because the order-to-owner mapping is not on the request. The refund tool is responsible for that part, refusing an order that does not belong to the  customerId  it was handed. Cedar validates who you are; the tool validates what is yours.
The same clause guards  place_order  and  present_refund_terms . It is the plainest use of the first block, deciding entirely on the request in front of it.

The second requirement, which Cedar cannot express

2. A refund may only be issued if the customer was shown the refund terms and accepted them, earlier in this conversation.
This is a rule about order:  present_refund_terms  must have run, and the customer must have accepted, before  issue_refund . Try to write it in Cedar and there is nothing to grab. The disclosure happened on an earlier request, and Cedar sees only the request in front of it. Evaluating the refund call, it has the refund's own arguments and the caller, and no trace whatsoever that any terms were ever shown.
It is tempting to reach for a tool here, the way you would for order ownership. You could even write each acceptance to a table and read it back before refunding. That does not close the gap, for two reasons. A stored row can record that a customer accepted terms, but not that the acceptance happened in this conversation, which is the whole point of a per-interaction disclosure. And the deeper problem: nothing binds the refund to that row except asking the model to go and check it. Tell the model to present the terms, wait for a yes, and only then refund, and enforcement becomes a sentence in a system prompt, deterministic in every part except the part that decides whether to obey it. Under pressure from an impatient customer, a model will usually show the terms and usually wait for the yes. Usually is not a control.
The rule is not hard to satisfy. It is hard to enforce, because enforcing it means looking at something that happened between two tool calls. A stateless policy engine cannot see across that gap, and neither can the refund tool itself: the disclosure was a separate call, possibly served by a separate system, and no tool has a view of another tool's history. The only component that sees the whole sequence is the gateway that every call passes through.

Dogwood

That gap is what Dogwood addresses. It is an open source policy language, used by AgentCore Policy for session-aware authorization. As noted above it is a strict superset of Cedar, so the first requirement keeps working untouched.
The new syntax is the  temporal  block.  formerly within <window>  asserts that a matching event occurred earlier in the window.  since within <window>  asserts that a condition has held continuously since an anchor event.  count  and  sum  aggregate over the matching events. Finer constructions are available through  previous ,  exists , and  tp , though  formerly within  covers most requirements in practice, including this one.
Before writing the policy, one distinction needs settling, because it accounts for most of the operational behavior encountered later.

The language and the service divide the work

Dogwood is a query language over a history. It has no storage, no counters, and no database of its own. It supplies a way to ask about the past and remembers nothing.
AgentCore Policy is the part that remembers. It records events, decides which of them a given evaluation is permitted to see, and keys that partition by session.
Concern
Dogwood (the language)
AgentCore Policy (the service)
A way to look back
Supplies  temporal { } ,  formerly within ,  since within ,  count ,  sum 
n/a
The events
Defines their shape: the kinds  ::request ,  ::response ,  ::error , and the fields each carries
Records and stores them, on every Gateway invocation
Session scoping
Defines what a  pin  means and what guarantee it produces
Declares  pin sessionId  in the generated schema, and supplies its value from your header
Isolating callers
n/a in the AgentCore schema
Binds the session to the authenticated identity, as part of the session key
Surviving hops
n/a
Propagates session and caller identity inside the Workload Access Token
Storage and lifetime
None whatsoever
The event log, the 24 hour idle TTL, invalidation on policy change
Dogwood supplies the method. AgentCore Policy supplies the record and the key that partitions it. Taking the record first.

What the service records

You do not define the temporal schema. AgentCore generates it from the tools on the Gateway, so each tool's inputs and outputs become fields a temporal predicate can reference. The service also does the recording. On every Gateway invocation it appends to the session's history, and each action can produce up to three kinds of event.
Event kind
Recorded when
Carries
 ::request 
the request was authorized
the action's input fields
 ::response 
the tool returned successfully
inputs and outputs
 ::error 
the request was denied, or the tool errored
inputs (history-only)
Only  ::request  is a decision kind, meaning that ingesting one runs authorization and produces a verdict. The other two update engine state and produce no verdict of their own.
For our requirement, the row that matters is  ::response . It is written only when a tool actually succeeded, so the mere presence of a  present_refund_terms::response  in the history is proof that the disclosure step ran to completion and reported acceptance. A failed attempt would have been an  ::error  instead, which our rule will not match.
Seen that way, the conversation acquires a second column.
The agent's call
Recorded in the session
 present_refund_terms(customerId="C-77", orderId="ORD-8841") 
 present_refund_terms::request , then  present_refund_terms::response { orderId: "ORD-8841", accepted: true } 
 issue_refund(customerId="C-77", orderId="ORD-8841", amount=1499, note="Item arrived cracked.") 
decision point, evaluated against everything above
Along with those fields, every event the engine records is tagged with the session it belongs to. That tag is the key mentioned earlier, and it earns a section of its own.

The session key, and the pin

Recording events is not enough on its own. What turns them into a session, a private timeline the refund can be checked against, is one field the generated schema adds for you and that you can never write yourself: a  sessionId  that is pinned.
A pin does two things, and together they are the whole mechanism.
It scopes every rule automatically. You never write  sessionId  in a predicate, and you cannot, yet every  formerly within  you author is silently constrained to events from the same session. Isolation is not a discipline your policies have to keep; it is built into how they are evaluated.
Its value comes from you, once. The session is whatever you put in the  x-amzn-bedrock-agentcore-policy-session-id  header. AgentCore reads that header, validates it, and stamps it onto every event it records for the call. So the schema supplies the structure, every event carries a pinned session, and your header supplies the value. You configure neither the pin nor the matching, only the header.
Watch it decide, in one exchange:
  1. You call  present_refund_terms  on header  ...session-id: sess-A . The disclosure is recorded, tagged  sess-A .
  1. You call  issue_refund , still on  sess-A . Your  formerly within 1h present_refund_terms::response{ ... }  runs with  sess-A  supplied by the pin, matches the recorded disclosure, and the refund is allowed.
  1. Send that same refund on  sess-B  instead. The pin now demands  sess-B , the  sess-A  disclosure no longer matches, and the refund is denied.
That raises the obvious worry: the session id is a string you choose, so what stops one caller from reusing another's and inheriting their history? The identity does. On an authenticated gateway the session is keyed by the id and the caller's verified principal together, so two callers who send the same id still get separate timelines. The guessable half is scoped by the unforgeable half. Turn authentication off and that safety goes with it, which is why temporal policy on an unauthenticated gateway is advisory only.
Because the id is yours to choose, it is a design decision, not a detail. A fresh id per conversation is the usual choice.

The second requirement, in Dogwood

With the record and the key in hand, requirement 2 becomes a short policy.
permit (
principal,
action == AgentCore::Action::"RetailTarget___issue_refund",
resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/retail-gw"
)
when {
context.input.customerId == principal.getTag("customerId")
}
when temporal {
formerly within 1h AgentCore::Action::"RetailTarget___present_refund_terms"::response{
eventResource: resource,
output.orderId: context.input.orderId,
output.accepted: true
}
};
The  when temporal  block reads as a sentence: somewhere earlier in this session, within the last hour, the terms for this exact order were presented and the customer accepted. The identity check from requirement 1 rides along in the plain  when  block above it. Both must hold for the permit to apply, so a refund now needs a caller acting on their own account and an accepted disclosure for the order being refunded.
That acceptance cannot be faked into existence at the policy layer. It has to be a real  present_refund_terms  call that the Gateway authorized and the tool completed with  accepted: true , recorded in this caller's own session. The model can no longer talk its way to a refund; it has to have actually run the disclosure and gotten back a yes.
One honest limit is worth stating plainly. The policy guarantees the disclosure ran and reported acceptance. It cannot guarantee the acceptance was genuine — that depends on the tool setting  accepted  from something the customer actually did, a click or a spoken confirmation, rather than echoing the model's intent. Bind  accepted  to a real customer signal and a manipulated model cannot manufacture consent; let the model supply it and the control is only as strong as the model. The policy enforces the sequence; the tool is responsible for the truth of what it reports. This is the same trust boundary as any tool output, and it is why  accepted  is an output of the tool, never an argument the model passes in.
Sequence in one session
Decision
 issue_refund  with no terms shown
DENY
terms accepted for ORD-8841, then  issue_refund  for ORD-8841
ALLOW
terms accepted for ORD-8841, then  issue_refund  for ORD-9002
DENY, different order
terms shown for ORD-8841 but declined ( accepted: false )
DENY, acceptance required
 present_refund_terms  fails ( ::error ), then  issue_refund 
DENY, no  ::response  to match
 issue_refund  with a  customerId  that is not the caller's
DENY, the Cedar clause

Keep the prerequisite permitted

One subtlety decides whether this works at all. An action is recorded as a  ::response  only if it was permitted. So  present_refund_terms  needs its own permit, the same identity clause the other tools already get, or it lands in history as an  ::error , the  ::response  predicate never matches, and every refund is denied forever. The disclosure has to be allowed for its acceptance to count.

The third requirement, with a guardrail

3. The reason recorded with a refund must be free of profanity or abusive language.
The refund carries a  note : the customer's free-text reason for the refund. It is recorded on the refund and can be surfaced to staff and quoted back in the customer's history, so the retailer wants it kept civil, free of profanity and abuse. Whether a stretch of free text is abusive is not a comparison of fields, so Cedar cannot judge it, and it is not a question of history either. It is a judgment about the text on this one request, made as the request is decided.
That is what the third block is for. A guardrail is an information provider that AgentCore consults inline: at evaluation time it scores the text and hands back a confidence value, and the policy decides on that value. The provider available today is Bedrock Guardrails, and its content filter covers exactly this, with categories including  INSULTS  and  HATE . One part of this is probabilistic and one part is not, and the distinction is the whole point: the guardrail's verdict can vary, the same reason scoring differently across runs, but whether it runs at all does not, because the Gateway invokes it on every refund. Telling the model to keep things polite itself fails in the worse way, by skipping the check entirely.
forbid (
principal,
action == AgentCore::Action::"RetailTarget___issue_refund",
resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:111122223333:gateway/retail-gw"
)
when guardrails {
BedrockGuardrails::ContentFilter(["INSULTS", "HATE"], [context.input.note])
.maxConfidenceScore()
.greaterThan(decimal("0.4"))
};
Two things about the shape. It is a  forbid , not a  permit , because the guardrail expresses a prohibition: block the refund when the reason scores as abusive. And it is its own policy, separate from the temporal permit, invoked through a dedicated  when guardrails { }  block rather than an ordinary  when { } . The Gateway calls the Bedrock guardrail on demand, injects the returned score into the evaluation, and the  forbid  fires when  maxConfidenceScore()  across the listed categories clears the threshold. Because  forbid  overrides  permit , an abusive reason denies the call even when the caller is legitimate and the terms were accepted; the refund goes through once the reason is restated civilly.

Why these are separate policies

It is worth being precise about how the three requirements compose on  issue_refund , because getting it wrong fails quietly.
The identity and disclosure checks are both necessary conditions, so they are conjoined in one  permit , as two  when  blocks that must both hold. You cannot split them into two separate permits, because Cedar allows a request when any permit is satisfied, so two permits would mean either condition suffices on its own. Adding a permit loosens access; it never tightens it.
The guardrail is a prohibition, so it is a  forbid . Making it a permit would be worse than useless: it would offer another way to allow the refund rather than a way to block it. Prohibitions belong in  forbid , necessary conditions belong conjoined in a  permit , and  forbid  wins over both.

What you actually configure

A handful of things have to be true for these policies to work, and none of them involves configuring the pin.
The gateway must be authenticated, with either  CUSTOM_JWT  or  AWS_IAM . The session key combines the session ID with the authenticated identity, so two callers presenting the same session ID still receive isolated histories. Under  authorizerType=NONE  there is no identity to bind to, every caller sharing an ID shares one event stream, and temporal policy degrades to advisory.
The Gateway role needs two permissions beyond the basics.  bedrock-agentcore:GetWorkloadAccessToken  is required for temporal enforcement, even when outbound authorization uses IAM. Grant it whenever you attach temporal policies; without it, temporal enforcement does not work.  bedrock:InvokeGuardrailChecks  is required because the guardrail block calls the Bedrock Guardrails API on your behalf, using credentials derived from the gateway's execution role.
{
"Effect": "Allow",
"Action": [
"bedrock-agentcore:GetWorkloadAccessToken",
"bedrock:InvokeGuardrailChecks"
],
"Resource": "..."
}

Sharp edges

A few behaviors are worth knowing before the first deployment rather than after.
Pick  ::request  or  ::response  deliberately.  ::request  means the call was attempted;  ::response  means it completed successfully, and only  ::response  carries outputs. The disclosure rule uses  ::response  because it should require terms that were actually presented and accepted, not merely a call that was attempted.
A rule can match the request it is deciding. When a temporal condition names the same action it guards, the current request counts as one of the events it looks at, its own. Take a cool-down, "block a refund if another refund happened in the last minute," written as a  forbid . If you match  ::request , the refund being decided is itself a refund request, so the rule matches that, and the refund is blocked forever, from the very first call. Match  ::response  instead. A  ::response  is recorded only after a call finishes, and the current one has not finished yet, so it cannot match itself. Only a genuinely earlier, completed refund trips the rule.
Wait for a response before the call that depends on it. A  ::response  is recorded shortly after the call completes, so presenting the terms and issuing the refund back to back may find the history incomplete.
Updating a temporal policy ends live sessions. Recorded history only means something against the policies that were in force when the session began. Rather than decide against inconsistent data, the service ends the session, and the next request that reuses it fails with HTTP 409  ConflictException . Recovery means starting a new session, which begins empty. Plan for it before deploying in the middle of a busy afternoon.
Know the quotas. 25 temporal policies per engine, three temporal operators per policy, and a 24 hour maximum window.
Guardrail scores vary; the policy does not. Guardrails are non-deterministic, so the same text can score differently on different runs. The policy stays deterministic given a score, but the score itself is a model's judgment.
Roll out in  LOG_ONLY . It is supported on both the gateway attachment and individual policies, and it matters more here than for stateless policies because the failure mode of a wrong event kind is not an error but a rule that quietly never fires.  TemporalLatency  publishes to the  AWS/Bedrock-AgentCore  namespace, and with traces enabled the span attribute  aws.agentcore.policy.temporal.evaluation_invoked  distinguishes a policy that denied from a policy that never ran.

An asymmetry in your favor

Session-scoped limits are often described as soft controls, because the caller supplies the session ID and can always start a fresh one. That is true of  count  and  sum  caps. It is not true of the disclosure rule, and the difference comes down to which direction the rule points.
Rule shape
Effect of starting a fresh session
 permit ... when temporal { formerly ... } 
Empty history, nothing to match, deny. Rotation makes it stricter.
 forbid ... when temporal { count / sum ... } 
Counter resets, forbid does not fire, allow. Rotation is a real bypass.
The disclosure rule is a permit that demands a prior event, and a fresh session contains no disclosure, so the refund is denied. Session rotation cannot bypass a temporal requirement. It bypasses only temporal budgets.

Where this leaves us

Three requirements, three blocks. The identity check was always going to be Cedar, deciding on the one request in front of it. The disclosure-before-refund rule was headed for a sentence in a prompt asking the model to behave, and it is a deterministic policy now, decided against real session history. The reason check was headed for nobody, and it is a guardrail scored on demand.
What changed is not what can be computed, because none of these facts was hard to compute. What changed is that consulting them stopped being the model's decision. Cedar decides about the request in front of it. A guardrail asks a question about that request the moment it arrives. And a temporal policy decides about the conversation that led to it.
A reasonable place to begin is with one tool call. Find the one in your agent whose safety rests on the model choosing to do something first. Write down what must already be in the history before that call is allowed to run. That is your  temporal  block. Deploy it in  LOG_ONLY  and read the logs for a day.



References

Temporal policies are available in 16 AWS Regions at the time of writing, and guardrails in policy in a smaller set. Check the documentation for current availability.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article