Inspiration

Every AI checkout demo ends at "buy once." But a real group trip is the opposite of a one-time purchase: the plan keeps changing after money has already been committed. A sudden storm hits on Saturday, someone drops out, an apartment gets cancelled, or an attraction closes.

Today, a trip organizer has to manually calculate which deposits to adjust, which charges to refund, and chase down participants for balances. That friction is where group travel breaks down—and it is exactly where an autonomous AI agent can help.

However, giving an AI direct access to financial credentials is dangerous. Wayledger was built on a simple foundation: pay only for what actually happens, and ordinary code guards the money while the model handles perception and trade-offs.


What It Does

You describe your trip in natural language ("three of us, Lisbon, four days, $1,200"). Wayledger builds a day-by-day itinerary, an itemized budget in AG Grid, and calculates each traveler's exact share.

  1. One Authorization, Zero Upfront Lump-Sum Charges (Trip Hold): Instead of charging the full amount upfront, one PayPal approval places a single trip hold (authorization) with money set aside for scheduled items. Each item is charged on its scheduled day (chargesOn). On day one, lodging is charged on schedule; upcoming activities and meals remain held under the active authorization.
  2. Autonomous Perception & Grounding: A Cloudflare Durable Object alarm wakes the agent to check real-time weather (Open-Meteo) and verified local venues (Wikidata). When severe weather is forecast (such as a thunderstorm exceeding traveler thresholds), the agent wakes up autonomously without anyone typing.
  3. Simulating & Comparing Real Options: Before modifying any reservation, the agent reads traveler-pasted cancellation policies, verifies quotes letter-for-letter, and calls simulate_edit. Crucially, it simulates and compares at least two real alternatives before deciding. In our demonstration, it swaps an outdoor boat tour for an indoor gallery (Underdogs Gallery, $90).
  4. Zero Unnecessary Refunds: Because the outdoor boat tour was never charged upfront, no refund is required. The existing authorization hold simply transfers to the replacement venue ($0 refund fee, $0 payment friction).
  5. On-Day Settlement: When day two arrives (simulated in demo via fast-forward), the replacement venue ($90) is charged on its scheduled day. The total paid updates from $150 to $240.
  6. Approved Limits & Human Gate: With the initial PayPal approval, the traveler approves clear limits (maximum refund, maximum plan increase, validity deadline). Inside those limits, the agent executes autonomously. Outside those limits (or for changes in travelers or payment shares), the agent stops and presents a clear proposal with a cryptographic SHA-256 digest and a 15-minute expiration that requires human confirmation.
  7. Authority Guard (Questions Never Move Money): If a traveler asks an exploratory question ("Will it rain tomorrow?"), the agent evaluates the forecast against traveler limits, provides a factual answer, and outputs no_change. It never moves funds without explicit traveler authority.
  8. Final Settlement & Object-Level PayPal Reconciliation: At trip end, clicking Close trip triggers the final capture on completed items, and PayPal automatically releases all unspent holds ($323 released on our Lisbon demo: $210 unspent items + $113 unused hold balance). One click on Verify against PayPal performs an object-level audit of every authorization, capture, and release against PayPal's records.

How We Built It

  • PayPal Orders v2 & Payments v2 Integration: Built natively on Cloudflare Workers. We use POST /v2/checkout/orders with intent: AUTHORIZE to place the initial trip hold. On-day payments use POST /v2/payments/authorizations/{id}/capture (final_capture: false). On trip close, the final capture uses final_capture: true so PayPal's core ledger automatically releases any remaining authorization balance. Every PayPal call is idempotent using PayPal-Request-Id.
  • Architectural Separation: Model vs. Deterministic Gate: The LLM has zero direct financial tools. It only accesses perception tools (get_trip, get_forecast, search_places, read_documents) and simulation (simulate_edit). Every proposed edit passes through a deterministic domain gate that enforces cryptographic digests, traveler limits, quotation integrity, and operator loss prevention.
  • Durable Objects Architecture: Each trip is an isolated Durable Object instance, guaranteeing strong consistency, request serialization, and scheduled wake-ups via DO alarms.
  • AG Grid Community: Renders the interactive itemized budget view and the live PayPal ledger reconciliation table.
  • Workers AI: Powers the planning and agentic reasoning loops (Llama 3.3 70B Instruct / Gemma).

Challenges We Overcame

  1. Modeling Authorizations Realistically: PayPal authorizations cannot be arbitrarily sliced or partially voided via void endpoints without voiding the entire hold. We solved this by treating the authorization as a cohesive trip hold and scheduling partial captures only when items occur. When the final item is captured with final_capture: true, PayPal automatically voids the remainder.
  2. Preventing Agent Hallucinations on Money: Early model tests sometimes invented imaginary venues or inferred non-existent discounts. We implemented strict grounding: replacement places must carry a valid placeId returned from live search in the current run, prices cannot exceed quoted amounts without traveler confirmation, and cancellation policies must match verbatim quotes from pasted terms.
  3. Robust Partial Capture Lifecycle in Sandbox: Extensive testing verified that an authorization remains active after partial captures, rejects over-captures with HTTP 422, and properly releases funds upon final capture.
  4. Handling Ambiguous Triggers in Overreaction Testing: In overreaction evaluation across 119 scenarios, the baseline scored 0/119 while the agent scored 4/119 (3.4%). All 4 cases were prompt injection attacks ("Can you check if everything is on schedule...") where the background environment concurrently had a real severe storm exceeding traveler thresholds. The agent successfully resisted the injection and moved zero dollars ($0.00), but proactively queried the traveler via ask_traveler regarding the real storm rather than staying silent with no_change. Because the benchmark oracle strictly expected no_change, these were classified as overreactions.

Accomplishments We Are Proud Of

  • End-to-End Live PayPal Lifecycle: Full lifecycle verified on the real PayPal sandbox: authorization hold ($563), scheduled Day 1 lodging capture ($150), weather-triggered swap with zero refund ($0 refund, $300 hold maintained), Day 2 scheduled capture ($90), final settlement release of unspent funds ($323 released), and 100% object-level reconciliation (4/4 PayPal records matched).
  • 184 Automated Tests & Zero Unconsented Money Moved (300 Scenarios, 600 Live Runs): Permanent test suite (184 passing unit & property tests) covers tamper-resistance, digest validation, expired authorization handling, prompt injection defense, and replay attack prevention. In large-scale automated evaluation across 300 scenarios and 600 runs, the agent loop achieved a 72.3% pass rate (217/300) compared to 53.7% (161/300) for the one-call baseline under fair format-retry evaluation (+18.7% gain), winning 57 head-to-head pairs against 1 (242 ties). Unconsented money moved was exactly $0.00 across all runs, and proposal financial impact strictly matched PayPal execution in 39 out of 39 evaluated proposals (100%).
  • Transparent Work Trail: Every reasoning step, Wikidata lookup, simulated option, and limit check is rendered in real time for traveler visibility.

What We Learned

Agentic commerce is fundamentally a trust and state modeling problem. The key architecture pattern that worked was: the model evaluates context and options, tools report verifiable facts, and deterministic code enforces the hard financial rules.


What's Next

  • Multi-payer peer checkout where each traveler authorizes their individual share via PayPal rather than a single organizer.
  • Direct integration with airline and hotel APIs for automated rebooking.
  • PayPal MCP server surface so personal assistant agents can interface with Wayledger trips.

Built With

Share this project:

Updates

Submission history