Inspiration

Payments fail constantly—due to bank downtimes, network drops, insufficient funds, or expired cards—and a large share of that lost revenue is recoverable if merchants respond intelligently instead of relying on blind, static retry schedules. While researching recovery systems like Stripe Smart Retries, I wanted to build an open, event-driven system for PayPal that pairs machine learning policy scoring with an LLM agent capable of understanding customer context, negotiating payment timelines, and knowing when to escalate to a human.

What it does

Renvue is an autonomous Revenue Recovery & AI Dunning System built on the PayPal Developer Platform. When a PayPal payment fails, Renvue ingests the webhook event, evaluates the optimal recovery strategy using a LightGBM policy scoring engine, generates PayPal recovery checkout links, and manages multi-turn customer follow-ups—extracting relative promise-to-pay dates, dynamically rescheduling retries, and escalating hostile or high-risk cases to human operators with full audit trails.

How we built it

Event-Driven Ingestion & Settlement (PayPal Sandbox + FastAPI): PayPal webhooks serve as the system's entry point. When a failure occurs, FastAPI ingests the event, creates a recovery case in PostgreSQL, and generates PayPal payment links for one-click customer recovery.

Cost-Aware Routing (Deterministic + LightGBM + LangGraph): Because invoking an LLM for every event is expensive and unnecessary, Renvue routes standard recovery decisions through deterministic rules and a LightGBM policy model trained on historical outcomes to predict recovery probability and expected net yield across channels and ticket sizes.

Stateful Async Agent & Scheduler (LangGraph + Taskiq + Redis): When a customer replies, a provider-agnostic LangGraph agent (supporting OpenRouter, Groq, Mistral, and Gemini) classifies intent, extracts promise-to-pay dates, or escalates edge cases to human review. Taskiq and Redis schedule future wake-ups so the agent resumes days later with full historical context.

Operational Workbench & Telemetry (React + AG Grid + AG Charts): Operators can filter high-volume failed cases by failure reason and ticket size in AG Grid, inspect step-by-step audit logs, test policy parameters in the Agent Lab, and analyze touch-to-recovery conversion and revenue at risk via AG Charts.

Challenges we ran into

Async vs. Sync Execution Mismatches: The FastAPI server, database layer, and LangGraph agent workflows were fully asynchronous, while my initial background worker setup with Celery was synchronous—causing event-loop friction and race conditions. Migrating to Taskiq unified the entire execution pipeline around native asyncio.

LLM Date Hallucinations & Guardrails: Early versions of the promise-to-pay extractor could be gamed by adversarial inputs (e.g., a customer replying "I will pay in 2047") or hallucinate invalid dates. I added strict relative-date validation bounds, confidence guardrails, and automatic human-in-the-loop escalation triggers.

Safe Model Retraining: Running nightly LightGBM retraining directly against live inference risked destabilizing active scoring, so I introduced external feature flags and controlled retraining toggles to decouple model updates from live worker execution.

Accomplishments that we're proud of

Building a fully asynchronous, event-driven agentic dunning pipeline with strict guardrails, human-in-the-loop escalation, and complete event-level auditability.

Closing the feedback loop between agent actions and machine learning policy scoring—turning raw PayPal webhook events into actionable telemetry in AG Grid and AG Charts.

What we learned

When not to use an LLM: LLMs excel at unstructured customer replies and promise-to-pay intent extraction, while tabular ML (LightGBM) and deterministic rules are faster, cheaper, and more predictable for retry policy scoring.

Operational Control & Observability: External feature flags, strict input guardrails, and transparent audit trails are what make an autonomous agent trustworthy and debuggable in production.

What's next for Renvue

Event Streaming with Apache Kafka: Replacing simple webhook queueing with Kafka partitions to handle high-throughput merchant payment bursts with stronger replay guarantees.

Bandit & Uplift Modeling: Expanding the LightGBM policy engine into contextual bandits to continuously test and optimize message tone, channel selection, and retry intervals.

Built With

Share this project:

Updates

Submission history