Skip to main content
The bridge is the client-side counterpart to the gateway. It provides functions to route tool execution through the gateway while preserving custody chains, agent state, and trace context across network boundaries. Bridge functions are exported from 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:
The helper combines 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, the AgentManager makes gateway calls seamless:
The manager.invoke() call automatically:
  1. Resolves the gateway hop config from app.hops
  2. Builds the agent state from the current context
  3. Injects auth headers, idempotency keys, and cause context (per automation flags)
  4. Issues the gateway call with full custody chain
For the full bridge options reference, see Bridge Options Reference.