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 5 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 5 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

@chopmob-cloud
Copy link
Copy Markdown
Author

I have signed the Google CLA. @googlebot please re-check.

- Remove redundant `uv pip install -e .` (uv sync already covers it)
- Use `find -mindepth 1 -delete` for log clearing (safer than wildcard)
- Point `adk web` at $AGENTS_DIR/shopping_agent subdirectory
@chopmob-cloud chopmob-cloud force-pushed the feat/crypto-algo-scenario branch from bfac829 to 6002d73 Compare April 14, 2026 18:02
Copy link
Copy Markdown
Author

@chopmob-cloud chopmob-cloud left a comment

Choose a reason for hiding this comment

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

Thanks for the review @gemini-code-assist. All three suggestions are already applied in the latest commit:

  • adk web now points to $AGENTS_DIR/shopping_agent specifically
  • uv pip install -e . removed (uv sync handles it)
  • Log clearing uses find "$LOG_DIR" -mindepth 1 -delete for robustness

@chopmob-cloud
Copy link
Copy Markdown
Author

Thanks for the review @gemini-code-assist — all three suggestions are already applied in the latest commit:

  • adk web now targets $AGENTS_DIR/shopping_agent specifically
  • uv pip install -e . removed (covered by uv sync)
  • Log clearing uses find "$LOG_DIR" -mindepth 1 -delete

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Thanks for the update, @chopmob-cloud. The changes look good and address the points raised. I'll take another look at the PR now.

@chopmob-cloud
Copy link
Copy Markdown
Author

Live demo: AP2 over A2A v1.0 REST + MCP

Following up on the adapter — wanted to share a working end-to-end demonstration of the protocol stack this implements:

AI Agent (Claude/Cursor/etc.)
    │  MCP tool call: send_a2a_message(agent_url, text)
    ▼
AlgoVoi MCP Server  ─────────────────────────────────────────
    │  POST https://agent.example.com/message:send
    ▼
A2A v1.0 REST server
    │  HTTP 402  X-AP2-Cart-Mandate: ...
    │            X-AP2-Payment-Required: amount=0.01,network=algorand_mainnet
    ▼
Agent pays on-chain (Algorand / VOI / Hedera / Stellar)
    │  Retry with  Authorization: Payment <tx_id>
    ▼
A2A v1.0 REST server  →  task result returned

AP2 v0.1 (CartMandate / PaymentMandate) is one of three payment challenge protocols the adapter supports over the A2A v1.0 REST transport — alongside MPP (WWW-Authenticate) and x402 (X-Payment-Required).

MCP tools (v1.2.0)

The AlgoVoi MCP Server now ships two A2A client tools that complete this flow from inside any MCP-compatible assistant:

Tool What it does
fetch_agent_card GET {agent_url}/.well-known/agent.json — discover capabilities + payment requirements
send_a2a_message POST {agent_url}/message:send — call payment-gated A2A agent; returns task on 200, challenge_headers on 402 for pay-and-retry

Live smoke test results

═══════════════════════════════════════════════════════════
  MCP A2A Two-Agent Smoke Test
  Agent A: AlgoVoi MCP tools
  Agent B: https://api1.ilovechicken.co.uk
═══════════════════════════════════════════════════════════

Phase 1a — fetch_agent_card
  ✓  tool returned without exception
  ✓  agent_url matches
  ✓  error is None
  ✓  card.name present
  ✓  card.description present
  ✓  card.url present
  ✓  card has skills list
  ✓  card has securitySchemes

Phase 1b — send without payment (expect 401/402)
  ✓  tool returned without exception
  ✓  401 Unauthorized returned (auth required before payment check)

Phase 1c — generate AP2/MPP challenge (4-network)
  ✓  status_code == 402
  ✓  WWW-Authenticate set
  ✓  accepts has 4 networks

PASS  13/13 checks passed

npm: npx -y @algovoi/mcp-server
PyPI: pip install algovoi-mcp
Source + smoke test: https://github.com/chopmob-cloud/AlgoVoi-MCP-Server

@chopmob-cloud
Copy link
Copy Markdown
Author

Update — Base chain support + ecosystem status (2026-04-22)

Since the last update AlgoVoi now supports Base (EVM) as a fifth payment network alongside Algorand, VOI, Hedera, and Stellar. The AP2 scenario in this PR can be extended to cover Base/USDC payment flows in a follow-up if useful.

Current live status:

  • Agent card: https://algovoi.co.uk/.well-known/agent.json (lists base_mainnet in skills)
  • Running ecosystem discovery across 22 A2A seed domains — AlgoVoi is currently the only live A2A agent card found across all chains
  • AP2 + MPP + x402 all live on production with 13/13 smoke tests passing

This PR is MERGEABLE with CLA signed and all gemini-code-assist suggestions addressed. Gentle ping for human maintainer review — no changes needed on our side. 🙏

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