fix: add missing run.sh script for x402 scenario#184
fix: add missing run.sh script for x402 scenario#184ayushozha wants to merge 3 commits intogoogle-agentic-commerce:mainfrom
Conversation
Fixes google-agentic-commerce#107 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
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. |
Summary of ChangesHello, 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 Highlights
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| if [ -d "$LOG_DIR" ]; then | ||
| rm -f "$LOG_DIR"/* | ||
| fi |
There was a problem hiding this comment.
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.
| if [ -d "$LOG_DIR" ]; then | |
| rm -f "$LOG_DIR"/* | |
| fi | |
| rm -rf "$LOG_DIR" | |
| mkdir -p "$LOG_DIR" |
| 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 |
There was a problem hiding this comment.
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"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>
|
Superseded by #185 |
Summary
run.shscript tosamples/python/scenarios/a2a/human-present/x402/cards/run.sh, withPAYMENT_METHODset tox402Fixes #107
Test plan
cards/run.shwith appropriate x402 defaultsbash samples/python/scenarios/a2a/human-present/x402/run.shfrom the repo root to validate it starts correctly🤖 Generated with Claude Code