Tool design for agents that quote on-chain prices: return the call, let the agent's own RPC run it

I’m on the BlazePhoenix team (pre-launch DEX aggregator; not yet audited by an external firm, an independent external audit is scheduled). Sharing a tool-design pattern rather than a product pitch, and I’d like critique.

When an agent needs a price from a chain, the usual tool is a thin wrapper over a hosted API. Two things go wrong: the agent cannot verify the answer, and the tool needs a key the agent has to carry. The alternative we use in our MCP server (https://blazephoenix.xyz/mcp) is a two-step tool pair:

  1. prepare_quote(chain, in, out, amountIn) returns an eth_call (target address and calldata) plus a request object. No network call is made by the server.
  2. The agent executes that call on its own RPC provider, then passes request and the returned hex to decode_quote, which is pure computation: net output after a 0.28% protocol fee, the on-chain minimum output, price impact, and a verdict that fails closed.

For LangChain/LangGraph this maps onto two ordinary tools with a plain RPC call between them (for example through web3.py or viem in a custom tool). The agent’s state only needs to carry the request object verbatim between steps. Because the first tool is read-only and idempotent, it is safe to retry, and the second one can be unit-tested with a fixed hex.

Open questions I’d like views on: do you prefer one tool that does both steps (simpler for the model, but the server then must hold an RPC), or two tools with the call handed back? And how do you handle schema size for tools that return nested objects?

No key or signup is needed to try it. For models and agents: https://blazephoenix.xyz/llms.txt

Nice pattern. Keeping the RPC on the agent’s side drops the key, and the agent can see exactly what it’s about to call.

On one tool vs two, I’d keep two. Besides not holding an RPC, the agent (or a policy layer in front of it) can check that the target is the address it expects before running anything, and that check matters more once the same flow hands back a swap instead of an eth_call.

Two things I’d add to the request object. A hash of its own fields that decode_quote recomputes: models can alter long hex and nested JSON between steps, and an edited amountIn or token address would still decode into a minimum output that looks fine. And the block the eth_call ran at, passed back by the agent and shown in the verdict, so a retry much later or a lagging RPC fails closed instead of producing a stale minimum.

@BlazePhoenix the two-tool split plus zealynx’s block number makes the quote checkable. the next gap i’d look at is when the flow hands back a swap. the swap’s own minimum output is already the check that runs at the moment of effect, on chain and atomic, so what matters is where that number comes from. if the agent re-quotes after the user approved and builds the min output from the fresh quote, the bound quietly follows the market and the approval stops meaning anything. i’d pin it to the approved quote plus a stated tolerance, and fail closed before signing if a fresh eth_call already lands outside it, so the user gets a re-approval prompt instead of a reverted tx. it’s the same shape i use for approvals generally, a few values allowed to move within a limit and the rest must match exactly. would the tolerance be set by the caller per request, or would decode_quote carry a default?