Repository navigation
Add OpenAI Agents SDK x402 tool example - #422
Conversation
|
@Edgadafi Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
…col#365) Co-authored-by: Edgadafi <Edgadafi@users.noreply.github.com>
92bd1a6 to
a76f24e
Compare
Eras256
left a comment
There was a problem hiding this comment.
AI-assisted review (Claude)
Thanks Edgar, the tool is clean and the tests cover the cap well. I checked both payments on testnet (144d2090 and 1bed22cb): your account pays 0.02 USDC each time.
One item from #365 is still missing. The payments go to GC4Q5TWW…, which is Nirium's own testnet endpoint. The issue asks the agent to "pay a testnet x402Serve route you run". Please start a small route with x402Serve (Node SDK) on testnet with your own payTo address, point the tool at it, and put that paid call and the refused one in the README, with the hashes on Stellar Expert.
nirium-protocol#365 asks the agent to pay a testnet x402Serve route you run. agent.py already expected a server on localhost:3402, but none was in the PR, so the earlier payments went to Nirium's testnet endpoint. server/ adds that route: /paid/market-summary at X402_PRICE (below the agent's $1 cap) and /paid/full-report at $2 (above it), paid to SELLER_PUBLIC_KEY. agent.py Test 2 now calls the $2 route and expects the refusal. README and .env.example explain the setup; the evidence table for a run against your own route is left PENDING for the author. Checked locally: both routes answer an x402 v2 402 on stellar:testnet (200000 and 20000000 units to payTo); nirium 0.12.7 with a $1 cap refuses /paid/full-report before signing; the 8 offline tests pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
AI-assisted comment (Claude) Edgar, I pushed 2cacf10 to your branch with the missing piece, so you only need to run it:
I checked it locally: both routes answer an x402 v2 402 on stellar:testnet, the Python SDK with a $1 cap refuses What's left is yours, with your own keys:
Once that's in, this is ready to merge. |
|
Thanks @Eras256 for 2cacf10, the local server made this much easier to verify. I ran it with my own keys on stellar:testnet and filled the evidence table in ae185cf:
I also fixed Demo video |
M0nsxx
left a comment
There was a problem hiding this comment.
AI-assisted review (Claude)
Own-route testnet evidence checked on Horizon: both payments (2d9235ab…, bee03b8b…) go from Edgar's payer to his own seller GDYJA25N…IV5Z, 0.02 USDC each, and the $2 call is refused by the cap before signing. agent.py now uses Runner.run + final_output (openai-agents 0.25.0). CI green, no conflicts. Approved.
Edgar filled the own-route testnet evidence in ae185cf (verified on Horizon) and fixed Runner.run. Nothing left from this review.
) Edgar's OpenAI Agents SDK example merged 21 Nov with his own testnet run (tx 2d9235ab..., 0.02 USDC to his own seller account, verified on Horizon). Wave count 12 -> 13, outside total 36 -> 37, counted with the pulls API across nirium-protocol repos. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Closes #365
Summary
Adds
examples/openai-agents-x402/: an OpenAI Agents SDK@function_toolthat wraps Nirium'sx402_fetch()with a per-payment spend cap. Payments above the cap are refused before signing and return a clearX402SpendCapErrorthe agent can explain.What's included
nirium_tool.py:@function_toolwrapper withmax_amount_per_paymentagent.py: OpenAI Agents SDKAgentusing the tooltest_openai_tool.py: 8 offline tests (no network, no LLM)README.md, pinnedrequirements.txt,.env.example,.gitignoreTests
8/8 offline tests pass, including
test_payment_above_cap_refused(nothing is signed when over the cap).Testnet evidence (own Friendbot keys)
@function_tool(0.02 USDC): 144d2090…X402SpendCapError, no transactionVersions tested
nirium==0.12.7, openai-agents==0.25.0, python-dotenv==1.0.0, pytest==8.3.0, pytest-asyncio==0.24.0
Demo (34 s screen recording)
https://github.com/user-attachments/assets/8d178454-afff-4d86-81c2-d5c34935e8fc
Testnet only. No secrets committed.