Repository navigation
Docs: a recipe for agent spending limits and offline receipts (intent grants) - #830
Merged
Merged
Conversation
… grants) docs/quickstarts/agent-spending.md: an OpenAI Agents SDK agent pays through a send_payment tool on the dev signer. The first payment is held, the person approves it with a payment grant (two payees, 50 USD each, 120 USD in all, an hour), the next two run within it, one past the total is held with the signed reason, and the exported bundle verifies offline with the intent grants line. The output on the page is from a run of the example. examples/v2/openai_agents/spending.py runs it with a scripted model (no API key); tests/test_grants.py runs the same flow in-process and checks each step; tests/test_examples_v2.py runs the example end to end. Linked from the quickstarts index, intent-grants.md and limits.md. Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
This was referenced Nov 14, 2026
Say which agents the recipe covers (payments through a tool Tracekit gates), that on the dev signer the agent itself could have issued the grant or approved a payment, where the example prints the signed decisions, and that --scripted plays the person. Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.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.
What it adds
docs/quickstarts/agent-spending.md: "Spending limits and receipts for any agent". An OpenAI Agents SDK agent pays through asend_paymenttool on the dev signer:TK-M001,TK-M002);tracekit approvals approve ID --grant ...);flagwithTK-GRANTand what is left (45 of 120 USD left,20 of 120 USD left);grant g-…: 100 of 120 USD used; this call needs 40 USD, and the person rejects it;tracekit verifychecks it offline, with theintent grantsline passing. The.tkbandtrust.jsonare the receipt. A copy with one payment edited readsTAMPERED.The page is marked experimental. It ends with what the receipt shows and its limits: dev signer, self-approved, T1, fields not checked against arguments, one run.
examples/v2/openai_agents/spending.py: the runnable example. It uses a scripted model and needs no API key.--scriptedruns the person's commands as a second process, the way the other v2 examples do. Without it, it prints them and waits.tests/test_grants.py::TestAgentSpending: the same flow in-process, with the adapter and a realSignerServiceon the dev pack. It checks each step: held, granted (self-approved, first payment counted), released within bounds with exact reasons andext.grantfields, held over the total with the reason, the rejected call never ran, and the bundle verifies with the grant check passing.tests/test_examples_v2.py::test_openai_agents_spending: runs the example end to end.docs/quickstarts/README.md(a new Recipes list),docs/intent-grants.md, anddocs/limits.md. The page has a limits section, andtest_docsrequires limits.md to link it. Also a short section inexamples/v2/openai_agents/README.md.How I ran it
python examples/v2/openai_agents/spending.py --scriptedin a fresh HOME and runtime dir with this branch's code. The output on the page is from that run, and every output line on the page was checked against it. I rantracekit verify(short form) on the receipt and on an edited copy by hand.--scripted. It printed the person's commands and waited. I stopped it there and did not approve as the agent.make lint: passed.pytest tests/test_grants.py tests/test_docs.py tests/test_examples_v2.py: 61 passed, 7 skipped (frameworks not installed). Both new tests ran.pytest tests/test_wiki.py tests/test_eval_docs.py: 11 and 3 passed.python scripts/wiki.py OUT: 132 pages. The new page isQuickstarts-Agent-Spending, in the Get started sidebar.Not run: the full
make test,make buildandmake test-ts. The CI Linux run is the gate for those.Found while writing it, not changed here
tracekit approvals showprints the rules' reasons (sending money (TK-M001); moving money (TK-M002)), not the grant's reason. Itsgrantline also offers a new grant. The approval record has no reason field. The exact reason is only in the signed decision (reasons) and thedecideresponse.decidereason to the app on anask. So the example prints the reason from the bundle after export.