Google Cloud’s Always-On Memory Agent Replaces RAG and Embeddings With Continuous LLM Consolidation on Gemini 3.1 Flash-Lite
Most AI agents forget. They process a request, answer it, then drop the context. Google Cloud’s generative-ai repository now ships a sample that tackles this directly. It is the Always-On Memory Agent, a reference implementation that treats memory as a running process.
Always-On Memory Agent
Fundamentally, the project is a lightweight background agent that never stops. It runs 24/7 as a continuous process, not a one-shot call. It is built with Google ADK (Agent Development Kit) and Gemini 3.1 Flash-Lite. Notably, it uses no vector database and no embeddings. Instead, an LLM reads, thinks, and writes structured memory into SQLite. The model choice targets low latency and low cost for continuous background work.
How It Works: Ingest, Consolidate, Query
Architecturally, an orchestrator routes every request to one of three specialist sub-agents. Each sub-agent owns its own tools for reading or writing the memory store.
First, the IngestAgent handles incoming content. It uses Gemini’s multimodal capabilities to extract a summary, entities, topics, and an importance score. That structured record then lands in the memories table.
Next, the ConsolidateAgent runs on a timer, every 30 minutes by default. Like sleep cycles, it reviews unconsolidated memories and finds connections between them. Then it writes a synthesized summary, one key insight, and those connections to the database. Consequently, the agent builds new understanding while idle, with no prompt.
Finally, the QueryAgent answers questions. It reads all memories and consolidation insights, then synthesizes a response. Importantly, it cites the memory IDs it used as sources.
loading="lazy" scrolling="no"
style="width:100%;height:600px;border:0;border-radius:16px;overflow:hidden;display:block"
srcdoc="<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Always-On Memory Agent — Explainer</title>
<style>
:root{
–g-blue:#4285F4; –g-red:#EA4335; –g-yellow:#FBBC04; –g-green:#34A853;
–ink:#202124; –muted:#5f6368; –line:#dadce0; –bg:#ffffff; –soft:#f8f9fa;
}
*{box-sizing:border-box}
body{margin:0;background:var(–bg);color:var(–ink);
font-family:"Google Sans","Segoe UI",Roboto,Arial,sans-serif;-webkit-font-smoothing:antialiased}
.wrap{max-width:960px;margin:0 auto;padding:20px 16px 8px}
.head{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:6px}
.dot4{display:inline-flex;gap:4px}
.dot4 span{width:11px;height:11px;border-radius:50%}
.b{background:var(–g-blue)} .r{background:var(–g-red)} .y{background:var(–g-yellow)} .gr{background:var(–g-green)}
h1{font-size:19px;margin:0;font-weight:600;letter-spacing:-.2px}
.sub{color:var(–muted);font-size:13px;margin:2px 0 16px}
.controls{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:16px}
button{font-family:inherit;font-size:13px;font-weight:600;border:1px solid var(–line);
background:#fff;color:var(–ink);padding:9px 14px;border-radius:9px;cursor:pointer;transition:.15s}
button:hover{background:var(–soft);box-shadow:0 1px 3px rgba(60,64,67,.15)}
button:disabled{opacity:.45;cursor:not-allowed}
.btn-ingest{border-color:var(–g-blue);color:var(–g-blue)}
.btn-cons{border-color:var(–g-yellow);color:#b06000}
.btn-query{border-color:var(–g-green);color:#0b7a35}
.stage{display:grid;grid-template-columns:120px 1fr;gap:14px;align-items:start;
border:1px solid var(–line);border-radius:14px;padding:14px;margin-bottom:12px;background:#fff;position:relative}
.stage.active{border-color:var(–g-blue);box-shadow:0 0 0 3px rgba(66,133,244,.12)}
.stage.active.cons{border-color:var(–g-yellow);box-shadow:0 0 0 3px rgba(251,188,4,.14)}
.stage.active.query{border-color:var(–g-green);box-shadow:0 0 0 3px rgba(52,168,83,.14)}
.badge{font-size:12px;font-weight:700;padding:6px 10px;border-radius:999px;color:#fff;display:inline-block;white-space:nowrap}
.ing{background:var(–g-blue)} .con{background:var(–g-yellow);color:#3c2c00} .que{background:var(–g-green)}
.stg-t{font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.5px;color:var(–muted)}
.stg-d{font-size:12.5px;color:var(–muted);margin-top:6px;line-height:1.5}
.store{display:flex;flex-wrap:wrap;gap:10px;min-height:40px}
.card{border:1px solid var(–line);border-left:4px solid var(–g-blue);border-radius:10px;
padding:10px 12px;width:220px;background:#fff;font-size:12px;opacity:0;transform:translateY(8px);
transition:.35s;position:relative}
.card.show{opacity:1;transform:none}
.card.hl{border-left-color:var(–g-yellow);box-shadow:0 0 0 2px rgba(251,188,4,.25)}
.card.cite{border-left-color:var(–g-green);box-shadow:0 0 0 2px rgba(52,168,83,.28)}
.card .cid{position:absolute;top:8px;right:10px;font-weight:700;color:var(–muted);font-size:11px}
.card .sm{font-weight:600;line-height:1.4;margin:0 34px 8px 0;color:var(–ink)}
.chips{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px}
.chip{font-size:10.5px;padding:2px 7px;border-radius:999px;background:#e8f0fe;color:#1967d2}
.chip.tp{background:#e6f4ea;color:#137333}
.imp{font-size:10.5px;color:var(–muted);margin-top:7px}
.imp b{color:var(–ink)}
svg.wires{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;overflow:visible}
.insight{margin-top:10px;border:1px dashed var(–g-yellow);background:#fffbe8;border-radius:10px;
padding:10px 12px;font-size:12.5px;line-height:1.5;color:#5c4b00;display:none}
.insight.show{display:block}
.insight b{color:#b06000}
.qbox{display:none}
.qbox.show{display:block}
.qask{font-size:13px;font-weight:600;color:var(–ink);margin-bottom:6px}
.qans{font-size:12.5px;line-height:1.6;color:var(–ink);background:var(–soft);
border-radius:10px;padding:11px 13px;border:1px solid var(–line)}
.qans .ref{color:#0b7a35;font-weight:700}
.flow{position:relative;height:2px;background:var(–line);margin:4px 0 14px;border-radius:2px}
.pkt{position:absolute;top:-4px;left:0;width:10px;height:10px;border-radius:50%;
background:var(–g-blue);opacity:0;transition:left .9s ease, opacity .2s}
.log{border-top:1px solid var(–line);margin-top:8px;padding-top:10px;font-size:12px;color:var(–muted);min-height:18px}
.log b{color:var(–ink)}
.foot{text-align:center;font-size:11.5px;color:var(–muted);margin-top:14px;padding-top:12px;border-top:1px solid var(–line)}
.foot b{color:var(–g-green)}
@keyframes tick{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}
.timer{display:inline-block;width:12px;height:12px;border:2px solid var(–g-yellow);
border-top-color:transparent;border-radius:50%;vertical-align:-2px;margin-right:4px}
.timer.run{animation:tick .8s linear infinite}
@media(max-width:640px){
.stage{grid-template-columns:1fr;gap:8px}
.card{width:100%}
h1{font-size:17px}
}
</style>
</head>
<body>
<div class="wrap">
<div class="head">
<span class="dot4"><span class="b"></span><span class="r"></span><span class="y"></span><span class="gr"></span></span>
<h1>Always-On Memory Agent — How It Works</h1>
</div>
<div class="sub">Google ADK + Gemini 3.1 Flash-Lite · no vector DB, no embeddings · SQLite memory store</div>
<div class="controls">
<button id="bIngest" class="btn-ingest">+ Ingest a file</button>
<button id="bCons" class="btn-cons" disabled>⟳ Run consolidation</button>
<button id="bQuery" class="btn-query" disabled>? Ask a question</button>
<button id="bReset">↺ Reset</button>
</div>
<div class="flow"><div class="pkt" id="pkt"></div></div>
<!– INGEST –>
<div class="stage" id="sIngest">
<div><span class="badge ing">IngestAgent</span></div>
<div>
<div class="stg-t">1 · Ingest</div>
<div class="stg-d">Reads any file with Gemini multimodal, then extracts summary, entities, topics, importance.</div>
</div>
</div>
<!– STORE –>
<div class="stage" id="sStore">
<div><span class="badge" style="background:#5f6368">Memory Store</span></div>
<div style="position:relative">
<div class="stg-t">SQLite · memories table</div>
<svg class="wires" id="wires"></svg>
<div class="store" id="store"></div>
</div>
</div>
<!– CONSOLIDATE –>
<div class="stage" id="sCons">
<div><span class="badge con"><span class="timer" id="tmr"></span>ConsolidateAgent</span></div>
<div>
<div class="stg-t">2 · Consolidate · every 30 min</div>
<div class="stg-d">Reviews unconsolidated memories, links related ones, then writes one cross-cutting insight.</div>
<div class="insight" id="insight"></div>
</div>
</div>
<!– QUERY –>
<div class="stage" id="sQuery">
<div><span class="badge que">QueryAgent</span></div>
<div>
<div class="stg-t">3 · Query</div>
<div class="stg-d">Reads all memories and insights, then answers with cited memory IDs.</div>
<div class="qbox" id="qbox">
<div class="qask" id="qask"></div>
<div class="qans" id="qans"></div>
</div>
</div>
</div>
<div class="log" id="log"><b>Start here →</b> drop a file into the agent's inbox.</div>
<div class="foot">Interactive explainer · <b>Marktechpost</b> · built on Google Cloud's open-source Always-On Memory Agent</div>
</div>
<script>
(function(){
var SAMPLES = [
{icon:"", src:"report.pdf", sm:"Anthropic reports 62% of Claude usage is code-related.",
ent:["Anthropic","Claude","AI agents"], tp:["AI","code generation"], imp:0.8},
{icon:"
", src:"roadmap.png", sm:"Q1 priority: reduce inference costs by 40%.",
ent:["Q1","inference"], tp:["cost","planning"], imp:0.7},
{icon:"
", src:"standup.mp3", sm:"AI agents grow fast, but reliability is still a challenge.",
ent:["AI agents","reliability"], tp:["agents","reliability"], imp:0.75},
{icon:"
", src:"idea.txt", sm:"Smart inbox idea: persistent AI memory for email.",
ent:["smart inbox","email"], tp:["product","memory"], imp:0.6}
];
var CONS = {
links:[[1,3],[2,1],[3,4]],
insight:"The bottleneck for next-gen AI tools is the transition from static RAG to dynamic memory systems."
};
var Q = "What should I focus on?";
var A = ‘Based on your memories, prioritize: ship the cost-reduction plan <span class="ref">[Memory 2]</span>, ‘ +
‘then close the agent reliability gap <span class="ref">[Memory 3]</span>. ‘ +
‘The smart inbox concept <span class="ref">[Memory 4]</span> validates demand for persistent AI memory.’;
var i=0, consolidated=false;
var $=function(id){return document.getElementById(id)};
var store=$("store"), pkt=$("pkt"), logEl=$("log");
function post(){ try{ parent.postMessage({type:"aoma-resize",height:document.body.offsetHeight+40},"*"); }catch(e){} }
function log(html){ logEl.innerHTML=html; post(); }
function activate(el,cls){ [ "sIngest","sCons","sQuery" ].forEach(function(id){ $(id).classList.remove("active","cons","query"); });
if(el){ el.classList.add("active"); if(cls) el.classList.add(cls); } }
function packet(color){ pkt.style.background=color; pkt.style.opacity="1"; pkt.style.left="0";
setTimeout(function(){ pkt.style.left="calc(100% – 10px)"; },30);
setTimeout(function(){ pkt.style.opacity="0"; },950); }
function ingest(){
if(i>=SAMPLES.length){ log("<b>Inbox empty.</b> All 4 sample files ingested — now consolidate or query."); return; }
var s=SAMPLES[i]; var id=i+1;
activate($("sIngest")); packet("#4285F4");
log(‘<b>IngestAgent</b> reads <b>’+s.icon+’ ‘+s.src+'</b> → extracting summary, entities, topics, importance…’);
var c=document.createElement("div"); c.className="card"; c.id="card"+id;
c.innerHTML='<span class="cid">#’+id+'</span><div class="sm">’+s.sm+'</div>’+
‘<div class="chips">’+s.ent.map(function(e){return ‘<span class="chip">’+e+'</span>’}).join("")+'</div>’+
‘<div class="chips">’+s.tp.map(function(t){return ‘<span class="chip tp">’+t+'</span>’}).join("")+'</div>’+
‘<div class="imp">importance <b>’+s.imp+'</b></div>’;
store.appendChild(c); post();
setTimeout(function(){ c.classList.add("show"); post();
log(‘<b>Stored memory #’+id+'</b> in SQLite. ‘+(SAMPLES.length-id)+’ file(s) left in inbox.’); },500);
i++;
if(i>=2){ $("bCons").disabled=false; $("bQuery").disabled=false; }
}
function consolidate(){
if(i<2){ log("Ingest at least 2 memories first."); return; }
activate($("sCons"),"cons"); packet("#FBBC04");
$("tmr").classList.add("run");
log("<b>ConsolidateAgent</b> woke on its 30-min timer — reviewing unconsolidated memories…");
var svg=$("wires"); svg.innerHTML="";
for(var k=1;k<=Math.min(i,4);k++){ var el=$("card"+k); if(el) el.classList.add("hl"); }
setTimeout(function(){
CONS.links.forEach(function(pair){ drawWire(pair[0],pair[1]); });
log("<b>Found connections</b> across memories — writing one cross-cutting insight…");
},500);
setTimeout(function(){
var ins=$("insight"); ins.innerHTML='<b>Insight:</b> ‘+CONS.insight; ins.classList.add("show");
$("tmr").classList.remove("run"); consolidated=true;
log("<b>Consolidation done.</b> New insight written back to the store — no prompt needed."); post();
},1200);
}
function drawWire(a,b){
var svg=$("wires"), ca=$("card"+a), cb=$("card"+b); if(!ca||!cb) return;
var box=svg.getBoundingClientRect(), ra=ca.getBoundingClientRect(), rb=cb.getBoundingClientRect();
var x1=ra.left-box.left+ra.width/2, y1=ra.top-box.top+ra.height/2;
var x2=rb.left-box.left+rb.width/2, y2=rb.top-box.top+rb.height/2;
var ln=document.createElementNS("http://www.w3.org/2000/svg","line");
ln.setAttribute("x1",x1);ln.setAttribute("y1",y1);ln.setAttribute("x2",x1);ln.setAttribute("y2",y1);
ln.setAttribute("stroke","#FBBC04");ln.setAttribute("stroke-width","2");ln.setAttribute("stroke-dasharray","4 3");
svg.appendChild(ln);
requestAnimationFrame(function(){ ln.style.transition="all .5s"; ln.setAttribute("x2",x2); ln.setAttribute("y2",y2); });
}
function query(){
if(i<1){ log("Ingest something first."); return; }
activate($("sQuery"),"query"); packet("#34A853");
$("qbox").classList.add("show"); $("qask").textContent=”Q: “+Q; $("qans").innerHTML="Reading all memories…";
log("<b>QueryAgent</b> reads every memory"+(consolidated?" and the consolidation insight":"")+", then synthesizes…");
["card2","card3","card4"].forEach(function(id){ var el=$(id); if(el) el.classList.add("cite"); });
setTimeout(function(){ $("qans").innerHTML=A;
log("<b>Answer returned</b> with cited memory IDs — grounded only in stored memories."); post(); },900);
}
function reset(){
i=0; consolidated=false; store.innerHTML=""; $("wires").innerHTML="";
$("insight").className="insight"; $("insight").innerHTML="";
$("qbox").className="qbox"; $("qans").innerHTML=""; $("qask").textContent="";
$("bCons").disabled=true; $("bQuery").disabled=true; activate(null);
log("<b>Reset.</b> Drop a file into the agent’s inbox to begin.");
}
$("bIngest").onclick=ingest;
$("bCons").onclick=consolidate;
$("bQuery").onclick=query;
$("bReset").onclick=reset;
window.addEventListener("load",post);
window.addEventListener("resize",post);
if(window.ResizeObserver){ new ResizeObserver(post).observe(document.body); }
setTimeout(post,150);
})();
</script>
</body>
</html>
“>
(function(){
window.addEventListener(“message”,function(e){
if(e.data && e.data.type===”aoma-resize”){
var f=document.getElementById(“aoma-frame”);
if(f && e.data.height){ f.style.height=e.data.height+”px”; }
}
});
})();
Supported Inputs
Beyond text, the IngestAgent accepts 27 file types across five categories. Simply drop any supported file into the ./inbox folder for automatic pickup.
How It Compares to RAG, Summaries, and Knowledge Graphs
To clarify the difference, it frames three common memory approaches. Each solves part of the problem, yet leaves a gap.
Unlike RAG, this agent processes memory actively, not only on retrieval.
Use Cases With Examples
Practically, the pattern fits any workload needing durable, evolving context. Consider three examples.
- A research assistant ingests PDFs, meeting audio, and screenshots all week. Later, it links a cost target to a reliability problem on its own.
- A personal knowledge base absorbs notes, articles, and images continuously. Over time, consolidation surfaces themes you never explicitly connected.
- A support agent stores past tickets as structured memories. Then it answers new questions with cited references to earlier cases.
Getting Started
With the design clear, setup stays minimal for early-level engineers. Install dependencies, set your key, then start the process.
pip install -r requirements.txt
export GOOGLE_API_KEY=”your-gemini-api-key”
python agent.py
Once running, the agent watches ./inbox, consolidates every 30 minutes, and serves an HTTP API on port 8888. Therefore, you can also feed it over HTTP.
# Ingest text
curl -X POST http://localhost:8888/ingest \
-H “Content-Type: application/json” \
-d ‘{“text”: “AI agents are the future”, “source”: “article”}’
# Ask a question
curl “http://localhost:8888/query?q=what+do+you+know”
Additionally, the API exposes /status, /memories, /consolidate, /delete, and /clear. An optional Streamlit dashboard adds ingest, query, browse, and delete controls. CLI flags change the watch folder, port, and consolidation interval.
python agent.py –watch ./docs –port 9000 –consolidate-every 15
Key Takeaways
- No vector DB, no embeddings — an LLM reads, thinks, and writes structured memory into SQLite.
- Runs 24/7 on Google ADK + Gemini 3.1 Flash-Lite as a lightweight background process.
- Three sub-agents under one orchestrator: Ingest, Consolidate, and Query.
- Consolidates every 30 minutes — links related memories and writes new insights while idle.
- Ingests 27 file types across text, images, audio, video, and PDFs, dropped into ./inbox.
Check out the FULL CODES here. Also, feel free to follow us on Twitter and don’t forget to join our 150k+ML SubReddit and Subscribe to our Newsletter. Wait! are you on telegram? now you can join us on telegram as well.
Need to partner with us for promoting your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar etc.? Connect with us
The post Google Cloud’s Always-On Memory Agent Replaces RAG and Embeddings With Continuous LLM Consolidation on Gemini 3.1 Flash-Lite appeared first on MarkTechPost.



