fix: scope rail balance lookup + surface merchant error.code in CLI envelope#18
Merged
vvillait88 merged 2 commits intomainfrom May 5, 2026
Merged
Conversation
…nvelope Two findings from the agents.agentscore.sh redemption-flow smoke today. 1. selectRail used to call listHeldCandidates with no chain filter, so every `pay --chain X` ran a Promise.all over base + solana + tempo. With the public Solana mainnet RPC's 40-req/10s cap, legitimate tempo + base settles intermittently surfaced as `rpc_error: solana mainnet RPC call failed: HTTP error (429): Too Many Requests`. listHeldCandidates now takes an optional filterChain and selectRail forwards chainOverride through, so explicit overrides do exactly one balance query. 2. The merchant_error wrapper printed only "Merchant returned 400 Bad Request", discarding the structured `error.code` / `error.message` the merchant returns in its 4xx envelope. An agent following 4xx recovery instructions had to re-curl manually to learn whether the failure was, e.g., codes_not_accepted vs product_not_found vs unsupported_jurisdiction. The CLI message now lifts `error.code` and `error.message` (when present) into the display string and into the error.extra block; falls back to bare status text when the body isn't envelope-shaped. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Carries the rail-balance scoping + merchant_error.code surfacing fixes from this PR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two findings from today's redemption-flow smoke against `agents.agentscore.sh`.
1. `selectRail` over-fetched balances
`listHeldCandidates` used to query every held chain via `Promise.all`, even when the user passed an explicit `--chain`. With the public Solana mainnet RPC's 40-req/10s cap, multiple settles in quick succession produced
on legitimate tempo + base settles. Threaded `filterChain` through `listHeldCandidates` and `selectRail` forwards `chainOverride` so an explicit override now does exactly one balance query.
2. `merchant_error` swallowed `error.code`
The wrapper printed only "Merchant returned 400 Bad Request" and stuffed the body into `error.extra.body`. The structured `error.code` / `error.message` the merchant returns in its 4xx envelope was discarded from the human-readable message. An agent reading recovery hints had to re-curl to find out whether the failure was `codes_not_accepted` vs `product_not_found` vs `unsupported_jurisdiction`. Now lifts `error.code` and `error.message` (when JSON-envelope-shaped) into the CLI display string and into `error.extra` as `merchant_code` / `merchant_message`. Falls back gracefully when the body isn't envelope-shaped.
Test plan
🤖 Generated with Claude Code