Skip to main content

Module execution

Module execution 

Source
Expand description

Per-tool execution policy: which tool calls the proxy may send more than once, or answer without sending.

Retry, hedging, mirroring and failover can execute one client call several times; caching and coalescing can answer it without executing it. Each backend classifies its tools by Effect, and every one of these features checks the effect of the call it handles:

EffectRetry, hedgingFailover re-sendMirrorCache, coalescing
readyesyesyesyes
idempotentyesyesyesno
write (default)noonly when the primary never received the callnono

Tools no entry matches take the backend’s default_effect, which is write. A backend that enables any of these features applies them only to tools listed as read or idempotent; default_effect = "read" restores the behavior of releases before 0.9, where every tool was treated as read.

§Configuration

Configuration fragment: append this block after proxy.toml. No optional features required.

[[backends]]
name = "api"
transport = "http"
url = "http://localhost:8080"
default_effect = "write"        # default: unlisted tools are sent once

[backends.retry]
max_retries = 2

[backends.cache]
tool_ttl_seconds = 30

[[backends.tool_effects]]
tools = ["get_*", "list_*", "search"]
effect = "read"                 # retried, cached, coalesced

[[backends.tool_effects]]
tools = ["put_record"]
effect = "idempotent"           # retried, never cached

[[backends.tool_effects]]
tools = ["create_order"]
effect = "write"
idempotency_key = "request_id"  # retried only when the call carries one
  • tools lists backend-local names or wildcard patterns, with the syntax of expose_tools and hide_tools. The first matching entry wins.
  • idempotency_key names a backend argument (after param_overrides and inject_args). A write call with a non-empty value for it is treated as idempotent for that call, because the backend can deduplicate by key. It never enables caching or coalescing.
  • Upstream tool annotations (readOnlyHint, idempotentHint) are not used: a backend that marks a mutating tool read-only by mistake would be replayed silently.
  • Resources and prompts are unaffected; the policy covers tool calls.

§Failover

Failover re-sends a call only when the primary’s outcome is a backend failure (internal, server or transport error), never after a client error such as -32602 or a tool isError result. A write call without an idempotency key is re-sent only when it was rejected inside the proxy before reaching the primary: an open circuit breaker, a rate or concurrency limit, an outlier ejection, or a timeout while queued. A connection failure to the primary is not proof that the call was not received, so with only failover configured a write call is not re-sent; adding a circuit breaker lets writes fail over once it opens.

Changing tool_effects or default_effect requires a restart. Backends added at runtime carry no policy fields, so their tools are write.

Re-exports§

pub use crate::config::Effect;

Structs§

BackendEffects
One backend’s tool classification.
ExecutionPolicy
Every backend’s tool classification, addressed by namespaced names.