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

**URL:** <https://forum.langchain.com/t/tool-design-for-agents-that-quote-on-chain-prices-return-the-call-let-the-agents-own-rpc-run-it/4882>\
**Category:** Talking Shop\
**Created:** [October 27, 2026, 4:25pm UTC](https://forum.langchain.com/t/tool-design-for-agents-that-quote-on-chain-prices-return-the-call-let-the-agents-own-rpc-run-it/4882 "2026-10-27T16:25:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BlazePhoenix](https://avatars.discourse-cdn.com/v4/letter/b/9de0a6/32.png) [@BlazePhoenix](https://forum.langchain.com/u/BlazePhoenix)\
**Post date:** [October 27, 2026, 4:25pm UTC](https://forum.langchain.com/t/tool-design-for-agents-that-quote-on-chain-prices-return-the-call-let-the-agents-own-rpc-run-it/4882/1 "2026-10-27T16:25:40Z")

</div>

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](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](https://blazephoenix.xyz/llms.txt)

---

<div class="post-metadata">

**Author:** ![Zealynx](https://avatars.discourse-cdn.com/v4/letter/z/e480ec/32.png) [@Zealynx](https://forum.langchain.com/u/Zealynx)\
**Post date:** [October 28, 2026, 2:20pm UTC](https://forum.langchain.com/t/tool-design-for-agents-that-quote-on-chain-prices-return-the-call-let-the-agents-own-rpc-run-it/4882/2 "2026-10-28T14:20:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rayyanmaan](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/rayyanmaan/32/3749_2.png) [@rayyanmaan](https://forum.langchain.com/u/rayyanmaan)\
**Post date:** [November 8, 2026, 4:32am UTC](https://forum.langchain.com/t/tool-design-for-agents-that-quote-on-chain-prices-return-the-call-let-the-agents-own-rpc-run-it/4882/3 "2026-11-08T04:32:55Z")

</div>

@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?
