Skip to content

Conversation

@stefanoamorelli
Copy link
Contributor

@stefanoamorelli stefanoamorelli commented Oct 26, 2025

Tip

Better reviewed commit-by-commit.

Description

Implements a standalone go sample.

Closes #71 🦕

@stefanoamorelli stefanoamorelli requested a review from a team as a code owner October 26, 2025 18:24
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @stefanoamorelli, 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 delivers a new, self-contained Go sample for the Agent Payments Protocol (AP2). It provides a practical demonstration of how different agents can collaborate to facilitate commerce transactions, covering the entire flow from product discovery to payment processing. The implementation emphasizes clear architecture, robust message handling, and the integration of advanced AI capabilities for tool selection, offering a valuable reference for developers looking to build agentic commerce solutions in Go.

Highlights

  • New Go Sample for AP2: Introduces a complete, standalone Go sample implementation of the Agent Payments Protocol (AP2), demonstrating agent-to-agent commerce transactions.
  • Three Agent Roles: The sample includes three distinct agents: a Merchant Agent (manages products/carts), a Credentials Provider Agent (handles payment credentials), and a Merchant Payment Processor Agent (processes payments).
  • LLM-Based Tool Routing: Features intelligent tool/function routing using Google Gemini 2.5 Flash, with a fallback to simple string matching if an API key is not provided.
  • Comprehensive Documentation and Build System: Includes a detailed README with setup instructions, project structure, key AP2 concepts, and testing guidance, alongside a Makefile for streamlined building, testing, and running of agents.
  • Core AP2 Type Definitions: Defines all core AP2 protocol types in Go, such as IntentMandate, CartMandate, PaymentMandate, ContactAddress, and W3C Payment Request objects, following idiomatic Go patterns.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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
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 comprehensive standalone Go sample for the Agent Payments Protocol. The implementation is well-structured, covering multiple agent roles, common utilities, AP2 types, and supporting infrastructure like a Makefile and a detailed README. The code is clean, idiomatic, and demonstrates the protocol flow effectively.

My review includes a few suggestions for improvement, mainly focusing on enhancing robustness, code clarity, and adhering to Go best practices. These include safer type assertions, using the standard library for efficiency, and clarifying mock implementations. Overall, this is an excellent addition that will serve as a great reference for developers.

@stefanoamorelli stefanoamorelli force-pushed the feat/go-standalone-sample branch 15 times, most recently from c9fc058 to 2b8f93d Compare October 26, 2025 20:03
@joshlund-goog
Copy link
Collaborator

Could you add a README that instructs the user:

  • how to run this sample
  • how to interact with this sample (I notice there is no shopping_agent implemented in go)
  • what the sample is demonstrating

An example may be found at samples/python/scenarios/a2a/human-present/cards/README.md.

stefanoamorelli added a commit to stefanoamorelli/AP2 that referenced this pull request Oct 28, 2025
- Add detailed scenario README at samples/go/scenarios/a2a/human-present/cards/README.md
  - Explains how to run the Go sample
  - Clarifies no shopping agent is included (backend only)
  - Documents what the sample demonstrates
  - Provides cURL examples for testing
  - Compares with Python samples

- Update samples/go/README.md to be Go-specific
  - Removes incorrect Python-focused content
  - Provides Go project overview and structure
  - Documents development workflow

Addresses PR feedback on google-agentic-commerce#101
stefanoamorelli added a commit to stefanoamorelli/AP2 that referenced this pull request Oct 28, 2025
…operability

- Clarify Go sample provides backend agents only (no shopping agent)
- Add detailed instructions for using Python shopping agent with Go backends
- Highlight language-agnostic interoperability as key feature
- Include cURL examples for direct API testing
- Document architecture decisions and integration patterns
- Add comparison table with Python sample

This addresses PR google-agentic-commerce#101 feedback by clearly documenting:
- How to run the Go sample (backend agents only)
- How to interact with it (Python shopping agent or direct API calls)
- What it demonstrates (backend infrastructure + interoperability)
@stefanoamorelli
Copy link
Contributor Author

stefanoamorelli commented Oct 28, 2025

Could you add a README that instructs the user:

* how to run this sample

* how to interact with this sample (I notice there is no shopping_agent implemented in go)

* what the sample is demonstrating

An example may be found at samples/python/scenarios/a2a/human-present/cards/README.md.

Thanks for the feedback @joshlund-goog! I've updated the READMEs to address your points, but I also wanted to ask your opinion on something before finalizing this. Right now the golang sample focuses on the three backend agents (merchant, credentials provider, payment processor) without a Shopping Agent because the Python sample uses adk-python which handles all the agent orchestration, state management, and the web UI. We don't have an equivalent framework in Go, so I'd need to build a simplified version from scratch. It would work, but it wouldn't have the same polish as the Python version with ADK's dev-ui.

Alternatively, we can demonstrate the golang agents orchestrated using the Python Shopping Agent, implemented in adk-python. This would show interoperability but it's not a 100% golang sample.

What do you think makes more sense, or do you have other ideas? Please let me know if I'm missing out something.

@stefanoamorelli stefanoamorelli marked this pull request as draft October 28, 2025 14:31
@joshlund-goog
Copy link
Collaborator

Could you add a README that instructs the user:

* how to run this sample

* how to interact with this sample (I notice there is no shopping_agent implemented in go)

* what the sample is demonstrating

An example may be found at samples/python/scenarios/a2a/human-present/cards/README.md.

Thanks for the feedback @joshlund-goog! I've updated the READMEs to address your points, but I also wanted to ask your opinion on something before finalizing this. Right now the golang sample focuses on the three backend agents (merchant, credentials provider, payment processor) without a Shopping Agent because the Python sample uses adk-python which handles all the agent orchestration, state management, and the web UI. We don't have an equivalent framework in Go, so I'd need to build a simplified version from scratch. It would work, but it wouldn't have the same polish as the Python version with ADK's dev-ui.

Alternatively, we can demonstrate the golang agents orchestrated using the Python Shopping Agent, implemented in adk-python. This would show interoperability but it's not a 100% golang sample.

What do you think makes more sense, or do you have other ideas? Please let me know if I'm missing out something.

I like your solution of keeping the adk-python Shopping Agent as the entry point. I sent a review of the snags I ran into testing it out. Please fix and I'll continue testing/reviewing the go sample.

@stefanoamorelli stefanoamorelli marked this pull request as ready for review November 1, 2025 16:27
@stefanoamorelli
Copy link
Contributor Author

Thanks @joshlund-goog, I've addressed your comments and added a few improvements.

Here's also an E2E walkthrough of the process:

video.mp4

@stefanoamorelli stefanoamorelli force-pushed the feat/go-standalone-sample branch 2 times, most recently from 104a1f8 to 3a98db2 Compare November 1, 2025 16:44
Copy link
Collaborator

@joshlund-goog joshlund-goog left a comment

Choose a reason for hiding this comment

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

Verified the E2E test works. Nice work. Couple of README updates and then we can squash on merge.

Update scenario documentation to reflect correct agent endpoint paths and
improve documentation clarity:

- Add complete endpoint paths to agent descriptions (e.g.,
  /a2a/merchant_agent instead of just port numbers)
- Fix credentials provider endpoint from credentials_provider_agent to
  credentials_provider to match actual implementation
- Update integration instructions to clarify Python Shopping Agent is
  pre-configured
- Fix markdown linting issues (line length, list indentation, blank lines)
- Update run.sh output to display correct credentials provider endpoint

These changes align documentation with the actual implementation following
commit 669f2a6 where agent cards are hosted at path level.

Related to PR google-agentic-commerce#101
Refactor samples/go/README.md following the pattern established in Python
samples to eliminate duplication with scenario-specific documentation:

- Reduce from 307 to 86 lines (72% reduction)
- Remove detailed content duplicated in scenario READMEs
- Keep only essential overview, quick start, and navigation links
- Point readers to scenario directories for detailed instructions
- Remove "production-ready" wording per feedback
- Align structure with samples/python/README.md (26 lines)

This establishes scenario READMEs as the single source of truth for detailed
documentation, making the codebase easier to maintain and reducing the risk
of documentation drift.

Benefits:
- Single source of truth per scenario
- Easier maintenance (update once, not twice)
- Clearer navigation structure
- Consistent with Python samples pattern

Related to PR google-agentic-commerce#101
Reduce redundancy in the opening section by:
- Shortening title to be more direct
- Combining repetitive paragraphs into concise introduction
- Using bullet list for what's included instead of prose
- Removing repeated mentions of "sample", "Go", "backend agents"
- Making the note about Python Shopping Agent more concise

The new introduction is clearer and gets to the point faster while
maintaining all essential information.
@stefanoamorelli stefanoamorelli force-pushed the feat/go-standalone-sample branch 7 times, most recently from c51e4b7 to b5b472d Compare November 6, 2025 19:29
@stefanoamorelli stefanoamorelli force-pushed the feat/go-standalone-sample branch from b5b472d to a5fa461 Compare November 6, 2025 19:33
@stefanoamorelli
Copy link
Contributor Author

@joshlund-goog good stuff and thank you so much for all the feedback. I've given some love to the READMEs, lmkwyt!

@joshlund-goog
Copy link
Collaborator

@joshlund-goog good stuff and thank you so much for all the feedback. I've given some love to the READMEs, lmkwyt!

And thank you for the work on the go sample. We're very close.

@stefanoamorelli
Copy link
Contributor Author

Adjusted as suggested ✔️ @joshlund-goog

@joshlund-goog
Copy link
Collaborator

It appears we're blocked by this issue: https://github.com/orgs/community/discussions/144455. I'm looking into temporarily disabling the requirement for "conversations to be resolved".

@holtskinner
Copy link
Contributor

It appears we're blocked by this issue: https://github.com/orgs/community/discussions/144455. I'm looking into temporarily disabling the requirement for "conversations to be resolved".

The requirement is removed now

@joshlund-goog joshlund-goog merged commit c3a3876 into google-agentic-commerce:main Nov 11, 2025
4 checks passed
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]: Go reference implementation

3 participants