PROMPT CANVAS CANVAS

Role & Context

You are a Principal AI Architect specializing in OpenAI Agents and Enterprise Vector Databases (specifically Oracle Database 23ai). Your task is to design and implement a Long-Term Memory module that allows an AI Agent to persistently store and retrieve conversational context across multiple sessions.

Input Data

  • Agent Persona/Goal:
  • Memory Schema/Focus:

Step-by-Step Instructions

  1. Analyze the agent_persona to understand what kind of information is critical for this agent to remember long-term.
  2. Review the memory_schema to determine the specific entities or conversational artifacts that must be vectorized and stored.
  3. Within a dedicated thinking block, outline the architecture for the memory loop:
    • How incoming messages are summarized or evaluated for memory retention.
    • How the text is embedded using OpenAI's embedding models.
    • How the embeddings are stored in Oracle 23ai.
    • How semantic search is performed prior to the agent generating a response.
  4. Output the technical blueprint, including the necessary Python code to connect to Oracle 23ai, generate embeddings, and execute the vector search.

Constraints

  • The database queries must utilize Oracle 23ai's native VECTOR data type and vector search syntax (e.g., VECTOR_DISTANCE).
  • The code must be production-ready, including error handling for database connection failures.
  • Emphasize efficient token usage; the retrieval mechanism should only pull the top-K most relevant memories.
# Role & Context
You are a Principal AI Architect specializing in OpenAI Agents and Enterprise Vector Databases (specifically Oracle Database 23ai). Your task is to design and implement a Long-Term Memory module that allows an AI Agent to persistently store and retrieve conversational context across multiple sessions.

# Input Data
- Agent Persona/Goal: 
- Memory Schema/Focus: 

## Step-by-Step Instructions
1. Analyze the `agent_persona` to understand what kind of information is critical for this agent to remember long-term.
2. Review the `memory_schema` to determine the specific entities or conversational artifacts that must be vectorized and stored.
3. Within a dedicated thinking block, outline the architecture for the memory loop: 
   - How incoming messages are summarized or evaluated for memory retention.
   - How the text is embedded using OpenAI's embedding models.
   - How the embeddings are stored in Oracle 23ai.
   - How semantic search is performed prior to the agent generating a response.
4. Output the technical blueprint, including the necessary Python code to connect to Oracle 23ai, generate embeddings, and execute the vector search.

## Constraints
- The database queries must utilize Oracle 23ai's native `VECTOR` data type and vector search syntax (e.g., `VECTOR_DISTANCE`).
- The code must be production-ready, including error handling for database connection failures.
- Emphasize efficient token usage; the retrieval mechanism should only pull the top-K most relevant memories.
🚀 Copy Compiled Prompt & Launch in:

Enabling Long-Term Agent Memory with Oracle AI Agent Memory

Coding 2026-08-08T00:00:00Z
👁️ 0

Key Capabilities

  • Persistent Context Retention: Construct agents that remember past user interactions indefinitely by mapping conversation history to Oracle 23ai Vector Database.
  • Optimized Retrieval-Augmented Generation (RAG): Standardize your memory retrieval pipeline to dynamically inject relevant historical context into the prompt, reducing token overhead while maintaining deep personalization.
  • Enterprise-Grade Data Management: Leverage Oracle's robust database architecture for secure, scalable, and highly available agent memory storage.

Underlying Mechanism

This prompt utilizes a Markdown-structured Chain of Thought (CoT) to guide the LLM in designing a specialized memory management module. It explicitly constraints the architecture to use OpenAI's Embeddings API alongside Oracle 23ai Vector Search, ensuring the resulting code handles semantic memory retrieval accurately rather than relying on naive keyword matching or volatile in-memory storage.

Ideal Use Cases

  • Building personalized AI assistants that need to remember user preferences over long periods.
  • Developing enterprise-grade customer support bots that can recall past ticket histories.
  • Creating "Deep Research" agents that aggregate knowledge across multiple, disparate research sessions.

When NOT to Use (Anti-Patterns)

  • For stateless, single-turn query applications where historical context is irrelevant.
  • If you do not have access to an Oracle Database 23ai environment or a similar vector-capable persistent store.

Pro Tip

When defining the {{memory_schema}}, be specific about what attributes of the conversation are most valuable to retain (e.g., "User Preferences", "Factual Statements", "Completed Tasks") so the agent learns to prioritize indexing those specific entities.

Source Reference: Enabling Long-Term Agent Memory with Oracle AI Agent Memory

🎯 Real Output Example

Generated using this exact prompt structure with the default variable values.

Memory Architecture Blueprint

The long-term memory system will utilize a two-pass approach. First, an extraction prompt will identify key facts from the current turn based on the schema. Second, those facts are embedded and upserted into Oracle 23ai.

Implementation Code

import oracledb
from openai import OpenAI

client = OpenAI()

def get_embedding(text):
    response = client.embeddings.create(input=text, model="text-embedding-3-small")
    return response.data[0].embedding

def store_memory(conn, user_id, text):
    vector = get_embedding(text)
    cursor = conn.cursor()
    # Utilizing Oracle 23ai VECTOR syntax
    cursor.execute("""
        INSERT INTO agent_memory (user_id, content, embedding)
        VALUES (:1, :2, :3)
    """, [user_id, text, str(vector)])
    conn.commit()

🧬 Prompt Variables & Input Reference

Variable Tag What to Enter Default Example Value
{{agent_persona}} Describe the core purpose and persona of the agent (e.g., 'A financial advisor assistant' or 'A technical research agent'). A deep research assistant that helps users synthesize technical documentation over multiple weeks.
{{memory_schema}} Specify the types of information the agent should prioritize remembering. Key concepts researched, user's technical proficiency level, and previously cited URLs.

📋 How to Use This Prompt

1

Customize on Prompt Canvas

Click any {{variable}} directly on the canvas to choose a ⚡ Quick Preset or type your own value in the popover editor.

2

Copy Compiled Prompt

Click Copy Prompt to grab the ready-to-run prompt with your custom inputs already injected—or save it to your ⭐ Prompt Vault.

3

1-Click Launch in AI

Hit the ChatGPT, Claude, DeepSeek, or Gemini launch buttons to copy and open your preferred model in one click.