Skip to content

feat: add run.sh for human-present x402 scenario#244

Open
chopmob-cloud wants to merge 4 commits intogoogle-agentic-commerce:mainfrom
chopmob-cloud:feat/x402-human-present-run-script
Open

feat: add run.sh for human-present x402 scenario#244
chopmob-cloud wants to merge 4 commits intogoogle-agentic-commerce:mainfrom
chopmob-cloud:feat/x402-human-present-run-script

Conversation

@chopmob-cloud
Copy link
Copy Markdown

Summary

The code/samples/python/scenarios/a2a/human-present/x402/ directory was the
only scenario in v0.2 missing a run.sh. Every other scenario directory has
one:

Scenario run.sh
human-present/cards
human-present/x402 ❌ → ✅ this PR
human-not-present/cards
human-not-present/x402

The README worked around this by pointing users at
cards/run.sh --payment-method x402, which is confusing — a reader in the
x402 directory should not have to navigate to a sibling directory to run
the scenario.

Changes

  • run.sh (new): mirrors human-present/cards/run.sh exactly, with
    PAYMENT_METHOD="x402" hardcoded and the --payment-method arg-parsing
    block removed (not needed for a single-purpose script).
  • README.md (1 line): updates the "Execution" command from
    cards/run.sh --payment-method x402 to x402/run.sh.

The human-present/x402 scenario directory was the only scenario in
v0.2 missing a run.sh. The README worked around this by pointing users
at cards/run.sh --payment-method x402, but the dedicated script makes
the scenario consistent with all other scenario directories.

Update the README execution command to point at the new script.
@chopmob-cloud chopmob-cloud requested a review from a team as a code owner April 29, 2026 16:24
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 new shell script to automate the execution of the x402 human-present example and updates the README to point to this new script. I have provided a suggestion to improve the robustness of the log directory cleanup process. The suggestion regarding the AGENTS_DIR path was removed as it did not include a specific code change.

# Clear old logs.
echo "Clearing the logs directory..."
if [ -d "$LOG_DIR" ]; then
rm -f "$LOG_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.

low

Using rm -f "$LOG_DIR"/* can be problematic if the directory is empty, as the glob pattern * might not expand (depending on shell settings), leading to an attempt to delete a literal file named *. A more robust way to clear the directory is to remove and recreate it, or use find to delete its contents.

Suggested change
rm -f "$LOG_DIR"/*
rm -rf "$LOG_DIR" && mkdir -p "$LOG_DIR"

Replacing `rm -f "$LOG_DIR"/*` with `rm -rf "$LOG_DIR" && mkdir -p
"$LOG_DIR"` avoids a glob-expansion failure when the directory is
empty (some shells pass a literal `*` to rm if no files match).

Addresses Gemini code-review feedback on PR google-agentic-commerce#244.
@chopmob-cloud
Copy link
Copy Markdown
Author

Thanks for the review @gemini-code-assist — applied in the latest commit. Replaced rm -f "$LOG_DIR"/* with rm -rf "$LOG_DIR" && mkdir -p "$LOG_DIR" to avoid the glob-expansion edge case on empty directories.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Thanks for the update, @chopmob-cloud. That change to rm -rf "$LOG_DIR" && mkdir -p "$LOG_DIR" is a robust way to handle the directory cleanup and avoids the potential issues with glob expansion on empty directories. The implementation looks good.

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