Skip to content

feat: cross-merchant budget enforcement sample#252

Open
Ectsang wants to merge 4 commits intogoogle-agentic-commerce:mainfrom
Ectsang:samples/cross-merchant-budget
Open

feat: cross-merchant budget enforcement sample#252
Ectsang wants to merge 4 commits intogoogle-agentic-commerce:mainfrom
Ectsang:samples/cross-merchant-budget

Conversation

@Ectsang
Copy link
Copy Markdown

@Ectsang Ectsang commented May 1, 2026

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 BudgetEvaluator independently, each with its own MandateContext. 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.

@Ectsang Ectsang requested a review from a team as a code owner May 1, 2026 04:51
@Ectsang Ectsang changed the title samples: cross-merchant budget enforcement scenario feat: cross-merchant budget enforcement scenario May 1, 2026
@Ectsang Ectsang changed the title feat: cross-merchant budget enforcement scenario feat: cross-merchant budget enforcement sample May 1, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread code/samples/python/scenarios/cross-merchant-budget/cross_merchant_budget.py Outdated
Comment thread code/samples/python/scenarios/cross-merchant-budget/cross_merchant_budget.py Outdated
Comment thread code/samples/python/scenarios/cross-merchant-budget/cross_merchant_budget.py Outdated
Comment thread code/samples/python/scenarios/cross-merchant-budget/cross_merchant_budget.py Outdated
Comment thread code/samples/python/scenarios/cross-merchant-budget/cross_merchant_budget.py Outdated
Copy link
Copy Markdown

@gazaliyalade-hue gazaliyalade-hue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

2 participants