Home / Articles

Exploring Oracle Agent Memory for Stateful AI Agents

Oracle Agent Memory with LangChain and ATP for stateful AI agents: RAG, episodic notes, a Streamlit desktop wrapper and REST hooks for IDE agent skills.

Publisher: REACTAPP.TOP6 min read1290 words

This article is published in English.

Sources: Exploring Oracle Agent Memory

As AI agents move from simple chat into workflows that span sessions, memory becomes a first-class need. Oracle Agent Memory extends Oracle Database into a persistent memory layer so agents can keep context, learn from past interactions and improve over time. Stateless tools become stateful systems that can carry long-running, multi-step work with continuity.

What agentic memory means

Agentic memory is persistent storage that lets agents store, retrieve and update information across sessions and workflows. It is more than RAG. It covers short-term context (the current conversation) and long-term material (preferences, historical outcomes, learned knowledge). With it, agents keep state and adapt from experience instead of starting from zero every time.

Without memory, agents suffer amnesia: they cannot recall prior interactions and become unreliable in real use. Memory enables continuity, personalization, knowledge retrieval and workflow resilience. Agents can resume tasks, remember goals and constraints and improve decisions over time. For long-horizon work, memory is essential for consistent, useful outcomes.

Why Oracle

Oracle embeds agent memory in the database itself. Oracle AI Agent Memory uses the converged stack (vector, relational, JSON and graph) so several memory types and retrieval strategies share one platform. Memory sits beside enterprise data, which helps with security, governance and scale and avoids a scatter of specialty stores. Autonomous Database adds self-management, patching and auto-scaling for teams that want stability without babysitting the database.

Building an engagement tracker

Customer-facing work often means juggling many engagements. Context switching is expensive, and notes are easy to lose. The sample here uses LangChain with Oracle Agent Memory for RAG, conversation tracking and episodic memory in one system of record.

Any 26ai instance works, including the free Oracle Database container. Oracle publishes a local setup guide under the Agent Memory documentation for release 26.4.

ATP with TLS

An Autonomous Transaction Processing instance, tuned for OLTP, is a good fit. TLS plus an ACL limits access to trusted locations. TLS instead of mTLS means no wallet file for clients. The developer image keeps cost and size down for prototypes.

Project and dependencies

Create a venv and install:

python3 -m venv .venv
source .venv/bin/activate

pip install langchain-oci
pip install oracleagentmemory

OCI config

OCI Generative AI serves embeddings and language models on demand. A local desktop needs a profile under ~/.oci/config. See the OCI SDK setup docs.

Connectivity checks

The Database Connection tab in the OCI console shows how to create a Python oracledb pool over TLS. After that, a short script can exercise Oracle Agent Memory:

''' Script to test access to Oracle Agent Memory '''

# load dependenies
from oracleagentmemory.apis.searchscope import SearchScope
from oracleagentmemory.core import OracleAgentMemory
from oracleagentmemory.core.dbschemapolicy import SchemaPolicy
from oracleagentmemory.core.embedders.embedder import Embedder
from oracleagentmemory.core.llms.llm import Llm
import oracledb
from pathlib import Path
from oci.config import from_file

# create connection object
def return_connection():
 try:
  pool = oracledb.create_pool(
   user=DB_USER,
   password=DB_PASSWORD,
   dsn=CONNECT_STRING,
  )
  return pool
 except Exception as e:
  raise(e)

connection = return_connection()
print('database connection made')

# set OCI config parameters
config = from_file('~/.oci/config')
oci_key_file = str(Path(config['key_file']).expanduser())
compartment_id = config['compartment_id']

# set embedding model
oci_embedder = Embedder(model="oci/cohere.embed-english-v3.0",
      oci_compartment_id=config['compartment_id'],
      oci_region=config['region'],
      oci_user=config['user'],
      oci_fingerprint=config['fingerprint'],
      oci_tenancy=config['tenancy'],
      oci_key_file=oci_key_file)

# set language model
oci_llm = Llm(model="oci/openai.gpt-oss-120b",
     oci_compartment_id=config['compartment_id'],
     oci_region=config['region'],
     oci_user=config['user'],
     oci_fingerprint=config['fingerprint'],
     oci_tenancy=config['tenancy'],
     oci_key_file=oci_key_file)

try:
 memory = OracleAgentMemory(connection=connection,
          embedder=oci_embedder,
          llm=oci_llm,
          schema_policy=SchemaPolicy.CREATE_IF_NECESSARY,
          table_name_prefix="OAM_")
 print("successfully connected to agent memory")
except Exception as e:
 raise(e)

By default the SDK expects Agent Memory schemas to exist. On first setup, allow the memory store to create its objects (SchemaPolicy.CREATE_IF_NECESSARY in the sample). The database user needs privileges to create tables and vector indexes. After schema creation, stricter policy can return.

LangChain agent and UI

The agent follows a familiar LangChain shape: utility tools, an LLM, a system prompt and wiring into one agent. A Streamlit UI sits in front so notes can be added, updated or deleted interactively.

Behaviors that needed fixing

Early versions were too flexible: the agent updated memory before answering, which reinforced hallucinations. Tightening that order helped. The UI can ingest files or markdown into category buckets (projects, internal, platform). A manual search path finds memories by natural language, category or date without always calling the agent. Chat searches the knowledge base through the agent. Obsolete memories can be deleted one by one.

REST endpoints and a Cline skill

FastAPI endpoints support programmatic use:

  • GET /health
  • POST /memories
  • GET /memories
  • GET /search
  • POST /memories/delete

Those endpoints also power a Cline skill so memories can be updated from a task inside VS Code.

Desktop wrapper

To avoid another browser tab, a small pywebview launcher starts Streamlit on localhost, waits until it responds, then opens a native window. Streamlit starts FastAPI as a background subprocess so the stack feels like one local app:

from pathlib import Path
import subprocess
import time
import urllib.request

import webview

PROJECT_DIR = Path("/path/to/your/project")
URL = "http://127.0.0.1:8501"

streamlit = subprocess.Popen(
    [
        str(PROJECT_DIR / ".venv/bin/streamlit"),
        "run",
        "app.py",
        "--server.address=127.0.0.1",
        "--server.port=8501",
        "--server.headless=true",
    ],
    cwd=PROJECT_DIR,
)

try:
    start = time.time()
    while time.time() - start < 30:
        try:
            with urllib.request.urlopen(URL, timeout=1):
                break
        except Exception:
            time.sleep(0.5)

    webview.create_window("HiveMind AI", URL, width=1200, height=850)
    webview.start()
finally:
    streamlit.terminate()

Package with PyInstaller:

cd /path/to/your/project
source .venv/bin/activate

pip install pywebview pyinstaller

pyinstaller --windowed \
  --name "HiveMind AI" \
  --icon assets/hivemind_ai_icon.icns \
  hivemind_desktop.py

That yields dist/HiveMind AI.app, which can live in /Applications and launch from Spotlight.

Design choices that kept the demo honest

Three decisions made the sample usable instead of merely flashy.

First, memory writes are gated. The agent should answer from what it already knows before it invents a new memory. Letting the model write before it speaks produced confident nonsense that then polluted later retrieval. Putting write tools behind clearer prompts, or behind explicit user actions in the UI, stopped that loop.

Second, search does not always need a model. Keyword or vector search over categories and dates is enough for "find last week's AlloyDB notes." Saving the LLM for synthesis keeps cost and latency down and makes failures easier to debug.

Third, desktop packaging matters for personal tools. If opening the note app means hunting a terminal and a browser tab, the tool dies of friction. A launcher that starts services and opens a window turns the same stack into something you actually click twice a day.

What this is not

This is not a claim that Oracle is the only place to put agent memory. Vector databases, dedicated memory products and file-based stores all have roles. The point of the sample is that if the rest of the enterprise data already lives in Oracle, putting agent memory next to it simplifies governance: one IAM story, one backup story, one audit trail. Teams already standardized on Autonomous Database can add memory without inventing a second platform.

It is also not production-hardened multi-tenant SaaS. The demo assumes a single trusted user or a small team, TLS to ATP and OCI credentials on a developer laptop. Production would add stronger tenancy isolation, secret management and observability around every memory write.

Closing notes

Memory matters for agents that span sessions. Oracle's unified Agent Memory SDK can act as a multi-modal store beside enterprise data. The sample ties Autonomous Transaction Processing to OCI Generative AI, adds a Streamlit UI, REST surface and a desktop wrapper for day-to-day note taking.