feat(mcp): semantic revert decoding and actionable agent remediation - #2429
feat(mcp): semantic revert decoding and actionable agent remediation#2429GreatSage-dev wants to merge 1 commit into
Conversation
Surface structured failure codes and actionable remediation guidance in simulation preflight and MCP dry-run errors so autonomous agents can self-heal transaction reverts without human intervention.
About the
|
This pull request needs an issue or ticket referenceNo issue or ticket reference was found in the title, description, or branch name. Outside contributions start with an issue. Open one, wait for a maintainer to apply the This check reruns on every push and edit, and again on its own once a referenced issue is labelled |
What this changes
Adds semantic EVM revert decoding, Solidity panic translation, and structured, plain-English remediation guidance to KeeperHub's simulation engine and Model Context Protocol (MCP) dry-run diagnostics.
When an autonomous AI agent or execution script simulates a transaction that reverts (e.g. ERC-20 allowance shortfall, contract pause gate, AccessControl permission rejection, or arithmetic division by zero), KeeperHub previously surfaced cryptic revert strings or unparsed hexadecimal data requiring downstream clients to guess the failure root cause.
This PR upgrades simulation preflight errors across
execute_transfer,execute_contract_call, andexecute_check_and_execute:SimulateFailureCodeliterals:insufficient_allowance(with structuredallowance,neededAllowance,spender)insufficient_token_balancecontract_pausedunauthorizedreentrancy_blockedsafe_signature_invalidpanic_*(e.g.panic_divisionbyzero,panic_arithmeticoverflowunderflow)"ERC20: transfer amount exceeds balance","ERC20: insufficient allowance","Pausable: paused","Ownable: caller is not the owner") to structured codes and remediation."Call approve() on token contract 0x... with spender 0x... for at least 1000000000000000000 units before retrying this transaction.") directly in the HTTP 400 simulation envelope and MCP tool error hints, with 500-char non-truncating bounds and control-character injection protection.Zero breaking changes: HTTP response codes (400 Bad Request), status headers, and existing fields (
wouldRevert,revertReason,failureKind) remain 100% intact.Scope
One cohesive, tightly-scoped change: widening KeeperHub's preflight failure classification and threading actionable remediation through
failureFromPreflightError(),simulationFailureFromError(), andbuildSimulationFailureHint(). All parts are strictly interdependent.How it was verified
Added and expanded 2 Vitest unit test suites covering the new classification, panic lookup, string-revert matching, remediation generators, untrusted input protection, and MCP tool formatting: