Skip to content

byteStealthX/autoretry

Repository files navigation

🧠 Autoretry

Self-Healing Background Jobs with AI Intelligence

A demonstration of the Motia unified backend framework.

Motia Agentic Layer

🚀 Overview

The Motia Agentic Layer is an intelligent orchestration system that transforms standard background job retries into a smart, decision-making process. Instead of blindly retrying failed jobs, this system uses an AI Brain to analyze errors, understand context, and make optimal recovery decisions.

It features a Polyglot Architecture running TypeScript, Python, and JavaScript seamlessly in a single runtime, visualized by a real-time React Dashboard.

✨ Key Features

🤖 Agentic Intelligence

  • Smart Decision Engine: Classifies errors (Network, Timeout, Logic, Resource) and selects the best strategy (Retry, Backoff, Abort, Escalate).
  • Short-Term Memory: "Remembers" recent failures to detect patterns and prevent retry loops.
  • AI Explanations: Uses OpenAI (GPT-4) to generate human-readable root cause analysis.

🌐 Polyglot Runtime

Three languages, one workflow:

  1. TypeScript: High-performance API Gateway.
  2. Python: Data processing and AI integration.
  3. JavaScript: Lightweight logging and notification.

📊 Live Dashboard

  • Real-time visualization of job states.
  • Detailed timeline of every execution attempt.
  • Insight into the "Brain's" decision-making process.

🛠️ Tech Stack

  • Core: Motia (Unified Backend Framework)
  • Languages: TypeScript, Python 3.10+, JavaScript
  • AI: OpenAI API
  • State/Queue: Redis
  • UI: React + Tailwind CSS
  • Deployment: Docker / Railway

🚦 Quick Start

Prerequisites

  • Node.js 18+
  • Python 3.10+
  • Redis (running locally or cloud)
  • OpenAI API Key

Installation

# 1. Clone the repo
git clone https://github.com/byteStealthX/autoretry.git
cd autoretry

# 2. Install dependencies (Node + Python)
npx motia install

# 3. Configure Environment
cp .env.example .env
# Edit .env and add your OPENAI_API_KEY

Running Locally

# Start the Unified Dev Server
npm run dev

Visit http://localhost:3000 to open the Workbench & Dashboard.

🧪 Testing the Flows

1. The Polyglot Flow via API

# Triggers TS -> Python -> JS flow
curl http://localhost:3000/hello

2. The Agentic Job Flow

# Starts a background job that may fail and trigger AI analysis
curl -X POST http://localhost:3000/run-job

📂 Project Structure

src/
├── agentic/               # The "Brain" of the system
│   ├── decision-engine.ts # Logic for recovery strategies
│   ├── memory-store.ts     # Failure pattern tracking
│   └── explanation-engine.ts # AI analysis integration
├── hello/                 # Business Logic Steps
│   ├── hello-api.step.ts  # TS API Endpoint
│   ├── process_greeting_step.py # Python Processor
│   └── run-job.step.ts   # Job Trigger
└── dashboard/             # React UI

☁️ Deployment

Ready to deploy? This project is Docker-ready.

Deploy to Railway:

  1. Fork this repo.
  2. New Project -> Deploy from GitHub.
  3. Add OPENAI_API_KEY and Redis.

Built with ❤️ using Motia.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published