Build Your Own Receipt Gateway in 28 Lines of Python
说明与用途
使用28行Python代码构建自己的收据网关,生成工具执行的加密证明,确保执行完整性。
问题
Agents can claim tool execution without verifiable proof, making it hard to trust their outputs.
结果
A lightweight, 28‑line Python implementation that mints verifiable receipts for every tool call, ensuring execution integrity without external services.
工作流
- 1. Wrap the tool dispatch in execute_with_receipt, passing tool name, arguments, and the tool function.
- 2. The executor runs the tool and obtains the result.
- 3. Immediately after execution, generate a receipt containing a UUID, tool name, SHA‑256 hashes of canonicalized arguments and result, and a timestamp.
- 4. Store the receipt and result in an append‑only log (RECEIPT_LOG).
- 5. Return the result and receipt ID to the agent.
- 6. To verify, fetch the receipt by UUID and compare the SHA‑256 hash of the claimed result with the stored hash using verify_receipt.
证据
The receipt has to be minted by the thing that runs the tool, not the thing that talks about running the tool.
Wrap your tool dispatch in execute_with_receipt, and every call your agent makes now carries independently checkable proof.
- 记录日期: 2026-09-22T00:00:37.033Z