Skip to content

feat(types): add budget field to IntentMandate#198

Open
ravyg wants to merge 2 commits intogoogle-agentic-commerce:mainfrom
ravyg:budget-field
Open

feat(types): add budget field to IntentMandate#198
ravyg wants to merge 2 commits intogoogle-agentic-commerce:mainfrom
ravyg:budget-field

Conversation

@ravyg
Copy link
Copy Markdown

@ravyg ravyg commented Mar 26, 2026

Adds an optional budget: PaymentCurrencyAmount field to IntentMandate in both Python and Go, giving agents a machine-readable spend ceiling to enforce when fulfilling a purchase intent.

  • Python: src/ap2/types/mandate.py -- new field + import
  • Go: samples/go/pkg/ap2/types/mandate.go -- new field with omitempty
  • Tests: 6 Python tests + 5 Go tests (optional, set, JSON round-trip, absent-from-JSON)
  • Docs: Section 4.1 Intent Mandate field list updated

Closes #133

Description

Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

Fixes #<issue_number_goes_here> 🦕

@ravyg ravyg requested a review from a team as a code owner March 26, 2026 07:52
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a crucial enhancement to the IntentMandate type by adding an optional budget field. This new field provides a mechanism for agents to define and enforce a maximum spend limit for a given purchase intent, thereby improving control and predictability in automated commerce scenarios. The change is implemented across both Python and Go language bindings, accompanied by thorough testing and updated documentation.

Highlights

  • New Feature: Budget Field: An optional budget field of type PaymentCurrencyAmount has been added to the IntentMandate type in both Python and Go implementations. This field allows agents to enforce a machine-readable spend ceiling for purchase intents.
  • Cross-Language Implementation: The budget field was added to IntentMandate in src/ap2/types/mandate.py (Python) and samples/go/pkg/ap2/types/mandate.go (Go), ensuring consistency across language bindings.
  • Comprehensive Testing: Extensive tests were added for both Python and Go, covering scenarios such as the field's optionality, successful setting of a budget, correct JSON serialization and deserialization, and proper omission from JSON output when the field is not set.
  • Documentation Update: The docs/specification.md file was updated to reflect the addition of the new Budget field within the Intent Mandate section, providing clear guidance on its purpose and usage.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 new 'Budget' field to the IntentMandate type, allowing for an optional maximum total spend ceiling for AI agents. The change is implemented in both Go and Python, including updates to the specification documentation and comprehensive unit tests covering optionality, setting, JSON serialization, and round-trip functionality. The only feedback provided suggests using a standard apostrophe for consistency in the markdown documentation.

- Prompt Playback: The Agent’s understanding of the User’s prompt in natural
language.
- Time-to-Live (TTL): An expiration time for the mandate's validity.
- Time-to-Live (TTL): An expiration time for the mandates validity.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

low

Consider using a standard apostrophe ' instead of the right single quotation mark for consistency in markdown files, unless there's a specific style guide dictating otherwise. While is typographically correct, '' is more common in plain text and code contexts.

Suggested change
- Time-to-Live (TTL): An expiration time for the mandates validity.
- Time-to-Live (TTL): An expiration time for the mandate's validity.

Adds an optional `budget: PaymentCurrencyAmount` field to `IntentMandate`
in both Python and Go, giving agents a machine-readable spend ceiling to
enforce when fulfilling a purchase intent.

- Python: `src/ap2/types/mandate.py` -- new field + import
- Go: `samples/go/pkg/ap2/types/mandate.go` -- new field with omitempty
- Tests: 6 Python tests + 5 Go tests (optional, set, JSON round-trip, absent-from-JSON)

Closes google-agentic-commerce#133
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.

[Feat]: Standardized budget limitation field

1 participant