Skip to content

feat(payments): add MPP, x402 upto, and Quick Create support - #643

Merged
aidandaly24 merged 9 commits into
mainfrom
feat/payments-ga
Aug 18, 2026
Merged

feat(payments): add MPP, x402 upto, and Quick Create support#643
aidandaly24 merged 9 commits into
mainfrom
feat/payments-ga

Conversation

@aidandaly24

@aidandaly24 aidandaly24 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds three incremental payment capabilities to the AgentCore Python SDK.

Machine Payments Protocol (MPP)

  • Parses WWW-Authenticate: Payment challenges and selects one compatible with the configured payment instrument.
  • Rejects malformed challenges before selection so they cannot suppress valid MPP or x402 alternatives.
  • Supports EVM, Tempo, and Solana charge methods with network-preference and expiry handling.
  • Routes MPP requests through ProcessPayment and returns Authorization: Payment <credential>.
  • Supports optional buyer_pays_gas_fees.
  • Falls back to x402 when a response advertises both protocols and no MPP challenge is satisfiable.
  • Extends the Strands plugin and LangGraph middleware with automatic MPP detection, settlement, retry, and receipt handling.
  • Reuses an already-generated credential when LangGraph retries the paid request, preventing duplicate payment submission.

x402 upto

  • Adds the optional permit2_allowance_limit integration setting.
  • Passes the configured allowance as cryptoX402.permit2AllowanceLimit only for a selected upto requirement.
  • Validates the Smithy-compatible positive ASCII integer shape and threads the setting through Strands and LangGraph.

PaymentConnector Quick Create

  • Adds PaymentConnectorProvisionMode with MANUAL and QUICK_CREATE.
  • Accepts the exported enum directly and threads its value through PaymentClient.create_payment_connector.
  • Supports an empty credential-provider configuration list for Quick Create.
  • Surfaces the live authorizationUrl from create and get responses while the connector is PENDING_AUTHENTICATION.
  • Rejects wait_for_ready=True for Quick Create because user consent must happen before the connector can become ready.
  • Adds the Quick Create connector statuses PENDING_AUTHENTICATION, PROVISIONING, AUTHENTICATION_EXPIRED, and AUTHENTICATION_FAILED.
  • Preserves existing manual behavior by omitting provisionMode when it is not supplied.
  • Preserves positional compatibility for the existing wait configuration arguments.

Release Dependencies

This change requires boto3>=1.43.72 and botocore>=1.43.72, the first published model release containing:

  • Native MPP input/output shapes.
  • permit2AllowanceLimit.
  • PaymentConnector provisionMode, Quick Create statuses, and authorizationUrl.

The package dependency floor and lockfile enforce that requirement.

Verification

  • Focused regression suite: 495 passed.
  • Full Payments suite: 901 passed, 9 skipped.
  • Full SDK suite: 3360 passed, 10 skipped, 4 xpassed.
  • Pre-commit and pre-push gates passed, including Bandit and full coverage.
  • Live mpp.dev detection/header-preservation tests passed.
  • MPP integration module with current Botocore models: 8 passed, 6 resource-dependent skipped.
  • uv build produced the wheel and source distribution.
  • Final wheel installed successfully against the exact minimum Boto3/Botocore 1.43.72 versions.
  • Local Griffe analysis found no breaking changes.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

rajuans and others added 3 commits August 17, 2026 14:35
Add MPP alongside the existing x402 protocol in ProcessPayment. MPP servers
answer 402 with WWW-Authenticate: Payment challenges; the SDK selects the one
challenge the payment instrument can satisfy and mints an Authorization header.

Core:
- mpp.py: parse WWW-Authenticate challenges and select one (charge intent,
  unexpired, method the instrument satisfies: evm/tempo->ETHEREUM,
  solana->SOLANA; ordered by NETWORK_PREFERENCES, tiebroken on soonest expiry
  then server order). The selected challenge is forwarded verbatim so the
  challenge HMAC stays valid, and unknown auth-params are preserved per the
  spec's "unknown parameters must be ignored by clients" rule.
- generate_payment_header auto-detects the protocol from the 402 and returns
  {"Authorization": "Payment <token>"} for MPP; the x402 path is unchanged.
  When a 402 advertises both protocols and no MPP challenge is satisfiable, it
  falls back to a usable x402 requirement rather than failing the payment. The
  fallback is limited to selection failures (pre-submission); a failure after
  the payment was submitted propagates, so a buyer is never charged twice.
- Optional buyer_pays_gas_fees passthrough (MPP buyerPaysGasFees). Requires None
  or an actual bool and forwards it unchanged — values are not coerced, since
  bool("false") is True and would silently authorize wallet charges.

Integrations:
- Strands plugin and LangGraph middleware detect MPP 402s (WWW-Authenticate) and
  settle them; buyer_pays_gas_fees is exposed on the shared config.
- has_mpp_challenge delegates to the parser so detection and parsing cannot
  disagree (a prefix check missed "Bearer ..., Payment ..." and falsely matched
  a hypothetical PaymentXYZ scheme).

Notes:
- Submitting MPP requires a botocore release that models the MPP ProcessPayment
  shapes. On an older release botocore rejects the request client-side with
  'Unknown parameter in paymentInput: "mpp"'. The integ tests surface this
  dependency explicitly so it is diagnosed as an out-of-date botocore rather
  than an SDK bug.
- Solana localnet is intentionally not aliased to solana-testnet: it is a
  distinct local RPC/Surfpool environment, and aliasing let a local-only
  challenge outrank a payable devnet challenge. Unmapped networks are unranked
  rather than misranked — still selectable when they are the only option.

Tests: unit coverage for parsing, selection, manager routing, dual-protocol
fallback, gas-fee validation, and both integrations; integ tests gated on TEST_*
env vars, including live checks against the mpp.dev endpoint.

Verified against the live mpp.dev 402 and prod ProcessPayment (request shape
accepted; end-to-end settlement pending account MPP entitlement).

Co-authored-by: Raju Ansari <ansraju@amazon.com>
Adds an opt-in permit2_allowance_limit knob so the Strands plugin and LangGraph
middleware can grant a Permit2 allowance for the x402 "upto" scheme. When set,
ProcessPayment submits the one-time on-chain approve to the Permit2 contract
before signing; when unset (default), the exact-scheme flow is unchanged.

- manager.generate_payment_header: new optional permit2_allowance_limit param,
  injected at the cryptoX402 level (sibling of version/payload) only when set.
- integrations config: new permit2_allowance_limit field (decimal string in the
  asset's smallest denomination) with positive-integer validation in
  __post_init__; None by default.
- Strands plugin + LangGraph middleware: thread config.permit2_allowance_limit
  into generate_payment_header.
- Tests: manager injection + omission cases; config validation (valid 1 USDC /
  uint256-max unlimited, reject 0/-1/1.5/abc/empty/non-string).

upto + permit2AllowanceLimit are already merged on the service and public model
mainline. This mirrors the buyer_pays_gas_fees config-knob pattern.
@aidandaly24
aidandaly24 requested a review from a team August 17, 2026 14:40
@github-actions github-actions Bot added the size/xl PR size: XL label Aug 17, 2026
@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

✅ No Breaking Changes Detected

No public API breaking changes found in this PR.

@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 17, 2026
@aidandaly24
aidandaly24 deployed to auto-approve August 17, 2026 16:35 — with GitHub Actions Active
@aidandaly24
aidandaly24 deployed to auto-approve August 17, 2026 16:35 — with GitHub Actions Active
@aidandaly24
aidandaly24 deployed to auto-approve August 17, 2026 16:35 — with GitHub Actions Active
@aidandaly24
aidandaly24 deployed to auto-approve August 17, 2026 16:35 — with GitHub Actions Active
@aidandaly24
aidandaly24 deployed to auto-approve August 17, 2026 16:35 — with GitHub Actions Active
@aidandaly24
aidandaly24 deployed to auto-approve August 17, 2026 16:35 — with GitHub Actions Active
@aidandaly24
aidandaly24 deployed to auto-approve August 17, 2026 16:35 — with GitHub Actions Active
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Aug 17, 2026
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 17, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Aug 17, 2026
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 17, 2026
aidandaly24 and others added 3 commits August 17, 2026 17:20
…onnector

Thread a provision_mode arg through PaymentClient.create_payment_connector to
the CreatePaymentConnector request (provisionMode), and surface the
authorizationUrl the service returns for a QUICK_CREATE connector in
PENDING_AUTHENTICATION. Add the PaymentConnectorProvisionMode enum
(MANUAL/QUICK_CREATE) and the QUICK_CREATE connector statuses
(PENDING_AUTHENTICATION, PROVISIONING, AUTHENTICATION_EXPIRED,
AUTHENTICATION_FAILED) to constants, exported from the package.

MANUAL behaviour is unchanged: provisionMode is omitted from the request when
provision_mode is not supplied, and authorizationUrl is only added to the
result when present.

Signed-off-by: ykas11 <vikas.k.walunj@gmail.com>
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 18, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Aug 18, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Aug 18, 2026
@aidandaly24 aidandaly24 changed the title feat(payments): add MPP and x402 upto support feat(payments): add MPP, x402 upto, and Quick Create support Aug 18, 2026
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 18, 2026
jariy17
jariy17 previously approved these changes Aug 18, 2026
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 18, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Aug 18, 2026
@github-actions github-actions Bot added the size/xl PR size: XL label Aug 18, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Aug 18, 2026
@aidandaly24
aidandaly24 merged commit 66a68e3 into main Aug 18, 2026
35 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xl PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants