A self-curating persistent-memory agent that remembers, forgets, and explains what matters.
Qwen Cloud Global AI Hackathon β Track 1: MemoryAgent
MemoPilot IQ is a persistent-memory AI agent. Unlike a normal chatbot that only sees recent chat history, it has a dedicated MemoPilot memory-governance layer that extracts structured memories from conversations, stores them persistently, retrieves only the most relevant ones inside a strict token budget, updates and supersedes outdated memories, expires temporary ones, and shows a transparent Memory Trace explaining why each memory was used, ignored, updated, or forgotten.
- Executive summary
- Problem statement
- Key features
- Architecture
- How Qwen Cloud API is used
- How Alibaba Cloud is used
- Memory-governance algorithm
- Forgetting engine
- Setup & local run
- Environment variables
- Alibaba deployment
- API docs
- Testing
- Demo script
- Evaluation results
- Judging criteria mapping
- Screenshots
- License
Submission release gate: docs/submission_readiness.md. Submission package: SUBMISSION.md Β· editable presentation deck Β· Alibaba deployment handoff.
MemoPilot IQ autonomously accumulates experience across conversations. It remembers user preferences, project decisions, mistakes, goals, constraints and deadlines, and makes increasingly accurate decisions across multi-turn and cross-session interactions. It demonstrates sophisticated use of Qwen Cloud APIs, an Alibaba Cloud persistence/deployment adapter, a custom memory scoring engine, selective forgetting, a clean modular architecture, an evaluation benchmark, and a transparent UI.
It runs in two modes:
- LOCAL_MODE β SQLite + in-process vectors; runs on a laptop with no cloud keys thanks to a deterministic offline fallback for Qwen.
- ALIBABA_CLOUD_MODE β Alibaba Cloud Tablestore + OSS, activated automatically when cloud credentials are present.
The current mode is always visible in the UI header and on GET /health.
AI assistants forget everything between sessions. Developers and students re-explain their stack, decisions and constraints repeatedly, and assistants keep giving outdated advice after a decision changes (e.g. switching frameworks). MemoPilot IQ fixes this with a persistent, self-curating memory layer that knows what to remember, what to forget, and can prove its reasoning.
Implementation note: Memory priority never overrides the configured token budget; the reflection feature consolidates memories but does not train model weights; the diagnostic suite has 24 scenarios; and Alibaba deployment is considered complete only after a live deployment has been evidenced.
- π§ Structured memory extraction (12 types) via a Qwen "Memory Editor" β not raw chat logs.
- π― Custom scoring formula blending semantics, importance, recency, usage, project match, criticality and penalties.
- π Hybrid retrieval β dense embeddings + sparse keyword/tag overlap + structured filters.
- π Context budget manager β strict 2,500-token budget; critical/pinned memories are prioritized.
- β»οΈ Forgetting engine β expire deadlines, archive stale memories, supersede contradicted decisions (non-destructive).
- πͺ Memory Trace β see exactly which memories were injected/skipped, their scores, reasons and token cost.
- π Evaluation dashboard β a 24-scenario diagnostic against a no-memory baseline.
- π§ Reflection engine β a self-improvement pass that merges duplicates, promotes frequently-used memories, and derives higher-level insights.
- πΈοΈ Live Memory Graph β interactive visualization of memories with supersession/related edges, critical rings, and insight nodes.
- π Analytics dashboard β memory growth, type/status distribution, forgetting rate, token savings.
- π Secret-safe β secrets are redacted before storage; never committed.
- βοΈ Local β Alibaba Cloud dual mode with automatic fallback.
- β
CI + Docker β GitHub Actions (tests + build) and one-command
docker compose up. - π Production platform β optional API-key auth, per-key rate limiting,
Prometheus
/metrics, paginated + filtered memory API, per-memory audit history, and a two-stage rerank that bounds expensive hybrid scoring after tenant-scoped candidates are loaded. - π Python SDK β embed the MemoPilot memory layer in any agent in a few lines (sdk/python).
- π¬ LoCoMo harness β evaluate on the standard long-conversation memory benchmark used by Mem0/Zep, with F1/EM grading and a model-independent evidence-recall metric (docs/locomo.md).
See docs/architecture.md for the full Mermaid diagram and request lifecycle. Rendered diagram: assets/architecture.svg (Mermaid source: assets/architecture.mmd).
User β React + Vite frontend β FastAPI backend β MemoPilot memory layer
MemoPilot memory layer β Qwen Cloud chat API
MemoPilot memory layer β Qwen embedding API
MemoPilot memory layer β Alibaba Tablestore (or SQLite locally)
MemoPilot memory layer β Alibaba OSS (logs / snapshots / eval reports)
MemoPilot memory layer β Context Builder β Qwen Cloud β Response + Trace
All AI calls go through backend/app/qwen_client.py
against the DashScope OpenAI-compatible endpoint:
- Chat / reasoning β
qwen-plus(configurable) generates the final answer from the budgeted memory context. - Memory extraction β JSON-only "Memory Editor" prompt returns structured
new_memories,updates, andforgetactions. - Embeddings β
text-embedding-v3powers semantic retrieval.
If QWEN_API_KEY is unset, a deterministic offline implementation keeps the
whole app, tests and benchmark working end-to-end.
- Tablestore β persistent memory + event store (
store_alibaba.py). - OSS β raw turn logs, memory snapshots, eval reports (
oss_client.py). - Deployment β Docker image +
serverless.yamlfor ECS / Function Compute / ACK. Full guide & proof checklist: docs/deployment_alibaba.md. The final cloud, benchmark, video, deck, and public-link gates are tracked in docs/submission_readiness.md.
Full detail (scoring weights, retrieval, extraction, states/types) in docs/memory_algorithm.md. The scoring formula:
final_score = 0.40*semantic + 0.20*importance + 0.15*recency + 0.10*confidence
+ 0.10*usage + 0.15*project_match + 0.20*critical_bonus
- 0.30*outdated - 0.25*privacy - 0.50*superseded
Expires deadlines/temporary memories, archives unused low-importance memories after 30 days, and supersedes contradicted decisions. Nothing is silently hard-deleted β superseded/expired memories remain on the timeline but are never injected into context. Users can Pin, Archive, Forget, Export, and Forget-all.
Prerequisites: Python 3.11+ and Node 18+.
cd backend
python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000cd frontend
npm install
npm run dev # http://localhost:5173 (proxies /api to :8000)The frontend uses React Router:
/β professional product landing page (hero, problem/solution, features, architecture flow, demo scenario, evaluation preview, hackathon compliance)./appβ the MemoryAgent dashboard (Chat, Memory Trace, Graph, Timeline, Analytics, Evaluation, Controls, Settings), with a one-click Judge Demo. Reached via Launch App, with a β Home link back to the landing page./demoβ alias that redirects to/app.
npm install # installs concurrently
npm run dev # starts backend + frontend togetherdocker compose up --build # backend :8000 + frontend :5173CI runs the backend tests and frontend build on every push β see .github/workflows/ci.yml.
# macOS/Linux:
cd backend && SEED_DEMO=1 uvicorn app.main:app --port 8000
# Windows PowerShell:
cd backend; $env:SEED_DEMO=1; uvicorn app.main:app --port 8000No Qwen/Alibaba keys are required to run locally β the app starts in
LOCAL_MODE with the offline Qwen fallback.
Copy .env.example to backend/.env and fill in real values
(placeholders only in the example; .env is git-ignored).
| Variable | Purpose |
|---|---|
APP_MODE |
local or alibaba |
QWEN_API_KEY / QWEN_BASE_URL |
Qwen Cloud auth + endpoint |
QWEN_CHAT_MODEL / QWEN_EMBEDDING_MODEL |
Qwen models |
ALIBABA_ACCESS_KEY_ID/SECRET/REGION |
Alibaba Cloud credentials |
ALIBABA_OSS_BUCKET/ENDPOINT |
OSS storage |
ALIBABA_TABLESTORE_ENDPOINT/INSTANCE |
Tablestore memory store |
MEMORY_STORE |
sqlite or alibaba |
DATABASE_URL |
SQLite path for local mode |
FRONTEND_ORIGIN |
Frontend CORS origin, comma-separated origins, or * for a public demo |
MEMORY_TOKEN_BUDGET / RETRIEVAL_TOP_K |
Context budget and retrieval depth |
EVAL_MAX_CONCURRENCY |
Concurrent model calls during evaluation (default 4, maximum 8) |
MEMOPILOT_API_KEYS / RATE_LIMIT_PER_MINUTE |
Optional API auth and rate limit |
See docs/deployment_alibaba.md for ECS (Docker),
Function Compute (serverless.yaml) and ACK instructions, plus the proof
checklist (health screenshot, Tablestore rows, OSS objects).
Interactive OpenAPI docs at http://localhost:8000/docs.
| Method | Path | Description |
|---|---|---|
| GET | /health |
Status, mode, Qwen/store configuration |
| POST | /api/chat |
Memory-augmented chat; returns answer + used memories + actions + trace + mode |
| GET | /api/memories |
List memories by user/project |
| POST | /api/memories |
Create a memory manually |
| PATCH | /api/memories/{id} |
Pin / archive / edit / change status |
| DELETE | /api/memories/{id} |
Delete (soft by default, ?hard=true to remove) |
| GET | /api/memories/timeline |
Memory event timeline |
| GET | /api/memories/export |
Export memories as JSON |
| POST | /api/memories/forget-all |
Clear all memories for a project |
| POST | /api/memory/extract |
Run extraction manually |
| GET | /api/memories/{id}/history |
Per-memory audit trail (all lifecycle events) |
| GET | /metrics |
Prometheus metrics (requests, latency, 401/429 counters) |
| POST | /api/eval/run |
Run the benchmark |
| POST | /api/eval/ablation |
Run the governance ablation study |
| GET | /api/eval/report |
Latest evaluation report |
| POST | /api/demo/run |
Run the scripted 4-session judge demo |
| GET | /api/trace/{session_id} |
Latest Memory Trace for a session |
| POST | /api/reflect |
Run the reflection / consolidation pass |
| GET | /api/analytics |
Aggregate memory analytics |
| GET | /api/graph |
Memory graph nodes + edges |
Production hardening (all optional, zero-friction locally): set
MEMOPILOT_API_KEYS=key1,key2 to require an X-API-Key header on /api/*,
and RATE_LIMIT_PER_MINUTE (default 120) for per-key/IP rate limiting.
GET /api/memories supports type, status, q (text search), limit,
offset. See sdk/python for the embeddable client.
cd backend
python -m pytestFrontend type-check / build:
cd frontend && npm run buildThe under-3-minute walkthrough is in docs/demo_script.md. The Chat tab has four starter buttons that replay the 4-session demo.
Run Evaluation β Run benchmark in the UI, or POST /api/eval/run.
The report records the configured model, strict keyword evaluator, retrieval
depth, context recall, stale-memory leaks, historical-context token reduction,
and latency for that run. Results depend on the selected model and are not
hard-coded in the landing page. See
docs/evaluation_results.md for the protocol and
reporting checklist.
See docs/judging_mapping.md for the full rubric and rule-compliance checklist.
Before submission, add captures of the landing page (/), Chat + Trace,
Timeline, Evaluation dashboard, and a real Alibaba /health response to
assets/. Do not add cloud-proof captures until the deployment is live.
MIT.