aws / aws/bedrock-agentcore-sdk-python

Add post-payment delivery validation without retrying possible spend

Aperta
#651 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Python
Stelle
761
Fork
147
Merge medio
1g 23h
PR unite (30g)
7

Descrizione

**Is your feature request related to a problem? Please describe.**

The AgentCore Payments LangGraph middleware and Strands plugin can detect a
payment challenge, obtain a credential, retry the tool, and return the paid
result. There is no opt-in application-output gate between that paid retry and
result promotion.

That leaves a buyer unable to reject malformed or contract-invalid application
output while preserving two facts: a payment credential may already have spent,
and the middleware must not automatically pay or retry again.

A credential-free reproduction uses a fake `PaymentManager` and a local tool:

1. The first tool call returns an x402 or MPP payment challenge.
2. The fake manager returns one payment credential.
3. The paid retry returns HTTP 200 with malformed application output.
4. The current middleware returns that output through LangGraph sync,
LangGraph async, or Strands without a buyer-owned validation hook.

No AWS account, wallet, signature, or live payment is needed to reproduce the
control-flow gap.

**Describe the solution you'd like**

Add an optional post-payment delivery callback to the existing integrations.
When configured, it should:

- receive the raw paid result plus an immutable snapshot of the selected
payment requirement or challenge;
- run after exactly one credential generation and one paid retry;
- preserve the original paid result and explicit possible-spend evidence when
validation rejects or raises;
- return a deterministic failure through the native LangGraph or Strands path;
- set native retry behavior so the same result cannot trigger another automatic
payment attempt; and
- leave current behavior unchanged when the callback is absent.

Protocol-native evidence should retain its authority label. An x402 Payment
Response or MPP Receipt can be exposed as observed, unverified evidence. Calling
settlement verified should require a separate protocol-specific verifier that
reconciles the native transaction or reference against the frozen payment
terms.

The three public integration paths should share the same semantics:

- LangGraph `wrap_tool_call`
- LangGraph `awrap_tool_call`
- Strands `after_tool_call`

**Describe alternatives you've considered**

- Tool-specific wrappers duplicate payment middleware and can lose the selected
challenge and possible-spend context.
- LLM inspection after the result returns is not a fail-closed output contract.
- Requiring a seller to echo protocol, network, scheme, challenge or offer ID,
amount, asset, payee, credential digest, and transaction in one custom bag is
not portable. Standard x402 settlement responses and MPP receipts do not echo
that complete set, and seller-authored echoes are not independent settlement
verification.

**Additional context**

Current source references:

- [AgentCore LangGraph payment flow](https://github.com/aws/bedrock-agentcore-sdk-python/blob/826416a2493131f79137c77575bc1e10b9589d56/src/bedrock_agentcore/payments/integrations/langgraph/README.md)
- [x402 settlement response shape](https://github.com/coinbase/x402/blob/dd927a26cfefc98c24b3ec38b3a8f204dad0c60d/typescript/packages/core/src/types/facilitator.ts#L18-L34)
- [x402 Payment Response header codec](https://github.com/coinbase/x402/blob/dd927a26cfefc98c24b3ec38b3a8f204dad0c60d/typescript/packages/core/src/http/index.ts#L57-L78)
- [MPP receipt shape](https://github.com/tempoxyz/mpp/blob/868ae128ea8f7996bfa37f6fe996ca58c04bbf05/src/pages/protocol/receipts.mdx#L7-L47)

The repository's current contribution policy asks external users to report
problems and request features rather than submit code pull requests, so this is
intentionally a feature request without an external patch.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia dal flusso di pagamento di AgentCore LangGraph in src/bedrock_agentcore/payments/integrations/langgraph/README.md e segui i tre punti di ingresso denominati: wrap_tool_call, awrap_tool_call e Strands after_tool_call. Riproduci il flusso simulato di PaymentManager con una challenge, una credenziale, un nuovo tentativo a pagamento e un output malformato. Il lavoro è completato quando il callback opzionale condivide una semantica coerente, conserva le prove di una possibile spesa in caso di rifiuto, impedisce un altro tentativo di pagamento automatico e lascia invariato il comportamento in assenza del callback.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
backend-api-design, payments
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.