ChokepointInterceptor¶
chokepoint.core.interceptor
¶
ChokepointInterceptor — the integration point between Chokepoint and an agent.
Authorizes every tool call made by one agent. Construct one per agent (the
common pattern — see "Multi-agent" in CLAUDE.md), or share a registry across
many interceptors for centralized identity management.
Tool arguments and interceptor options travel separately. call() accepts the
tool's arguments as **kwargs for brevity, but session_id and domain are
named parameters of call() itself, so a tool that happens to declare an
argument by one of those names cannot be reached that way. Pass args={...}
to keep the two namespaces apart; the interceptor warns when it detects the
collision rather than silently dropping the argument.
ChokepointInterceptor
¶
ChokepointInterceptor(
policies=(),
mode="enforce",
*,
registry=None,
agent_id=None,
otel_tracer=None,
checksum_provider=None,
consent_provider=None,
max_sessions=DEFAULT_MAX_SESSIONS,
call_state=None,
ledger=None,
redactor=None,
)
Authorizes every tool call made by one agent.
The interceptor is what turns a list of Policy objects into enforcement:
it builds the ExecutionScope carrying caller identity, hands the call to
the evaluation engine, and records the outcome to the ledger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policies
|
Iterable[Policy]
|
Policies evaluated on every call. A policy with no
|
()
|
mode
|
Mode
|
|
'enforce'
|
registry
|
ChokepointRegistry | None
|
Shared identity source. With |
None
|
agent_id
|
str | None
|
Who this interceptor speaks for. Omitting it leaves
|
None
|
otel_tracer
|
Any
|
Tracer provider for this interceptor's spans only,
overriding the one set globally by |
None
|
checksum_provider
|
Callable[[], str] | None
|
Backs |
None
|
consent_provider
|
Callable[[str], bool] | None
|
Backs |
None
|
max_sessions
|
int | None
|
How many sessions' step counters to keep before evicting
the least recently used. |
DEFAULT_MAX_SESSIONS
|
call_state
|
CallState | None
|
Cross-call counters backing rate-limit and budget policies.
Private per interceptor by default; pass a shared |
None
|
ledger
|
ActionLedger | None
|
Where decisions are recorded. Defaults to the process-wide
|
None
|
redactor
|
Redactor | None
|
Scrubs arguments and free text at record time. Defaults to
the process-wide |
None
|
wrapped_tools
property
¶
wrapped_tools
A snapshot of the tools wrapped through this interceptor, by name.
call
¶
call(
tool_name,
func,
/,
*,
args=None,
session_id=_UNSET,
domain=_UNSET,
**kwargs,
)
Run func through this interceptor's policies as tool tool_name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_name
|
str
|
The name policies match on and the ledger records. Positional-only, so a tool argument may share the name. |
required |
func
|
Callable[..., Any] | ReversibleAction
|
The tool to call, or a |
required |
args
|
Mapping[str, Any] | None
|
The tool's arguments, as an explicit mapping. Use this
whenever a tool declares an argument named |
None
|
session_id
|
str
|
Groups calls for step counting, rate limits and budgets. |
_UNSET
|
domain
|
str | None
|
Ambient domain available to predicates as |
_UNSET
|
**kwargs
|
Any
|
The tool's arguments, for the common case where none of them collide with the parameters above. |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
Whatever |
Raises:
| Type | Description |
|---|---|
GuardBlocked
|
In |
acall
async
¶
acall(
tool_name,
func,
/,
*,
args=None,
session_id=_UNSET,
domain=_UNSET,
**kwargs,
)
Async sibling of call(), for an async def tool (or a
ReversibleAction with an async do_fn). Same arguments, same
semantics, same ledger and OTEL behavior.
wrap_tool
¶
wrap_tool(tool_name, func)
Return a callable wrapping func through self.call/self.acall
(auto-detected — see _is_async_tool), suitable for registering in
place of the original tool on an agent.
Everything the wrapper is called with is forwarded as tool arguments
via args=, never as interceptor options: an agent framework invoking
a wrapped tool is passing the model's arguments, so a tool parameter
named session_id or domain must reach the tool intact.
use
¶
use(agent)
One-line integration point: agent.use(interceptor) ends up calling
this. Delegates to chokepoint.adapters.base.wrap for tool auto-discovery.