Repository navigation
Conversation
SpendTools.tighten_permit existed but the ReAct system prompt, the agent's only tool-discovery surface, never listed it, so the live LLM agent could never call it. Add the tool entry and surrender rule to SYSTEM_TEMPLATE, plus two tests: prompt listing (fails without this change) and dispatch through the ReAct executor with immediate gate binding. 407 passed, 1 skipped, plain and under python -O. demo.py chain VERIFIED.
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.
User Job
As an autonomous spending agent, I want to voluntarily narrow my permit's spend cap, merchant allowlist, expiry, or approval threshold when my assigned task requires less authority than provisioned, so that leftover spending headroom cannot be hijacked by downstream prompt injections or unexpected tool loops.
Why this change
Mature / high-ranking repos require smaller, surgical, micro-iterative updates that narrow boundaries with zero regressions. In
permit, the authority gate already supports strict post-issuance tightening viapermit.tighten()andPOST /api/permits/<id>/tightenwith old→new receipt logging and descendant cascading. However, this capability was not exposed to the agent loop insideSpendTools(agent/tools.py).Exposing
tighten_permitdirectly empowers agents operating under least-privilege standards to drop unneeded merchants, lower remaining budgets, or shorten expiry windows without requiring out-of-band operator intervention or widening any trust boundary.What changed
tighten_permit()toSpendToolsinagent/tools.py:cap_cents,remove_merchants,expiry_minutes, andapproval_threshold_cents.self.flow.permits.tighten()withactor=f"agent:{permit.agent_id}".ValueErrorand fails closed (ok: False).ok: True,tightened: True,effective_cap_cents,remaining_cents, andeffective_allowlist.tests/test_agent.py:test_agent_tighten_permit_narrows_cap_and_records_receipt: Verifies that an agent narrowing cap from $50 to $20 logs aTIGHTENreceipt on the hash-chained ledger withactor: agent:t, updates the permit store, and immediately blocks subsequent spends above $20 withtightened_cap_exceededwithout touching PayPal.test_agent_tighten_permit_rejects_widening_attempt: Proves that attempts to raise the cap or pass empty parameters fail closed without mutating the permit.test_agent_tighten_permit_narrows_allowlist: Verifies that dropping a merchant from the allowlist immediately blocks subsequent spends against that merchant withmerchant_not_allowed.Scores
tighten()primitives).python -O).Sources
README.md,permit/permit.py) [Verified].Step Size Rationale
permitis a high-ranking, mature repository (flagship PayPal AI Hackathon entry, 400+ tests, hardened gates). Per portfolio guidelines, high-ranking repos take smaller, surgical, micro-iterative updates prioritizing stability, narrowing boundaries, and zero regressions. This change touches only 118 lines across two files, introduces no schema breaks, and strictly enforces that authority only narrows.Falsifier
If agent orchestrators observe that agents reliably exit immediately after task completion without any residual injection vulnerability, or if voluntary authority surrender introduces agent planning confusion that causes valid subsequent subtasks to fail, this iteration is a mistake.
Non-Goals
How it was verified
AttributeError: 'SpendTools' object has no attribute 'tighten_permit'), passed after.python -O.python demo.pyends withledger chain: VERIFIED (16 receipts).Evidence Commit Hashes
483187c— feat(agent): allow agents to voluntarily tighten permit authority