Skip to content

Print x402 settlement and Bazaar status - #1493

Merged
asim merged 3 commits into
mainfrom
x402-print-settlement-status
Sep 5, 2026
Merged

Print x402 settlement and Bazaar status#1493
asim merged 3 commits into
mainfrom
x402-print-settlement-status

Conversation

@asim

@asim asim commented Sep 5, 2026

Copy link
Copy Markdown
Member

Why

We need to distinguish three different outcomes when testing M3O Bazaar discovery:

  1. the tool call succeeded
  2. the x402 payment actually settled
  3. the server exposed an EXTENSION-RESPONSES acknowledgement for Bazaar

Until now mu x402 call printed only the tool result, so a successful paid call gave no visibility into settlement or discovery status.

What

  • add PayAndCallMCPWithReceipt, preserving the existing PayAndCallMCP text-only API
  • capture the paid retry response headers
  • decode PAYMENT-RESPONSE into the settlement transaction/network
  • surface raw EXTENSION-RESPONSES when present
  • make mu x402 call print settlement details and extension status before the tool result
  • add a regression test for both payment receipt and Bazaar processing response

If the server does not expose EXTENSION-RESPONSES, the CLI says extensions: none returned by server explicitly rather than silently hiding the missing diagnostic.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-05T05:39:49.490075Z 2fab519 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@asim
asim merged commit 925bd5c into main Sep 5, 2026
1 of 2 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2fab519caf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

req.Header.Set("Authorization", h)
}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Run gofmt on the changed client

The closing brace is misindented, and gofmt -l service/wallet/x402client.go reports this file. The repository's CI explicitly fails whenever gofmt -l . produces output, so this commit cannot pass CI until the file is formatted.

AGENTS.md reference: AGENTS.md:L170-L175

Useful? React with 👍 / 👎.

Comment thread internal/cli/x402pay.go
}
fmt.Println(out)

if out.Settlement != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Report extension status independently of settlement

When a paid retry returns EXTENSION-RESPONSES but omits or malforms PAYMENT-RESPONSE, PayAndCallMCPWithReceipt preserves the extension response while this outer condition suppresses it. That makes the Bazaar acknowledgement invisible precisely when the three outcomes are meant to be diagnosed independently; print the extension status outside the settlement-only branch.

Useful? React with 👍 / 👎.

if err := json.Unmarshal(raw, &settle); err != nil {
return nil
}
return &settle

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject unsuccessful receipts before reporting settlement

If an x402 server returns a valid SettleResponse with success:false, this parser still returns a non-nil settlement, causing the CLI to print settled: even though the payment failed. Validate settle.Success (and surface its failure reason) before treating the response as proof of settlement.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant