strands.vended_interventions.dogwood.dogwood
Dogwood authorization intervention handler.
DogwoodValue
Section titled “DogwoodValue”A value Dogwood accepts in an event. \{"__entity": EntityRef} and \{"__decimal": "1.50"}
are its tagged escapes.
EntityRef
Section titled “EntityRef”class EntityRef(TypedDict)Defined in: src/strands/vended_interventions/dogwood/dogwood.py:46
A reference to an entity by type and id.
EntityInput
Section titled “EntityInput”class EntityInput(TypedDict)Defined in: src/strands/vended_interventions/dogwood/dogwood.py:53
An entity supplied to a decision: its id, and the attributes and parents a policy reads.
ENRICHED_GROUP
Section titled “ENRICHED_GROUP”The one context group a context_enricher can add.
INPUT_GROUP
Section titled “INPUT_GROUP”The context group carrying a tool call’s arguments. Only a tool-call action declares it.
SYSTEM_GROUP
Section titled “SYSTEM_GROUP”The context group Dogwood’s MCP schema template declares for the wall clock.
PrincipalResolver
Section titled “PrincipalResolver”Resolves a principal from invocation_state. Return None to deny (fail-closed).
ContextEnricher
Section titled “ContextEnricher”Adds fields to context.session. Receives {‘tool_name’, ‘tool_input’, ‘invocation_state’}.
EventGroups
Section titled “EventGroups”Event field groups, group -> \{field -> value}.
DogwoodAuthorization
Section titled “DogwoodAuthorization”class DogwoodAuthorization(InterventionHandler)Defined in: src/strands/vended_interventions/dogwood/dogwood.py:91
Dogwood authorization intervention handler.
Evaluates a Dogwood policy set before each tool call, and records the result afterward so temporal rules work.
A call on tool search is decided as action Action::"search" — qualified by the schema’s
namespace when it has one — against the configured principal and the gateway resource, with the
tool arguments in context.input. Arguments are compared as the model emitted them: an enum
parameter as a string, a number as a Cedar decimal, so a condition on one reads
context.input.amount.lessThan(decimal("10.0")).
One instance is one ordered temporal history, with every predicate pinned to the deciding
principal, so many principals can share it without their histories mixing. History is never
pruned; :meth:reset drops every principal’s at once. A result’s fields are not recorded, only
that the call returned, so a predicate on one type-checks and then never matches.
Dogwood checks a call against the schema before it will decide, so an argument the tool does not declare — or a required one the model left out — denies the call. The denial names the mismatch, which a model can act on when it retries.
Requires the dogwood-aws package.
Example::
dogwood = DogwoodAuthorization( policies=‘permit(principal, action == Action::“search”, resource);’, tools=[search_tool], ) agent = Agent(model=model, tools=[search_tool], interventions=[dogwood])
on_error
Section titled “on_error”@propertydef on_error() -> OnErrorDefined in: src/strands/vended_interventions/dogwood/dogwood.py:126
What to do when this handler throws.
__init__
Section titled “__init__”def __init__(*, policies: str, tools: list[AgentTool | ToolSpec] | None = None, action_schema: str | None = None, entities: list[EntityInput] | None = None, namespace: str | None = None, principal: EntityRef | None = None, principal_resolver: PrincipalResolver | None = None, context_enricher: ContextEnricher | None = None, on_error: OnError = "throw") -> NoneDefined in: src/strands/vended_interventions/dogwood/dogwood.py:130
Initialize the Dogwood authorization handler.
Arguments:
-
policies- Dogwood policy text, or a path to a.dwfile on disk. -
tools- Tools the action schema is generated from, as the tools themselves or their specs. -
action_schema- Cedar action schema text, or a path to a.cedarschemafile. Generated fromtoolswhen omitted. The namespace, the default principal and the resource are read from it, so it must declare its user entity asUserand its resource entity asResource. -
entities- Entities supplied to every decision — attributes and hierarchy a policy reads. Requiresaction_schema: a generated schema declares its entities with no attributes and no membership, so an entity carrying either fails conformance at decision time and denies every call. -
namespace- Namespace for a generated action schema, qualifying every action and entity it declares, as inAcme::Action::"search"andAcme::User. Omit it and they are declared at the top level. Only valid withtools. -
principal- Static principal,User::"anonymous"by default, qualified by the schema’s namespace when it declares one. Against a generated schema the type must beUser. Mutually exclusive withprincipal_resolver. -
principal_resolver- Dynamic principal resolver for multi-tenant agents. Return None to deny (fail-closed). Mutually exclusive withprincipal. -
context_enricher- Adds fields to thesessiongroup of the Cedar request context, read by a policy ascontext.session.tenant, forinvocation_statevalues a tool’s arguments do not carry. Dogwood checks a request’s context against the action’s context type, so this requires anaction_schemadeclaringsessionon every tool action. The fields reach awhencondition only, never a temporal predicate. -
on_error- What to do whenprincipal_resolverorcontext_enricherraises:'throw'(default) re-raises,'deny'denies the tool call (fail-closed).Warning:
'proceed'is fail-open — the tool runs with no authorization check. A failed Dogwood decision always denies regardless of this setting.
Raises:
ValueError- If neitheraction_schemanortoolsis supplied, ifprincipalandprincipal_resolverare both, ifentitiesis non-empty withoutaction_schema, ifnamespaceis supplied with one or is not a legal Cedar namespace, ifprincipalis not of the type a generated schema declares, ifcontext_enricheris supplied against a schema that declares nosessioncontext group, or if the policy set does not type-check against the schema.DogwoodError- If the policy set, the schema, or a tool manifest fails to parse.
before_tool_call
Section titled “before_tool_call”def before_tool_call(event: BeforeToolCallEvent, **kwargs: Any) -> Proceed | DenyDefined in: src/strands/vended_interventions/dogwood/dogwood.py:248
Decide a tool call against the policy set, and record the request event.
after_tool_call
Section titled “after_tool_call”def after_tool_call(event: AfterToolCallEvent, **kwargs: Any) -> ProceedDefined in: src/strands/vended_interventions/dogwood/dogwood.py:305
Record the result of a call this handler allowed, so temporal rules can read it.
def reset() -> NoneDefined in: src/strands/vended_interventions/dogwood/dogwood.py:346
Drop accumulated temporal history.
Clears every principal this instance has decided for, not one session’s history.