Skip to content

A proof of concept for Continuous Learning in AI Agents using LangGraph and Reflexion technique. The agent learns from mistakes and transfers knowledge to new tasks via long-term memory. πŸ§ πŸ€–

Notifications You must be signed in to change notification settings

alipyth/Continuous-Learning-AI-PoC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 

Repository files navigation

🧠 Continuous Learning Agent with Reflexion & LangGraph

Python LangChain LangGraph License

πŸ“œ Overview

This project is a Proof of Concept (PoC) for building Agentic AI systems capable of Continuous Learning.

Unlike traditional LLM chains that reset their state after every interaction, this agent possesses a persistent Long-Term Memory. It uses the Reflexion technique to analyze its own mistakes, extract general rules/lessons, and store them on the disk. When faced with new tasks, it recalls these lessons to avoid repeating past errors.

Built using LangGraph, it demonstrates a cyclic graph architecture rather than a linear chain.


πŸš€ Key Features

  • πŸ”„ Reflexion Loop: The agent acts, receives feedback from the environment, and reflects on why it failed before trying again.
  • πŸ’Ύ Long-Term Memory: Lessons are stored in a JSON file (agent_memory.json), allowing knowledge to persist across different execution sessions.
  • 🧠 Knowledge Transfer: The agent applies constraints learned in "Task A" to "Task B" automatically.
  • πŸ›‘οΈ Robust Parsing: Includes a smart validation node that handles various code formats outputted by LLMs.

πŸ—οΈ Architecture

The system is modeled as a State Graph with three main nodes:

  1. Generator (Agent): Generates Python code. It reads the Long-Term Memory before generating to ensure it respects previously learned rules.
  2. Validator (Environment): Executes the code and checks against specific rules (e.g., "Sum must be 100", "Number 50 is forbidden"). It acts as a simulator.
  3. Reflector (Critic): Triggered only upon failure. It translates raw error messages into high-level "Lessons" and saves them to the memory file.

Work flow Diagram

graph TD
    Start([Start]) --> Generator
    Generator --> Validator
    Validator -- "Valid Output" --> Success([End / Success])
    Validator -- "Error / Invalid" --> Reflector
    Reflector -- "Save Lesson to JSON" --> Generator


Loading

About

A proof of concept for Continuous Learning in AI Agents using LangGraph and Reflexion technique. The agent learns from mistakes and transfers knowledge to new tasks via long-term memory. πŸ§ πŸ€–

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published