feat: cross-merchant budget enforcement sample#252
Open
Ectsang wants to merge 4 commits intogoogle-agentic-commerce:mainfrom
Open
feat: cross-merchant budget enforcement sample#252Ectsang wants to merge 4 commits intogoogle-agentic-commerce:mainfrom
Ectsang wants to merge 4 commits intogoogle-agentic-commerce:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a sample implementation demonstrating the budget enforcement gap in cross-merchant scenarios and provides a solution via an external budget authority. Feedback focuses on improving numerical precision by using round() for currency conversions, optimizing the performance of hold lookups to avoid O(N) complexity, ensuring unique identifiers by using full UUIDs, and enhancing type safety by replacing mixed-type dictionaries with dataclasses.
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.
Adds a sample demonstrating the cross-merchant budget enforcement gap from #207 and a solution using an external budget authority.
Part 1 shows the problem: two merchants evaluate
BudgetEvaluatorindependently, each with its ownMandateContext. The agent overspends ($120 on a $100 budget).Part 2 shows the fix: an external authority with four verbs (authorize, commit, refund, query) based on the discussion in #207. The authorize call atomically checks and holds budget, preventing race conditions.
No external dependencies. Runs with
python cross_merchant_budget.py.