hamishfromatech/my-personal-skills-library/402pilot-buyer-side-payment-decision
Claude Code and agent skill by hamishfromatech/my-personal-skills-library
- community
Checking that the SKILL.md file is still in the repository.
Applies the 402Pilot buyer-side decision layer for autonomous agent micropayments to design spending policies that learn service value and adapt purchasing decisions under wallet pressure. Use when building autonomous agents that pay for API calls, designing budget-constrained provider selection policies, implementing pay-per-inference routing, or developing buyer-side decision-making for x402/AP2 payment protocols.
Install
npx vskill@latest install hamishfromatech/my-personal-skills-library/402pilot-buyer-side-payment-decisionSKILL.md
The same SKILL.md was published earlier as hamishfromatech/my-personal-skills-library/402pilot-buyer-side-payment-decision.
402Pilot: Buyer-Side Payment Decision Layer for Autonomous Agent Micropayments
Overview
A protocol-agnostic buyer-side decision layer between autonomous agents and payment execution that implements purchasing policies for selecting among payable providers — solving the problem that programmable payment protocols (x402, AP2) handle execution but do not determine which payable service an agent should buy under a finite wallet.
When to Use
- Building autonomous agents that pay for API calls, MCP tools, or inference endpoints
- Designing budget-constrained provider selection policies
- Implementing pay-per-inference routing across multiple model providers
- Developing buyer-side decision-making for x402, AP2, or ACP payment protocols
- Managing agent spending under finite wallet constraints with changing market conditions
- Building cost-aware LLM routing with post-payment feedback learning
- NOT for: payment execution infrastructure (use x402/AP2/ACP directly); human-operated purchasing decisions
Core Process / Workflow
The Agent-Native Payment Decision Problem
An autonomous buyer interacts with K payable providers over T rounds, starting with wallet balance B₀ = B:
Key constraints:
- Can only select from affordable providers (price ≤ remaining wallet)
- Observe outcomes only for selected provider (chosen-only paid feedback)
- Provider reliability and prices may change without announcement
- Must run continuously without human resetting or retuning
The 402Pilot Decision Layer Architecture
PA-DCT: Payment-Aware Discounted Contextual Thompson Sampling
Three core mechanisms:
- Discounted Utility and Cost Posteriors
- Maintains Bayesian posteriors over provider utility (Q-posterior) and cost (C-posterior) per provider-context pair
- Common discount factor γ applies to all cells each round (forgets stale evidence)
- Normal-Normal conjugate model with configurable priors
- Payment-Aware Selection Rule
- Thompson sample utility and cost from posteriors
- Combine into payment-aware reward:
r̂ = (1 - λ_norm) × û - λ_norm × ĉ_normalized - As wallet pressure increases, selection shifts from quality-focused to cost-focused
- Select provider with highest sampled reward from affordable set
- Post-Payment Learning
- After transaction: observe realized utility (quality - failure penalty) and receipt cost
- Update only the selected provider-context cell's posteriors
- All cells discounted each round (non-stationary adaptation)
Wallet Pressure Formula
- Rises when spending runs ahead of plan
- Falls when spending runs behind
- Exponential form keeps pressure positive and smooth
Key Hyperparameters
| Parameter | Value | Role | |
|---|---|---|---|
| γ (discount) | 0.999 | Effective memory ~1000 rounds; balances responsiveness with stability | |
| ν (failure penalty) | 0.5 | Makes billed failures materially worse without overwhelming utility signal | |
| c_max (cost normalizer) | $0.01 | Maps highest listed price to 1.0 | |
| α (pressure sensitivity) | 2.0 | Controls how aggressively spending deviations increase pressure | |
| λ₀ (baseline pressure) | 1.0 | Initial pressure when spending is on plan |
Performance Evidence (402Pilot-Bench: 823 tasks, 5 providers, 3 scenarios, 30 seeds)
| Scenario | PA-DCT Quality | Budget Used | PA-gap/T | Best Baseline PA-gap/T | |
|---|---|---|---|---|---|
| S1 Stationary | 0.797 | 42% | 0.133 | 0.101 (Always-P-mid) | |
| S2 Reliability shock | 0.761 | 43% | 0.166 | 0.164 (Always-P-cheap) | |
| S3 Price shock | 0.831 | 39% | 0.121 | 0.195 (LinCBwK-Adapt) |
Key finding: PA-DCT maintains competitive quality while using only 39-43% of wallet, and achieves best non-oracle PA-gap/T in price-shock scenario. None of the baselines simultaneously maintains budget discipline AND adapts across reliability and price changes.
Ablation: Component Roles
| Component Removed | Effect | |
|---|---|---|
| Payment-aware ranking (-P) | Exhausts wallet in S1/S2; PA-gap/T jumps from 0.166 to 0.878 in S2 | |
| Discounting (-D) | Slows S2 recovery by 53% (1,467→2,249 rounds) | |
| Contextual bucketing (-C) | Delays S3 adaptation from 200 to 398 rounds | |
| Thompson sampling (-TS) | Increases S1 PA-gap/T std from 0.004 to 0.046; delays S3 adaptation to 2,232 rounds | |
| Learned realized costs (-C_post) | Eliminates price adaptation; P-premium selection drops from 66.1% to 3.6% |
Decision Framework: When to Use PA-DCT vs Alternatives
| Situation | Recommended Policy | Why | |
|---|---|---|---|
| Stable market, known good provider | Fixed-arm (Always-P-mid) | No exploration cost; best when market matches | |
| Reliability shocks expected | PA-DCT | Discounting enables adaptation; payment-aware preserves solvency | |
| Price changes expected | PA-DCT | Learned realized costs enable reallocation; best PA-gap/T | |
| Strict budget, no adaptation needed | Contextual BTS | Preserves wallet but doesn't adapt to market changes | |
| Quality maximization, unlimited budget | LinCBwK-Adapt | Higher quality but consumes 93-100% of wallet | |
| Simple cost-aware routing | PM-Greedy | Uses listed prices; doesn't learn realized costs |
References
- See references/evidence-base.md for full evidence: problem formulation, 402Pilot architecture, PA-DCT algorithm details, 402Pilot-Bench benchmark design, provider set, scenario design, complete results tables, ablation study, sensitivity analysis, theoretical analysis (regret bounds, adaptation rate), x402 integration witness, A-Tech applications.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingai-agents-and-workflows/402pilot-buyer-side-payment-decision/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/hamishfromatech/my-personal-skills-library/402pilot-buyer-side-payment-decision)