Skip to navigation
AgentsAgentBase

set_tool_resend_dedupe

View as MarkdownOpen in Claude

Turn the dedupe of transport retries on or off. It’s on by default.

SignalWire sends a tool request again, with the same tool_call_id, after a timeout, a failed connection, or a 5xx response, so a slow tool could run twice. The dedupe answers such a retry with the first attempt’s result, and a retry that arrives while the first attempt is still running waits for it.

  • A retry is a request with the same call_id, tool_call_id, and function name. A call the model makes again has a new tool_call_id and runs.
  • A request without a tool_call_id always runs.
  • A handler that raises is answered with a result saying the tool failed before it finished, and that result is kept: a retry gets it, and the handler doesn’t run again. An exception raised in middleware, including a ToolRefusal, isn’t kept, so a retry runs the call again.
  • The underlying signalwire.core.tool_middleware.ResendDedupe stores results for ttl seconds (default 600.0) and keeps up to max_entries results (default 1024).
  • The record is kept in the agent’s process. With several processes or replicas, a retry that reaches another one runs the tool again, so make tools that change things safe to run twice.

The dedupe runs first, before any middleware.

Parameters

enabled
boolDefaults to True

False runs every request, retries included.

Returns

AgentBase — Self for method chaining.

Example

from signalwire import AgentBase
agent = AgentBase(name="idempotent", route="/idempotent")
agent.set_tool_resend_dedupe(False) # run every request, retries included
agent.serve()