Skip to content

feat(samples): add human-present crypto-algo scenario (AP2 v0.1 + AlgoVoi on-chain USDC extension)#218

Open
chopmob-cloud wants to merge 2 commits intogoogle-agentic-commerce:mainfrom
chopmob-cloud:feat/crypto-algo-scenario
Open

feat(samples): add human-present crypto-algo scenario (AP2 v0.1 + AlgoVoi on-chain USDC extension)#218
chopmob-cloud wants to merge 2 commits intogoogle-agentic-commerce:mainfrom
chopmob-cloud:feat/crypto-algo-scenario

Conversation

@chopmob-cloud
Copy link
Copy Markdown

Summary

Adds a new human-present scenario demonstrating on-chain USDC payment via the
AP2 crypto-algo/v1 extension on Algorand and VOI.

  • New scenario folder: samples/python/scenarios/a2a/human-present/crypto-algo/
  • README.md — full walkthrough matching the style of the cards and x402 scenarios
  • run.sh — one-command startup script matching the pattern of cards/run.sh

What this demonstrates

The crypto-algo/v1 extension (published at https://api1.ilovechicken.co.uk/ap2/extensions/crypto-algo/v1) defines:

  • PaymentMethodDatanetwork, receiver, amount_microunits, asset_id, min_confirmations, memo_required
  • PaymentResponseDetailsnetwork, tx_id, note_field

The scenario covers the full human-present flow:

  1. Merchant Agent issues a CartMandate with crypto-algo/v1 in payment_methods
  2. Credentials Provider submits on-chain USDC (Algorand or VOI)
  3. note_field = sha256(CartMandate) — cryptographically binds payment proof to the approved cart (addresses the binding gap discussed in issue [Security Hardening Suggestion]AP2 Human-Present: CartMandate ↔ PaymentMandate Binding and Verification Gap #211)
  4. Shopping Agent signs a PaymentMandate with the payer's ed25519 key
  5. Merchant Payment Processor verifies signature + note_field hash, then confirms on-chain via public indexer

Reference implementation

A complete open-source server-side gate (Ap2Gate) is available at
AlgoVoi-Platform-Adapters/ap2-adapter/
81/81 tests, zero pip dependencies, 4-chain smoke tested (Algorand, VOI, Hedera, Stellar — 13 April 2026).

Chain support

Network Asset Ticker
algorand-mainnet ASA 31566704 USDC
voi-mainnet ARC200 302190 aUSDC

Test plan

  • README.md renders correctly and matches style of existing scenarios
  • run.sh follows the same startup pattern as cards/run.sh
  • Extension URI resolves: https://api1.ilovechicken.co.uk/ap2/extensions/crypto-algo/v1
  • Schema resolves: https://api1.ilovechicken.co.uk/ap2/extensions/crypto-algo/v1/schema.json

Note: Google CLA must be signed before this PR can be merged — see CONTRIBUTING.md.

🤖 Generated with Claude Code

@chopmob-cloud chopmob-cloud requested a review from a team as a code owner April 13, 2026 21:15
@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 13, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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 bash script to automate the execution of the crypto-algo AP2 example, handling environment setup, virtual environment management via uv, and the orchestration of background agent processes. The review feedback suggests refining the web interface command to target the specific shopping agent directory, removing a redundant installation step that is already covered by uv sync, and improving the robustness of the log-clearing logic by using find instead of shell wildcards.

echo "All remote servers are starting."

echo "Starting the Shopping Agent..."
$UV_RUN_CMD --package ap2-samples adk web --host 0.0.0.0 $AGENTS_DIR
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.

medium

The log message on line 109 indicates that the 'Shopping Agent' is being started. However, $AGENTS_DIR points to the parent directory containing multiple agents (merchant, credentials provider, etc.). To ensure the web interface targets the shopping agent specifically, it is recommended to point adk web directly to the shopping_agent subdirectory.

Suggested change
$UV_RUN_CMD --package ap2-samples adk web --host 0.0.0.0 $AGENTS_DIR
$UV_RUN_CMD --package ap2-samples adk web --host 0.0.0.0 $AGENTS_DIR/shopping_agent

echo "Virtual environment activated."

echo "Installing project in editable mode..."
uv pip install -e .
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

The command uv pip install -e . is redundant because uv sync (called on line 71) already handles installing the project and its dependencies in the virtual environment. Removing this line simplifies the script and follows uv best practices.

Comment on lines +79 to +81
if [ -d "$LOG_DIR" ]; then
rm -f "$LOG_DIR"/*
fi
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

Clearing the log directory using a wildcard * can be problematic if the directory is empty (the wildcard might not expand) or contains a very large number of files. A more robust approach is to use find to delete the contents without relying on shell expansion.

Suggested change
if [ -d "$LOG_DIR" ]; then
rm -f "$LOG_DIR"/*
fi
if [ -d "$LOG_DIR" ]; then
find "$LOG_DIR" -mindepth 1 -delete
fi

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.

1 participant