Skip to content

fix: add missing run.sh script for x402 scenario#184

Closed
ayushozha wants to merge 3 commits intogoogle-agentic-commerce:mainfrom
ayushozha:fix/add-missing-x402-run-script
Closed

fix: add missing run.sh script for x402 scenario#184
ayushozha wants to merge 3 commits intogoogle-agentic-commerce:mainfrom
ayushozha:fix/add-missing-x402-run-script

Conversation

@ayushozha
Copy link

Summary

  • Adds the missing run.sh script to samples/python/scenarios/a2a/human-present/x402/
  • The script follows the same pattern as the existing cards/run.sh, with PAYMENT_METHOD set to x402
  • The x402 README already references this script but it was never included

Fixes #107

Test plan

  • Verify the script is present and executable
  • Confirm it matches the pattern of cards/run.sh with appropriate x402 defaults
  • Run bash samples/python/scenarios/a2a/human-present/x402/run.sh from the repo root to validate it starts correctly

🤖 Generated with Claude Code

Fixes google-agentic-commerce#107

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ayushozha ayushozha requested a review from a team as a code owner March 18, 2026 08:25
@google-cla
Copy link

google-cla bot commented Mar 18, 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.

@gemini-code-assist
Copy link
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 run.sh script for the x402 payment scenario, enabling its proper execution. The script automates the setup and launch of various agents and servers required for the scenario, ensuring consistency with other existing payment examples and rectifying a previous omission where the scenario's documentation referenced a missing script.

Highlights

  • Missing run.sh script added: A new run.sh script was added to samples/python/scenarios/a2a/human-present/x402/ to enable the execution of the x402 payment example.
  • Script functionality: The script automates the setup and execution of the x402 payment example by starting necessary servers and agents in the background.
  • Consistency with existing patterns: The new script follows the established pattern of the cards/run.sh script, including setting the PAYMENT_METHOD to x402.
  • Addressing a known issue: This addition resolves a previous omission where the x402 README referenced a run.sh script that was not included in the repository.

🧠 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
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 adds the run.sh script for the x402 scenario, which was previously missing. The script automates the setup and execution of the payment example. My review focuses on improving the script's robustness and fixing a potential bug. I've suggested using an array for command construction to handle potential spaces in paths correctly and a safer way to clear the log directory to prevent script failure.

Comment on lines +103 to +105
if [ -d "$LOG_DIR" ]; then
rm -f "$LOG_DIR"/*
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The command rm -f "$LOG_DIR"/* will cause the script to exit if the $LOG_DIR directory is empty, because set -e is active. This happens because the glob * doesn't expand to anything, and rm fails when it can't find a file matching the literal *. A simpler and more robust way to clear the log directory is to remove and recreate it.

Suggested change
if [ -d "$LOG_DIR" ]; then
rm -f "$LOG_DIR"/*
fi
rm -rf "$LOG_DIR"
mkdir -p "$LOG_DIR"

Comment on lines +115 to +137
UV_RUN_CMD="uv run --no-sync"

if [ -f ".env" ]; then
UV_RUN_CMD="$UV_RUN_CMD --env-file .env"
fi

echo "-> Starting the Merchant Agent (port:8001 log:$LOG_DIR/merchant_agent.log)..."
$UV_RUN_CMD --package ap2-samples python -m roles.merchant_agent >"$LOG_DIR/merchant_agent.log" 2>&1 &
pids+=($!)

echo "-> Starting the Credentials Provider (port:8002 log:$LOG_DIR/credentials_provider_agent.log)..."
$UV_RUN_CMD --package ap2-samples python -m roles.credentials_provider_agent >"$LOG_DIR/credentials_provider_agent.log" 2>&1 &
pids+=($!)

echo "-> Starting the Card Processor Agent (port:8003 log:$LOG_DIR/mpp_agent.log)..."
$UV_RUN_CMD --package ap2-samples python -m roles.merchant_payment_processor_agent >"$LOG_DIR/mpp_agent.log" 2>&1 &
pids+=($!)

echo ""
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
Contributor

Choose a reason for hiding this comment

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

medium

For robustness, it's better to use a bash array to build the command. This avoids issues with word splitting if paths with spaces are ever used. This change also quotes $AGENTS_DIR for the same reason.

UV_RUN_CMD=("uv" "run" "--no-sync")

if [ -f ".env" ]; then
  UV_RUN_CMD+=("--env-file" ".env")
fi

echo "-> Starting the Merchant Agent (port:8001 log:$LOG_DIR/merchant_agent.log)..."
"${UV_RUN_CMD[@]}" --package ap2-samples python -m roles.merchant_agent >"$LOG_DIR/merchant_agent.log" 2>&1 &
pids+=($!)

echo "-> Starting the Credentials Provider (port:8002 log:$LOG_DIR/credentials_provider_agent.log)..."
"${UV_RUN_CMD[@]}" --package ap2-samples python -m roles.credentials_provider_agent >"$LOG_DIR/credentials_provider_agent.log" 2>&1 &
pids+=($!)

echo "-> Starting the Card Processor Agent (port:8003 log:$LOG_DIR/mpp_agent.log)..."
"${UV_RUN_CMD[@]}" --package ap2-samples python -m roles.merchant_payment_processor_agent >"$LOG_DIR/mpp_agent.log" 2>&1 &
pids+=($!)

echo ""
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"

Ayush Ojha and others added 2 commits March 18, 2026 01:29
Address review feedback to follow DRY principle by extracting the
model name into a single MODEL constant in common/config.py, which
reads from the MODEL env var with a default of "gemini-2.5-flash".
All 6 files that previously hardcoded the model string now import
from this central config.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use rm -rf/mkdir -p for safer log directory clearing (avoids set -e
  failure on empty glob)
- Use bash arrays for UV_RUN_CMD to avoid word splitting issues
- Quote $AGENTS_DIR in final command

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ayushozha
Copy link
Author

Superseded by #185

@ayushozha ayushozha closed this Mar 18, 2026
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.

File missing

1 participant