Repository navigation
feat(plugins): add CheckoutGuardPlugin for pre-payment checkout checks - #200
Open
frostyhand wants to merge 1 commit into
Open
frostyhand wants to merge 1 commit into
frostyhand wants to merge 1 commit into
Conversation
Adds a plugin that checks the merchant's checkout right before a payment tool runs and compares it with what the shopper approved. It blocks the call, or asks the shopper through ADK tool confirmation, when the checkout holds an unrequested subscription or add-on, a total over budget or that does not add up, drip-priced fees, a changed merchant or ship-to, or text that gives orders to the AI. Reads Agentic Commerce Protocol and Universal Commerce Protocol checkouts. The 21 rules are deterministic (no model or network call) and port the Fine Print rule set. After an approval the checkout is reloaded and must match the digest the shopper approved, so an approval cannot be replayed onto a changed cart. Fails closed without a mandate or a loadable checkout. Includes unit tests over 15 trap and control carts, Runner tests through the real confirmation flow, and a sample agent.
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.
Closes #199
What
Adds
CheckoutGuardPlugin(google.adk_community.plugins.checkout_guard), abefore_tool_callbackplugin that checks the merchant's checkout right before a payment tool runs.checkout_guard.summary, the findings, andsuggested_fixeswhen a change is safe.tool_context.request_confirmation(hint=summary, payload=verdict). On approval the checkout is reloaded and must match the stored digest before the tool runs. Rejected or stale approvals do not pay.It reads ACP (2026-04-17) and UCP (purchase options, subscription policy) checkouts through
from_acpandfrom_ucp. The 21 rules are deterministic, need no new dependency, and port the Fine Print rule set (https://github.com/frostyhand/fine-print) with the same ids. No mandate, or a checkout that cannot be loaded, blocks the payment.Files
src/google/adk_community/plugins/checkout_guard/: models, text checks, rules,check, adapters, pluginsrc/google/adk_community/plugins/__init__.py: exportsCheckoutGuardPlugin,ShopperMandatetests/plugins/test_checkout_guard_rules.py,tests/plugins/test_checkout_guard_plugin.py,tests/plugins/checkout_guard_fixtures/(15 carts)contributing/samples/checkout_guard/: sample agent with three demo checkouts, console runner, READMETesting plan
Unit tests:
skip_rules, mandate dict round trip.InMemoryRunnerand ADK tool confirmation, scripted model): a trap is blocked and nothing is paid; approve pays once; reject does not pay; a tip raised after approval does not pay.mypy(repo config),isort --checkandpyink --checkpass on the new files.E2E (Runner, real model):
contributing/samples/checkout_guard/main.pywith Gemini (gemini-flash-latestthrough the Gemini API).python main.py cs_tip --yes(merchant added a $3.00 tip):python main.py cs_tip --no:python main.py cs_addon(pre-selected protection plan, total over the $120.00 limit):python main.py cs_clean: