Skip to content

Surrender unneeded authority: allow AI agents to narrow their own permit limits - #60

Draft
FetchDoge wants to merge 2 commits into
mainfrom
feat/agent-voluntary-tighten
Draft

FetchDoge wants to merge 2 commits into
mainfrom
feat/agent-voluntary-tighten

Conversation

@FetchDoge

Copy link
Copy Markdown
Owner

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 via permit.tighten() and POST /api/permits/<id>/tighten with old→new receipt logging and descendant cascading. However, this capability was not exposed to the agent loop inside SpendTools (agent/tools.py).

Exposing tighten_permit directly 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

  • Added tighten_permit() to SpendTools in agent/tools.py:
    • Accepts cap_cents, remove_merchants, expiry_minutes, and approval_threshold_cents.
    • Forwards to self.flow.permits.tighten() with actor=f"agent:{permit.agent_id}".
    • Tighten-only invariant strictly enforced: attempting to widen authority or passing empty parameters raises ValueError and fails closed (ok: False).
    • Returns ok: True, tightened: True, effective_cap_cents, remaining_cents, and effective_allowlist.
  • Added unit tests in tests/test_agent.py:
    • test_agent_tighten_permit_narrows_cap_and_records_receipt: Verifies that an agent narrowing cap from $50 to $20 logs a TIGHTEN receipt on the hash-chained ledger with actor: agent:t, updates the permit store, and immediately blocks subsequent spends above $20 with tightened_cap_exceeded without 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 with merchant_not_allowed.

Scores

  • Fit: 5/5 (Aligns directly with Permit's core invariant: spending authority only narrows, never widens, with a hash-chained receipt for every decision).
  • Usefulness: 5/5 (Allows agents to implement the principle of least privilege mid-task and shed excess spend capacity).
  • Feasibility: 5/5 (Zero new dependencies; pure Python stdlib; uses existing hardened tighten() primitives).
  • Evidence: 5/5 (Verified; passes all 23 agent tests and full 405-test suite plain and under python -O).

Sources

  • OWASP Top 10 for LLM Applications 2025/2026: ASI-01 Overreliance & Privilege Accumulation [Verified].
  • Anthropic MCP Specification / Tool Use Security Guidance (Sept–Oct 2026) [Verified].
  • Permit Architecture & Invariant Specifications (README.md, permit/permit.py) [Verified].

Step Size Rationale

permit is 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

  • Does NOT allow an agent to widen caps, add merchants, extend expiry, or raise approval thresholds.
  • Does NOT bypass the 4-clause gate or ledger receipting.
  • Does NOT add external network calls or alter the PayPal sandbox wire protocol.

How it was verified

  • Test-first verification: new tests failed before implementation (AttributeError: 'SpendTools' object has no attribute 'tighten_permit'), passed after.
  • Full test suite: 405 passed, 1 skipped in 19.26s plain and under python -O.
  • Smoke test: python demo.py ends with ledger chain: VERIFIED (16 receipts).

Evidence Commit Hashes

  • 483187c — feat(agent): allow agents to voluntarily tighten permit authority

FetchDoge and others added 2 commits October 20, 2026 09:17
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant