sec0-sdk/middleware.
callToolViaGateway
The standard bridge function for routing tool calls through the gateway:
Parameters
AP2 Mandate Forwarding
Identity Context Forwarding
callToolViaGatewayWithAgent
A convenience wrapper that accepts an agent block instead of a raw agentState:
buildIdempotencyKey
Generate a deterministic idempotency key for a tool call:
runId, nodeId, toolAtVersion, and a short digest of args. Pass a stable runId and nodeId when you want deterministic replay protection; if runId is omitted, the helper generates one and the result changes across runs.
Using Bridge with Instrumentation Decorators
When using decorators, theAgentManager makes gateway calls seamless:
manager.invoke() call automatically:
- Resolves the gateway hop config from
app.hops - Builds the agent state from the current context
- Injects auth headers, idempotency keys, and cause context (per automation flags)
- Issues the gateway call with full custody chain