GitHunt
BI

biubiutomato/TME-Agent

TME: Structured memory engine for LLM agents to plan, rollback, and reason across multi-step tasks.

🧠 Task Memory Engine (TME)

Task Memory Engine (TME) is a structured memory framework for LLM-based agents, enabling multi-step task planning, rollback, replacement, and graph-based reasoning.


πŸ“„ About This Repository

This repository contains prototype code for two research versions of TME:

⚠️ Disclaimer: This is a reference implementation aligned with the above papers. v1 and v2 are conceptually related but structurally distinct. The repository is under active development, and modules may change before final release.


πŸš€ Quick Start

1. Install Dependencies

pip install openai
pip install python-dotenv  # if using .env to manage openai keys (recommended)

2. Set Your OPENAI API Key

export OPENAI_API_KEY=your_key_here

Or use a .env file:

OPENAI_API_KEY=your_key_here

3. Run Example Cases

Test cases are .json files in the cases/ directory, each containing a sequence of user instructions.
Test cases are running on ChatGPT-4o model.

Case File Description Mode
✈️ Travel Planning cases/travel_planning_case.json Multi-step travel booking general
πŸ§‘β€πŸ³ Cooking Planner cases/cooking_case.json Recipe steps, edits, substitutions general
πŸ“… Meeting Scheduling cases/meeting_scheduling_case.json Rescheduling multi-user meetings general
πŸ›’ Cart Editing cases/cart_editing_case.json Add/remove items, undo operations cart

Run Commands:

# Run with default classifier (general)
python run_case.py cases/trip_planning_case.json
python run_case.py cases/cooking_case.json
python run_case.py cases/meeting_scheduling_case.json

# Run cart case with specialized intent_classifier
python run_case.py cases/cart_editing_case.json --mode cart

🧠 Key Features

  • Task Memory Tree (TMT): Hierarchical, structured task memory
  • Rollback / Replace: Update or revert previous decisions
  • Graph Reasoning (DAG): Non-linear dependencies between subtasks
  • Instruction Decomposer: LLM-based substep splitting
  • TRIM (Task Relation Inference Module): Classify task relations (merge, depend, rollback, etc.)
  • Memory-Aware QA: Answer queries like β€œwhat’s currently in memory?”

πŸ—οΈ System Architecture

TME processes user inputs into a structured graph of subtasks, preserving history, dependencies, and intent transitions. Below are the architectural diagrams for v1 and v2:

  • TME v1 Architecture: Illustrates the tree + graph memory framework with slot-based task tracking.
    TME v1 Architecture

  • TME v2 Architecture: Depicts the structured memory system with DAG dependencies and memory-aware QA.
    TME v2 Architecture
    TME v2 Workflow

Directory Structure

TME-Agent/
β”œβ”€β”€ run_case.py                         # Main script to execute test cases
β”œβ”€β”€ cases/                              # JSON input files for test scenarios
β”œβ”€β”€ assets/                             # Architecture diagrams
β”œβ”€β”€ v2/
β”‚   β”œβ”€β”€ TaskMemoryStructure.py          # TaskNode & TaskMemoryTree logic
β”‚   β”œβ”€β”€ input_splitter.py               # LLM-based instruction decomposition
β”‚   β”œβ”€β”€ trim.py                         # Task relation reasoning (TRIM)
β”‚   β”œβ”€β”€ intent_classifier_general.py    # General classifier (default)
β”‚   └── intent_classifier_specific/
β”‚       └── intent_classifier_cart.py   # Cart-specific classifier
β”œβ”€β”€ citation.bib
└── README.md

πŸ›‘οΈ License & Usage

This project is licensed under the Polyform Noncommercial License 1.0.0.

  • Free for academic and personal use.
  • For commercial use, please contact the author directly for a license. πŸ“§ Contact: biubiutomato@gmail.com

🌟 Star, Cite, Collaborate

If this project inspires or assists you, please consider:

  • ⭐ Starring the repository
  • 🧡 Opening discussions or issues
  • πŸ“š Citing the relevant paper(s)

Let’s build memory-aware LLM agents together!