A Dynamic Loyalty Engine for rational, autonomous retention
When machines make purchasing decisions, loyalty must become measurable.
In an AI-mediated market, customer-side agents continuously compare SaaS vendors and select the option with the highest measurable utility. Brand attachment and past satisfaction no longer guarantee renewal. Even a small difference in price or features can trigger a switch.
That creates a two-sided problem:
| For customers | For SaaS startups |
|---|---|
| Decisions may ignore the value of a proven relationship | Revenue depends heavily on predictable renewals |
| Switching introduces migration, integration, and reliability risk | Customers can switch with very little friction |
| A marginally cheaper offer may not be better overall | Traditional loyalty programs do not influence AI agents |
| Constant comparison creates decision churn | Churn becomes frequent and difficult to forecast |
AI × AI Negotiation addresses this paradox by replacing emotional loyalty and reactive discounting with structured, real-time negotiation between autonomous agents.
The Dynamic Loyalty Engine brings two agents together at renewal:
- Customer AI Agent evaluates every vendor using total utility—not price alone.
- Business AI Agent detects churn risk early and prepares an optimized counter-offer.
- Negotiation Engine exchanges structured proposals within business guardrails.
- Loyalty Engine learns from successful renewals and strengthens rational preference over time.
The result is a renewal process that protects customer value, preserves margins, and makes recurring revenue more stable.
Loyalty is transformed from emotional attachment into a computational preference built through consistent value delivery.
flowchart LR
A[Monitor usage and renewal timing] --> B[Predict churn risk]
B --> C[Customer AI evaluates alternatives]
C --> D[Business AI generates an optimized offer]
D --> E[Customer AI recalculates total utility]
E -->|Renew| F[Update loyalty score]
E -->|Counter| D
E -->|Switch| G[Record outcome and learn]
F --> A
G --> A
| Phase | What happens |
|---|---|
| 1. Monitor | Engagement, usage trends, contract context, and renewal timing are tracked. |
| 2. Detect risk | The Business AI estimates churn probability before the renewal date. |
| 3. Evaluate | The Customer AI ranks vendors using price, features, reliability, switching cost, and risk. |
| 4. Negotiate | The Business AI creates a value-optimized counter-offer within margin guardrails. |
| 5. Decide | The Customer AI recalculates utility and chooses to renew, counter, or switch. |
| 6. Reinforce | A successful renewal updates the loyalty score and informs the next cycle. |
The prototype demonstrates the complete AI-to-AI retention loop: renewal monitoring, churn-risk analysis, structured negotiation, decision tracking, and analytics.
flowchart TB
UI[Web Portal and Analytics Dashboard]
API[Python FastAPI Backend]
AI[FastAPI AI Negotiation Service]
DB[(PostgreSQL)]
UI -->|REST| API
API -->|Negotiation request| AI
AI -->|Offer and decision| API
API --> DB
The repository is split into focused services:
ai-negotiation/
├── ai-service/ # FastAPI agents and negotiation engine
├── backend/ # Python API, persistence, and analytics
├── frontend/ # Customer portal and dashboard
├── infra/ # Docker and Kubernetes assets
├── docs/ # Architecture and protocol documentation
└── docker-compose.yml # Local full-stack orchestration
| Layer | Stack |
|---|---|
| Experience | HTML, CSS, JavaScript |
| Business API | Python, FastAPI, SQLAlchemy |
| AI negotiation | Python, FastAPI, Pydantic |
| Data | PostgreSQL |
| Infrastructure | Docker, Docker Compose, Kubernetes |
- Docker with Docker Compose
- Python 3.11+
pipavailable for Python package installation- Ports
8080,8000, and5432available
git clone https://github.com/SachinRam18/AIxAI-Negotiation-System.git
cd AIxAI-Negotiation-System
docker compose up --buildOnce the services are healthy:
| Service | Address |
|---|---|
| Python Backend API | http://localhost:8080 |
| AI negotiation service | http://localhost:8000 |
| FastAPI health check | http://localhost:8000/health |
| FastAPI interactive docs | http://localhost:8000/docs |
cd ai-service
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 8000Open a second terminal:
cd backend
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
set DATABASE_URL=sqlite:///./aixai.db
set AI_SERVICE_URL=http://localhost:8000
uvicorn app.main:app --host 0.0.0.0 --port 8080Open frontend/index.html directly in your browser, or serve it from a lightweight static server.
- The backend expects the AI service on
http://localhost:8000by default. docker compose up --buildis the fastest full-stack local setup for development.- For a production deployment, update the database and AI service URLs before launch.
| Outcome | How the engine creates it |
|---|---|
| Revenue stability | Detects churn early and negotiates before switching occurs. |
| Lower churn | Improves total utility through targeted counter-offers. |
| Better acquisition ROI | Extends customer lifetime after onboarding. |
| Margin protection | Prefers features, flexibility, and risk reduction before discounts. |
| Faster decisions | Automates the negotiation loop and removes manual back-and-forth. |
| Better customer experience | Delivers relevant, optimized offers at the right moment. |
| Data-driven retention | Uses behavior and renewal history instead of intuition alone. |
| Competitive resilience | Reduces sensitivity to small competitor price changes. |
| Compounding loyalty | Makes each successful renewal inform and strengthen the next. |
Why would a Customer AI accept negotiation?
A Customer AI is designed to optimize value, not finalize its first comparison blindly. If a better outcome is computationally possible, evaluating a counter-offer is part of its objective. Negotiation is therefore an optimization step, not an emotional concession.
Will the Customer AI always switch for a lower price?
No. Total utility also includes switching cost, implementation effort, integration risk, reliability, service quality, and uncertainty. Once those factors are included, remaining with an improved incumbent offer can be the rational choice.
Is this just dynamic discounting?
No. Discounting can erode margins and trigger price wars. The engine prioritizes feature upgrades, contract flexibility, service improvements, and risk reduction. Price is a guarded final lever—not the entire strategy.
- SaaS startups operating subscription-based business models
- B2B software providers facing intense renewal competition
- Revenue and customer-success teams seeking proactive retention
- Organizations preparing for autonomous, agent-mediated procurement
Built by Team PentOps for the Loyalty Paradox theme.



