Agent Memory
This page presents the concrete Oracle AI Agent Memory implementation.
Oracle Agent Memory
Note: OracleAgentMemory.delete_thread() is the supported path for
thread-scoped cascading cleanup. It removes the thread together with
associated messages, durable memories, and managed retrieval data. This is
broader than OracleThread.delete_message(), which deletes only the raw
message row. Client-level deletion waits for relevant earlier background
extraction: thread deletion waits for that thread, memory deletion waits for
the stored target’s thread when present, and user or agent deletion waits
for known owned threads whether or not cascade cleanup is enabled. These
waits cover only work accepted by the same client before the wait begins.
class oracleagentmemory.core.OracleAgentMemory
Bases: IAgentMemory
Agent-memory client backed by Oracle DB or a caller-provided store.
Create a memory client.
- Parameters:
- store
OracleMemoryStore– Optional preconfigured store instance. When provided, the client uses this store directly instead of instantiating its own store. This is useful when callers need store configuration beyond the constructor options exposed byOracleAgentMemory. - connection
object– Optional Oracle DB connection/pool. When provided, the DB store is used. Passing a raw connection enables single-session mode for this client instance, so concurrent requests should use a connection pool instead. When omitted, callers must pass an explicitstore. - embedder
IEmbedder | str– Embedder implementation instance, or a LiteLLM embedding model identifier. When omitted, no embedder is attached. Vector-only DB search then requires precomputed vectors through lower-level store APIs, while keyword DB search can run directly from query text. Hybrid DB search requires anOracleDBEmbedderinstance so the managed hybrid index and the main embedder use the same in-database model. - llm
ILlm– Optional LLM adapter used by threads for memory extraction and/or context summarization. By default, threads created or loaded from this client require an LLM so recent messages can be mined for durable memories. Pass anllmhere, provide one later increate_thread, or disable automatic extraction withmemory_extraction_config=MemoryExtractionConfig(extract_memories=False). - memory_extraction_config
MemoryExtractionConfig– Optional client-level memory extraction configuration. Use it to control automatic memory extraction settings such as extraction mode, summary behavior, and extraction limits. Omitted fields use SDK defaults. In particular, an omitted image context isDISABLED. - image_input_limit_config
ImageInputLimitConfig– Optional client-level raw-image and LLM image-request limits. Omitted fields use SDK defaults and are inherited by threads unless a thread supplies an override. Validation cannot be disabled. - schema_policy
SchemaPolicy | str– DB schema setup policy used only when constructing a DB store fromconnection. Defaults toSchemaPolicy.REQUIRE_EXISTING. UseSchemaPolicy.CREATE_IF_NECESSARYwhen first enabling keyword or hybrid search on an existing schema, or when opening a supported older released managed schema, so the SDK can apply non-destructive schema upgrades and add the needed text-search objects. Development or partially updated schemas that already claim the current release shape should be recreated instead. Whenschema_owneris set, onlySchemaPolicy.REQUIRE_EXISTINGis allowed. This prevents managed schema DDL, including schema creation, upgrades, recreation, and first hybrid-index creation; perform those actions while connected as the owning database user withoutschema_owner. It does not make the client read-only: normal memory reads and writes use the connection user’s granted database privileges. - memory_store_id
str– Stable ID for the managed DB memory store used only when constructing a DB store fromconnection. Reuse the same ID to reopen the same managed store. The ID is joined to managed DB object names with an underscore, so it must start with a letter, contain only letters, numbers, and underscores, and be at most 16 characters. The DB store normalizes it to uppercase, so casing does not create a different store identity. Pass either this ortable_name_prefix, not both. If omitted, the DB store usestable_name_prefixor the unprefixed default whentable_name_prefixis also omitted. -
table_name_prefix
str–Optional DB table/index prefix used only when constructing a DB store from
connection. Pass either this ormemory_store_id, not both.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_store_idinstead. - schema_owner
str– Optional schema owner for an existing managed memory store. Omit this option to use the connection user’s schema. Use it whenconnection—a raw database connection or connection pool—belongs to an application DB user that has grants on tables owned by another user. This option is only for runtime access to an already-created managed memory store and requiresSchemaPolicy.REQUIRE_EXISTING. Create, upgrade, or recreate the managed memory store while connected as the schema owner and omit this option. Pass an unquoted identifier; lowercase input is normalized to uppercase, and quoted, case-sensitive schema owners are not supported. If you pass a preconfiguredstore, configureschema_owneron that store instead. GrantCREATE SESSIONand the required object privileges to the application DB user; see theDatabase Users and Privilegessection of the troubleshooting guide for the exact grants. As an alternative, expose same-named managed-object views in the runtime schema and omitschema_owner; this is supported only forSchemaPolicy.REQUIRE_EXISTING. - search_strategy
SearchStrategy–SearchStrategyvalue that selects the DB-search backend when constructing a DB store fromconnection. UseSearchStrategy.VECTOR(default) for vector-only retrieval,SearchStrategy.HYBRIDto query the managed Oracle hybrid vector index over the stored search text, orSearchStrategy.KEYWORDto rank by keyword/text matching over the stored search text without vector fusion.KEYWORDdoes not require an embedder.HYBRIDrequiresembedderto be anOracleDBEmbedder. Client startup fails when an incompatible strategy is used with an existing schema because that schema may not contain the stored search state the strategy needs. Whenschema_policy=SchemaPolicy.REQUIRE_EXISTINGand this argument is omitted, the DB store best-effort detects the schema’s stored search mode from managed metadata and uses that mode when available. - search_index_sync
SearchIndexSyncMode–SearchIndexSyncModevalue that selects the managed search-index refresh behavior forSearchStrategy.HYBRIDandSearchStrategy.KEYWORD.SearchIndexSyncMode.ON_COMMITis the default and makes records searchable as soon as the write transaction commits.SearchIndexSyncMode.MANUALleaves refresh to an explicit database-side sync operation.SearchIndexSyncMode.AUTOlets Oracle refresh the managed hybrid index asynchronously and is supported only withSearchStrategy.HYBRID; keyword search rejectsAUTO. -
extract_memories
bool–When
True, threads created or loaded by this client require an LLM and automatic memory extraction remains enabled. Set toFalseto disable automatic memory extraction and allow those threads to operate without an LLM. Defaults toTrueso missing extraction LLMs fail fast.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_custom_instructions
str–Optional custom instructions appended to the automatic memory extraction system prompt for threads created or loaded by this client. Per-thread values passed to
create_thread,get_thread, orupdate_threadtake precedence.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. - memory_retention_config
MemoryRetentionConfig– Optional memory retention configuration used only when constructing a DB store fromconnection.MemoryRetentionConfig.default_ttl_daysis applied to new messages and memories whose write call omitsttl_days.MemoryRetentionConfig.max_ttl_daysclamps explicit per-record durations above the configured maximum with a warning and, when set, makesttl_days=Noneuse that maximum instead of creating non-expiring records. WithSchemaPolicy.CREATE_IF_NECESSARY, an explicit configuration refreshes the stored metadata on an existing up-to-date managed schema, but it does not update the existing expiration dates; omitting it keeps the existing setting. If an explicit configuration leavesdefault_ttl_daysormax_ttl_daysatNOT_SET_MARKER, the SDK resolves that attribute to its default value (None) before comparing or storing schema metadata. Choose this configuration based on the expected information stored in records, why the application retains it, and any application or regulatory retention commitments. - search_config
MemorySearchConfig– Optional client-level search configuration inherited by new and loaded threads. When omitted, searches use a fixed top-k search configuration. - pruner_llm
ILlm– Optional LLM used to enable client-wide result pruning. When set, direct client searches and inherited thread searches use pruning with theFASTevaluation mode by default. Existing threads with a stored search configuration keep that configuration when reopened. Usesearch_config=PruningMemorySearchConfig(...)to customize pruning behavior.pruner_llmcannot be combined withsearch_config.
- store
Warning: SchemaPolicy.CREATE_IF_NECESSARY can be more expensive than normal
client startup because it may apply managed schema DDL and best-effort
data rewrites before initialization succeeds. Plan the first open of
an older managed schema as a migration or maintenance operation when
that schema may contain many rows.
If schema setup must create the managed expired-record purge job but
the database user lacks the scheduler-job privilege, initialization
warns and continues. Expired messages and memories stay hidden from
reads and search, but they are not physically purged until the job is
created by a user with CREATE JOB or an equivalent scheduler
privilege.
When SchemaPolicy.CREATE_IF_NECESSARY first creates a managed
hybrid index over an existing schema, Oracle scans the stored search
text and builds the managed hybrid-index state from the configured
in-database model. Client startup waits for that DDL to finish, so plan
the first hybrid upgrade as a migration or maintenance operation for
large schemas. SearchIndexSyncMode controls ongoing maintenance
after the index exists; it does not make the first index build
asynchronous.
- Raises:
ValueError – If conflicting store configuration is provided, such as passing
both
storeandconnection, DB-specific options without a DB connection, or omitting bothstoreandconnection. - Parameters:
- store
OracleMemoryStore - connection
object - embedder
IEmbedder | str - llm
ILlm - memory_extraction_config
MemoryExtractionConfig - image_input_limit_config
ImageInputLimitConfig - schema_policy
SchemaPolicy | str - memory_store_id
str - table_name_prefix
str - schema_owner
str - search_strategy
SearchStrategy - search_index_sync
SearchIndexSyncMode - extract_memories
bool - memory_extraction_custom_instructions
str - memory_retention_config
MemoryRetentionConfig - search_config
MemorySearchConfig - pruner_llm
ILlm
- store
Examples
To access a schema created by another database user, configure
memory_rw_pool for the application DB user and set
memory_schema_owner to the owning user’s unquoted database name.
from oracleagentmemory.core import (
MemoryExtractionConfig,
SearchIndexSyncMode,
OracleAgentMemory,
SchemaPolicy,
SearchStrategy,
)
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
read_only_client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
memory_extraction_config=MemoryExtractionConfig(extract_memories=False),
)
pruned_search_client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
memory_extraction_config=MemoryExtractionConfig(extract_memories=False),
pruner_llm=llm,
)
shared_client = OracleAgentMemory(
connection=memory_rw_pool,
embedder=embedder,
llm=llm,
schema_owner=memory_schema_owner,
)
Use an in-DB embedding model to exploit Oracle hybrid index search:
from oracleagentmemory.core.embedders import OracleDBEmbedder
db_embedder = OracleDBEmbedder(
connection=db_pool,
model="DOC_MODEL",
embedding_dimension=768,
)
hybrid_client = OracleAgentMemory(
connection=db_pool,
embedder=db_embedder,
schema_policy=SchemaPolicy.CREATE_IF_NECESSARY,
search_strategy=SearchStrategy.HYBRID,
search_index_sync=SearchIndexSyncMode.ON_COMMIT,
memory_store_id=memory_store_id,
)
method add_agent
Add an agent profile record to the store.
- Parameters:
- agent_id
str– Agent identifier. - information
str– Free-form information about the agent. - metadata
dict[str, Any] | None– Optional metadata mapping stored on the agent profile row.
- agent_id
- Returns: Identifier of the stored agent profile.
- Return type: str
Notes
Agent profile records are stored in the client-level store and are
intentionally unscoped. The returned record identifier is the same
public identifier the application uses as agent_id.
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
client.add_agent(
"a1",
"Support assistant",
metadata={"source": "catalog"},
)
'a1'
method add_agent_async (async)
Add an agent profile record to the store asynchronously.
- Parameters:
- agent_id
str– Agent identifier. - information
str– Free-form information about the agent. - metadata
dict[str, Any] | None– Optional metadata mapping stored on the agent profile row.
- agent_id
- Returns: Identifier of the stored agent profile.
- Return type: str
Notes
Agent profile records are stored in the client-level store and are
intentionally unscoped. The returned record identifier is the same
public identifier the application uses as agent_id.
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
import asyncio
asyncio.run(client.add_agent_async(
"a1",
"Support assistant",
metadata={"source": "catalog"},
))
'a1'
method add_image
Add an image record to the client.
- Parameters:
- image
bytes– Image bytes to store as an image. - description
str | None– Optional description associated with the image. Omit it or passNoneto generate one with the configured LLM. - mime_type
ImageMimeType– MIME type of the image. Supported values are provided byImageMimeType. When omitted, the SDK detects and validates the type from the image bytes. The supported detected types are PNG, JPEG, and WEBP. - image_id
str– Optional caller-provided stable identifier. When omitted, one is generated. - user_id
str | None– Optional user owner. Provide at least one ofuser_id,agent_id, orthread_id; all three cannot beNone. - agent_id
str | None– Optional agent identifier to associate with the image. - thread_id
str– Optional thread identifier to associate with the image. - metadata
dict[str, Any] | None– Optional metadata to persist with the image row. - timestamp
str | None– Optional event timestamp to save for this image. Omit this argument or passNoneto store aNULLevent timestamp. When the image is read, its creation time is returned as the effective timestamp. - ttl_days
int | None– Optional time-to-live duration in days. Omit this argument to use the schema default time-to-live duration. PassNoneto store an image that does not expire. - ttl_anchor
TimeToLiveAnchor– Optional time-to-live anchor. UseTimeToLiveAnchor.CREATED_ATfor the database creation time orTimeToLiveAnchor.TIMESTAMPfor the image timestamp. - **store_kwargs (Any) – Implementation-specific write options forwarded to the backing store.
- image
- Returns: Identifier of the inserted image record.
- Return type: str
Examples
image_id = client.add_image(
b"image-bytes",
description="Image description",
mime_type=ImageMimeType.PNG,
image_id="img-1",
user_id="user-1",
)
image_id
'img-1'
method add_image_async (async)
Persist one standalone image through the configured store.
When description is omitted or None, the configured LLM
generates a caption.
- Parameters:
- image
bytes– Raw image bytes to persist. - description
str | None– Optional description or caption. Omit it to generate a caption. - mime_type
ImageMimeType– Optional MIME type used for image persistence and caption generation. When omitted, the SDK detects and validates the type from the image bytes. The supported detected types are PNG, JPEG, and WEBP. - image_id
str– Optional identifier. One is generated when omitted. - user_id
str | None– Owner scope identifiers. At least one must be non-None. Whenthread_idis provided, its stored user and agent ownership is authoritative; omitted user and agent values are inherited. - agent_id
str | None– Owner scope identifiers. At least one must be non-None. Whenthread_idis provided, its stored user and agent ownership is authoritative; omitted user and agent values are inherited. - thread_id
str– Owner scope identifiers. At least one must be non-None. Whenthread_idis provided, its stored user and agent ownership is authoritative; omitted user and agent values are inherited. - metadata
dict[str, Any] | None– Optional metadata stored with the image. - timestamp
str | None– Optional event timestamp to save for this image. Omit this argument or passNoneto store aNULLevent timestamp. When the image is read, its creation time is returned as the effective timestamp. - ttl_days
int | None– Optional expiration settings. - ttl_anchor
TimeToLiveAnchor– Optional expiration settings. - store_kwargs
Any– Additional store-specific options.
- image
- Returns: The persisted image identifier.
- Return type: str
method add_memory
Add a memory in the memory system, attributed to the indicated user, agent and thread.
- Parameters:
- content
str– Memory content to persist. - memory_type
Literal['memory', 'guideline', 'fact', 'preference'] | ~oracleagentmemory._notset._NotSetMarker– Memory category to store. Supported values are"memory","fact","guideline", and"preference". When omitted, the content is stored as a general"memory". - user_id
str– Optional scope identifiers associated with the stored memory. Whenuser_idis omitted and the DB connection carries an end-user security context, the store uses that context’s username. - agent_id
str– Optional scope identifiers associated with the stored memory. Whenuser_idis omitted and the DB connection carries an end-user security context, the store uses that context’s username. - thread_id
str– Optional scope identifiers associated with the stored memory. Whenuser_idis omitted and the DB connection carries an end-user security context, the store uses that context’s username. - memory_id
str– Optional caller-provided stable identifier for this memory row. - metadata
dict[str, Any] | None– Optional metadata to persist with the stored memory. - timestamp
str | None– Optional event timestamp to save for this memory. Omit this argument or passNoneto store aNULLevent timestamp. When the record is read, its creation time is returned as the effective timestamp. Whenttl_anchorisTimeToLiveAnchor.TIMESTAMP, ISO-8601 timestamps without a timezone are treated as UTC. - ttl_days
int | None– Optional time-to-live duration in days. Omit this argument to use the schema default time-to-live duration. PassNoneto useMemoryRetentionConfig.max_ttl_dayswhen the retention configuration sets one, or to store a non-expiring memory when it does not. Values aboveMemoryRetentionConfig.max_ttl_daysare clamped to that maximum with a warning. - ttl_anchor
TimeToLiveAnchor– Optional time-to-live anchor. UseTimeToLiveAnchor.CREATED_ATfor the database creation time orTimeToLiveAnchor.TIMESTAMPfor the memory timestamp. ISO-8601 timestamps without a timezone are treated as UTC. - status
RecordStatus– Initial lifecycle status. Omit it to storeRecordStatus.VALID. - autonomous_linking
bool– Whether to create links from this new memory to relevant stored memories using the client’s LLM. Omitted enables it when an LLM exists; passFalseto skip. Failure leaves the memory stored. - memory_id_to_link
str– Together, create a directed link from the new memory to this existing memory, including one in another scope. Omitted user, agent, and thread scopes inherit from that target. - link_type
Literal['supersedes', 'contradicts', 'refines', 'supports', 'duplicates'] | ~oracleagentmemory._notset._NotSetMarker– Together, create a directed link from the new memory to this existing memory, including one in another scope. Omitted user, agent, and thread scopes inherit from that target. - link_id
str– Optional identifier, timestamp, and metadata for the explicit link. - link_timestamp
str | None– Optional identifier, timestamp, and metadata for the explicit link. - link_metadata
dict[str, Any] | None– Optional identifier, timestamp, and metadata for the explicit link. - **store_kwargs (Any) – Store-specific write options forwarded to the backing store.
- content
- Returns: Identifier of the inserted memory record.
- Return type: str
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
memory_id = client.add_memory("User likes pizza", memory_id="mem-1")
memory_id
'mem-1'
method add_memory_async (async)
Add a memory in the memory system asynchronously.
- Parameters:
- content
str– Memory content to persist. - memory_type
Literal['memory', 'guideline', 'fact', 'preference'] | ~oracleagentmemory._notset._NotSetMarker– Memory category to store. Supported values are"memory","fact","guideline", and"preference". When omitted, the content is stored as a general"memory". - user_id
str– Optional scope identifiers associated with the stored memory. Whenuser_idis omitted and the DB connection carries an end-user security context, the store uses that context’s username. - agent_id
str– Optional scope identifiers associated with the stored memory. Whenuser_idis omitted and the DB connection carries an end-user security context, the store uses that context’s username. - thread_id
str– Optional scope identifiers associated with the stored memory. Whenuser_idis omitted and the DB connection carries an end-user security context, the store uses that context’s username. - memory_id
str– Optional caller-provided stable identifier for this memory row. - metadata
dict[str, Any] | None– Optional metadata to persist with the stored memory. - timestamp
str | None– Optional event timestamp to save for this memory. Omit this argument or passNoneto store aNULLevent timestamp. When the record is read, its creation time is returned as the effective timestamp. Whenttl_anchorisTimeToLiveAnchor.TIMESTAMP, ISO-8601 timestamps without a timezone are treated as UTC. - ttl_days
int | None– Optional time-to-live duration in days. Omit this argument to use the schema default time-to-live duration. PassNoneto useMemoryRetentionConfig.max_ttl_dayswhen the retention configuration sets one, or to store a non-expiring memory when it does not. Values aboveMemoryRetentionConfig.max_ttl_daysare clamped to that maximum with a warning. - ttl_anchor
TimeToLiveAnchor– Optional time-to-live anchor. UseTimeToLiveAnchor.CREATED_ATfor the database creation time orTimeToLiveAnchor.TIMESTAMPfor the memory timestamp. ISO-8601 timestamps without a timezone are treated as UTC. - status
RecordStatus– Initial lifecycle status. Omit it to storeRecordStatus.VALID. - autonomous_linking
bool– Whether to create links from this new memory to relevant stored memories using the client’s LLM. Omitted enables it when an LLM exists; passFalseto skip. Failure leaves the memory stored. - memory_id_to_link
str– Together, create a directed link from the new memory to this existing memory, including one in another scope. Omitted user, agent, and thread scopes inherit from that target. - link_type
Literal['supersedes', 'contradicts', 'refines', 'supports', 'duplicates'] | ~oracleagentmemory._notset._NotSetMarker– Together, create a directed link from the new memory to this existing memory, including one in another scope. Omitted user, agent, and thread scopes inherit from that target. - link_id
str– Optional identifier, timestamp, and metadata for the explicit link. - link_timestamp
str | None– Optional identifier, timestamp, and metadata for the explicit link. - link_metadata
dict[str, Any] | None– Optional identifier, timestamp, and metadata for the explicit link. - **store_kwargs (Any) – Store-specific write options forwarded to the backing store.
- content
- Returns: Identifier of the inserted memory record.
- Return type: str
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
import asyncio
memory_id = asyncio.run(client.add_memory_async(
"User likes pizza", memory_id="mem-1"
))
memory_id
'mem-1'
method add_user
Add a user profile record to the store.
- Parameters:
- user_id
str– User identifier. - information
str– Free-form information about the user. - metadata
dict[str, Any] | None– Optional metadata mapping stored on the user profile row.
- user_id
- Returns: Identifier of the stored user profile.
- Return type: str
Notes
User profile records are stored in the client-level store and are
intentionally unscoped. The returned record identifier is the same
public identifier the application uses as user_id.
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
client.add_user(
"u1",
"Prefers concise answers.",
metadata={"source": "crm"},
)
'u1'
method add_user_async (async)
Add a user profile record to the store asynchronously.
- Parameters:
- user_id
str– User identifier. - information
str– Free-form information about the user. - metadata
dict[str, Any] | None– Optional metadata mapping stored on the user profile row.
- user_id
- Returns: Identifier of the stored user profile.
- Return type: str
Notes
User profile records are stored in the client-level store and are
intentionally unscoped. The returned record identifier is the same
public identifier the application uses as user_id.
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
import asyncio
asyncio.run(client.add_user_async(
"u1",
"Prefers concise answers.",
metadata={"source": "crm"},
))
'u1'
method close
Close the agent memory component.
Closing stops accepting new background work, including memory
extraction and image-description generation, and waits for pending
work to finish up to the configured timeout. If that timeout expires,
close() returns even if some work is still unfinished. The method
is idempotent.
- Parameters:
timeout
float | None– Optional maximum number of seconds to wait for accepted background work to finish. Defaults to300. PassNoneto wait indefinitely. - Return type: None
Examples
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
schema_policy=SchemaPolicy.CREATE_IF_NECESSARY,
memory_extraction_config=MemoryExtractionConfig(extract_memories=False),
)
client.close()
method close_async (async)
Asynchronously close the agent memory component.
This method follows the same shutdown behavior as close(). If the
timeout expires, it can return while background work is still running.
- Parameters:
timeout
float | None– Optional maximum number of seconds to wait for accepted background work to finish. Defaults to300. PassNoneto wait indefinitely. - Return type: None
Examples
import asyncio
asyncio.run(client.close_async())
method create_thread
Create and register a thread.
- Parameters:
- thread_id
str– Thread identifier. If omitted, a new one is generated. - user_id
str– User identifier attached to this thread record. If omitted and the DB connection carries an end-user security context, that context’s username is used. Otherwise, a new identifier is generated. - agent_id
str– Agent identifier attached to this thread record. If omitted, a new one is generated. - metadata
dict[str, Any] | None– Optional JSON-like metadata persisted with the conversation thread. - llm
ILlm– Optional LLM override for this thread. If omitted, the client-level LLM configured at construction time is used. By default, either the client or the thread must provide an LLM so automatic memory extraction can run. Setmemory_extraction_config=MemoryExtractionConfig(extract_memories=False)here or on the client to opt out of that requirement. - max_message_token_length
int– Maximum prompt-time message size before truncation or summarization during memory extraction and context-summary updates. Stored message content remains unchanged. When omitted, defaults to15_000tokens. - message_shortening_input_token_limit
int– Maximum size, in tokens, of the message excerpt sent to the LLM when shortening oversized prompt-time message copies. When omitted, defaults to30_000tokens. - memory_extraction_config
MemoryExtractionConfig– Optional per-thread memory extraction configuration. Provided fields override the client configuration. Omitted image context uses the client value, thenDISABLED. The resolved config is stored with the thread so later loads preserve create-time behavior. - image_input_limit_config
ImageInputLimitConfig– Optional per-thread raw-image and LLM image-request limits. Omitted fields inherit from the client configuration. The resolved limits are stored with the thread. - search_config
MemorySearchConfig– Optional search configuration for the thread. When omitted, the client-level configuration is used. - context_card_token_limit
int– Maximum input token budget for the LLM prompt used to build the summary and topic list included in the context card. When omitted, defaults to100_000. - context_card_type_search_concurrency
int– Maximum number of memory-like record searches to run concurrently when building a context card withmin_relevant_results_by_type. When omitted, defaults to5. -
extract_memories
bool–Optional per-thread override for automatic memory extraction. When
True, this thread requires an LLM so automatic extraction can run. Set toFalseto disable automatic extraction for this thread and allow operation without an LLM. When omitted, the client-levelextract_memoriessetting is used.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_window
int–Number of recent messages to include during memory extraction. Set to
-1to perform one extraction peradd_messagescall using the full batch of newly added messages. When omitted, defaults to-1.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
context_summary_update_frequency
int–Number of messages after the latest valid summary before automatically refreshing it. When memory extraction is enabled, the check is after each due extraction, so refresh can occur later. Values less than or equal to
0refresh at every check. When omitted, defaults to-1.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_frequency
int–Frequency of memory extraction updates. Set to
-1to perform one extraction peradd_messagescall using the full batch of newly added messages. When omitted, defaults to-1.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_token_limit
int–Maximum size, in tokens, of the LLM prompts used for memory extraction and running summary updates. When omitted, defaults to
100_000.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_custom_instructions
str–Optional custom instructions appended to the memory extraction system prompt for this thread. When provided, the resolved value is persisted with the thread runtime configuration.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_inherit_message_metadata
bool | Sequence[str]–Optional per-thread override for metadata copied from source messages onto automatically extracted memories.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
enable_context_summary
bool–Whether to keep a running context summary for this thread.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. - **kwargs (Any) – Additional implementation-specific thread options.
- thread_id
- Returns:
An
OracleThreadinstance. - Return type: OracleThread
- Raises:
ValueError – If no LLM is available for automatic memory extraction and the
thread and client were not configured with
memory_extraction_config=MemoryExtractionConfig(extract_memories=False).
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
thread = client.create_thread(thread_id="c1", user_id="u1")
thread.thread_id
'c1'
method create_thread_async (async)
Create and register a thread asynchronously.
- Parameters:
- thread_id
str– Thread identifier. If omitted, a new one is generated. - user_id
str– User identifier attached to this thread record. If omitted and the DB connection carries an end-user security context, that context’s username is used. Otherwise, a new identifier is generated. - agent_id
str– Agent identifier attached to this thread record. If omitted, a new one is generated. - metadata
dict[str, Any] | None– Optional JSON-like metadata persisted with the conversation thread. - llm
ILlm– Optional LLM override for this thread. If omitted, the client-level LLM configured at construction time is used. By default, either the client or the thread must provide an LLM so automatic memory extraction can run. Setmemory_extraction_config=MemoryExtractionConfig(extract_memories=False)here or on the client to opt out of that requirement. - max_message_token_length
int– Maximum prompt-time message size before truncation or summarization during memory extraction and context-summary updates. Stored message content remains unchanged. When omitted, defaults to15_000tokens. - message_shortening_input_token_limit
int– Maximum size, in tokens, of the message excerpt sent to the LLM when shortening oversized prompt-time message copies. When omitted, defaults to30_000tokens. - memory_extraction_config
MemoryExtractionConfig– Optional per-thread memory extraction configuration. Provided fields override the client configuration. Omitted image context uses the client value, thenDISABLED. The resolved config is stored with the thread so later loads preserve create-time behavior. - image_input_limit_config
ImageInputLimitConfig– Optional per-thread raw-image and LLM image-request limits. Omitted fields inherit from the client configuration. The resolved limits are stored with the thread. - search_config
MemorySearchConfig– Optional search configuration for the thread. When omitted, the client-level configuration is used. - context_card_token_limit
int– Maximum input token budget for the LLM prompt used to build the summary and topic list included in the context card. When omitted, defaults to100_000. - context_card_type_search_concurrency
int– Maximum number of memory-like record searches to run concurrently when building a context card withmin_relevant_results_by_type. When omitted, defaults to5. -
extract_memories
bool–Optional per-thread override for automatic memory extraction. When
True, this thread requires an LLM so automatic extraction can run. Set toFalseto disable automatic extraction for this thread and allow operation without an LLM. When omitted, the client-levelextract_memoriessetting is used.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_window
int–Number of recent messages to include during memory extraction. Set to
-1to perform one extraction peradd_messagescall using the full batch of newly added messages. When omitted, defaults to-1.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
context_summary_update_frequency
int–Number of messages after the latest valid summary before automatically refreshing it. When memory extraction is enabled, the check is after each due extraction, so refresh can occur later. Values less than or equal to
0refresh at every check. When omitted, defaults to-1.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_frequency
int–Frequency of memory extraction updates. Set to
-1to perform one extraction peradd_messagescall using the full batch of newly added messages. When omitted, defaults to-1.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_token_limit
int–Maximum size, in tokens, of the LLM prompts used for memory extraction and running summary updates. When omitted, defaults to
100_000.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_custom_instructions
str–Optional custom instructions appended to the memory extraction system prompt for this thread. When provided, the resolved value is persisted with the thread runtime configuration.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_inherit_message_metadata
bool | Sequence[str]–Optional per-thread override for metadata copied from source messages onto automatically extracted memories.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
enable_context_summary
bool–Whether to keep a running context summary for this thread.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. - **kwargs (Any) – Additional implementation-specific thread options.
- thread_id
- Returns:
An
OracleThreadinstance. - Return type: OracleThread
- Raises:
ValueError – If no LLM is available for automatic memory extraction and the
thread and client were not configured with
memory_extraction_config=MemoryExtractionConfig(extract_memories=False).
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
import asyncio
thread = asyncio.run(client.create_thread_async(
thread_id="c1", user_id="u1"
))
thread.thread_id
'c1'
method delete_agent
Delete an agent profile record by identifier.
- Parameters:
- agent_id
str– Agent identifier whose profile should be removed. - cascade
bool– WhenTrue(default), also delete records scoped to this agent. This includes deleting owned threads themselves, the messages and memory-like records removed with those threads, and any remaining directly agent-scoped records such as messages, memories, guidelines, facts, or preferences. This scoped cleanup still runs when the matching agent-profile row is already absent. Set toFalseto remove only the profile record.
- agent_id
- Returns:
Number of deleted agent-profile rows (
0or1). This may still be0when scoped rows were removed during cascade cleanup. - Return type: int
- Raises: TimeoutError – Raised when earlier accepted background extraction for already- known owned threads does not finish before the internal delete wait times out.
Notes
Before deleting the profile, this method waits up to 300 seconds for earlier background extraction already accepted for owned threads known through this agent memory component. This wait applies whether or not cascade cleanup is enabled. Cascading cleanup is planned and executed inside the backing store as one operation. The method does not wait for work accepted after the wait begins or for work started by another agent memory component or process. Concurrent actor-scoped use while deletion is in progress is unsupported.
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
client.add_agent("a-delete", "Support assistant")
'a-delete'
client.delete_agent("a-delete")
1
method delete_agent_async (async)
Delete an agent profile record by identifier asynchronously.
- Parameters:
- agent_id
str– Agent identifier whose profile should be removed. - cascade
bool– WhenTrue(default), also delete records scoped to this agent. This includes deleting owned threads themselves, the messages and memory-like records removed with those threads, and any remaining directly agent-scoped records such as messages, memories, guidelines, facts, or preferences. This scoped cleanup still runs when the matching agent-profile row is already absent. Set toFalseto remove only the profile record.
- agent_id
- Returns:
Number of deleted agent-profile rows (
0or1). This may still be0when scoped rows were removed during cascade cleanup. - Return type: int
- Raises: TimeoutError – Raised without deleting the profile when earlier accepted background extraction for known owned threads does not finish within 300 seconds.
Notes
This method follows the background-extraction wait and concurrency
behavior documented by delete_agent().
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
import asyncio
asyncio.run(client.add_agent_async("a-delete", "Support assistant"))
'a-delete'
asyncio.run(client.delete_agent_async("a-delete"))
1
method delete_image
Delete an image record by identifier.
- Parameters:
image_id
str– Identifier of the image record to remove. - Returns: Number of deleted image records.
- Return type: int
- Raises: ValueError – If the image is attached to a message. Delete or update the parent message instead.
method delete_image_async (async)
Delete one standalone image through the configured store.
- Parameters:
image_id
str– Identifier of the image to delete. - Returns:
1when deleted, otherwise0when no matching image exists. - Return type: int
- Raises: ValueError – If the image is attached to a message. Delete or update the parent message instead.
method delete_memory
Delete a memory-like record (e.g., a memory, fact, preference, or guideline) by identifier.
- Parameters:
memory_id
str– Memory identifier. The identifier may refer to a storedmemory,guideline,fact, orpreferencerecord. - Returns:
Number of deleted memory-like rows (
0or1). - Return type: int
- Raises: TimeoutError – Raised without deleting the record when earlier accepted background extraction for its stored thread does not finish within 300 seconds.
Notes
Before deleting a thread-scoped record, this method resolves its stored thread and waits for earlier background extraction accepted through this agent memory component. It does not wait for unrelated threads, work accepted after the wait begins, or work started by another agent memory component or process. Records without a thread scope and unknown identifiers do not cause an extraction wait.
Examples
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
memory_id = client.add_memory("Temporary memory", memory_id="mem-delete")
client.delete_memory(memory_id)
1
method delete_memory_async (async)
Delete a memory-like record asynchronously.
- Parameters:
memory_id
str– Memory identifier. The identifier may refer to a storedmemory,guideline,fact, orpreferencerecord. - Returns:
Number of deleted memory-like rows (
0or1). - Return type: int
- Raises: TimeoutError – Raised without deleting the record when earlier accepted background extraction for its stored thread does not finish within 300 seconds.
Notes
This method follows the targeted background-extraction wait and
concurrency behavior documented by delete_memory().
Examples
import asyncio
memory_id = asyncio.run(client.add_memory_async(
"Temporary memory", memory_id="mem-delete"
))
asyncio.run(client.delete_memory_async(memory_id))
1
method delete_record_link
Delete a relation by identifier or complete endpoint tuple.
When no relation_id is supplied, provide every source, target,
type, and relation-label argument in the stored source-to-target
orientation.
- Parameters:
- source_record_id
str– Source identifier when selecting by endpoint tuple. - source_record_type
str– Logical source record type when selecting by endpoint tuple. - target_record_id
str– Target identifier when selecting by endpoint tuple. - target_record_type
str– Logical target record type when selecting by endpoint tuple. - relation_type
str– Source-to-target label when selecting by endpoint tuple. - relation_id
str– Relation identifier to select directly. Provide this alone.
- source_record_id
- Returns:
Number of deleted relations, either
0or1. - Return type: int
Examples
client.delete_record_link(relation_id="relation-id")
1
method delete_record_link_async (async)
Asynchronously delete a relation by ID or complete endpoint tuple.
- Parameters:
- source_record_id
str - source_record_type
str - target_record_id
str - target_record_type
str - relation_type
str - relation_id
str
- source_record_id
- Return type: int
method delete_thread
Delete all records associated with a thread identifier.
- Parameters:
thread_id
str– Thread identifier to delete. - Returns:
Number of deleted conversation threads (
0or1). - Return type: int
- Raises: TimeoutError – Raised when earlier accepted background extraction for this thread does not finish before the internal delete wait times out.
Notes
Use this operation when you need retention-complete removal of a
thread. The backing store deletes the thread together with associated
thread-scoped messages, durable memories, and managed retrieval data.
This differs from OracleThread.delete_message(), which removes only
the raw message record and does not cascade to derived memories created
from that message. Before deleting the thread, this method waits for
earlier background extraction already accepted for that thread through
this agent memory component. It does not wait for background work
accepted after that wait begins or for work started by another agent
memory component or process. Concurrent use of the same thread while
deletion is in progress is unsupported.
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
thread = client.create_thread(thread_id="c-delete")
client.delete_thread(thread.thread_id)
1
method delete_thread_async (async)
Delete all records associated with a thread identifier asynchronously.
- Parameters:
thread_id
str– Thread identifier to delete. - Returns:
Number of deleted conversation threads (
0or1). - Return type: int
- Raises: TimeoutError – Raised when earlier accepted background extraction for this thread does not finish before the internal delete wait times out.
Notes
Use this operation when you need retention-complete removal of a
thread. The backing store deletes the thread together with associated
thread-scoped messages, durable memories, and managed retrieval data.
This differs from OracleThread.delete_message(), which removes only
the raw message record and does not cascade to derived memories created
from that message. Before deleting the thread, this method waits for
earlier background extraction already accepted for that thread through
this agent memory component. It does not wait for background work
accepted after that wait begins or for work started by another agent
memory component or process. Concurrent use of the same thread while
deletion is in progress is unsupported.
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
import asyncio
thread = asyncio.run(client.create_thread_async(thread_id="c-delete"))
asyncio.run(client.delete_thread_async(thread.thread_id))
1
method delete_user
Delete a user profile record by identifier.
- Parameters:
- user_id
str– User identifier whose profile should be removed. - cascade
bool– WhenTrue(default), also delete records scoped to this user. This includes deleting owned threads themselves, the messages and memory-like records removed with those threads, and any remaining directly user-scoped records such as messages, memories, guidelines, facts, or preferences. This scoped cleanup still runs when the matching user-profile row is already absent. Set toFalseto remove only the profile record.
- user_id
- Returns:
Number of deleted user-profile rows (
0or1). This may still be0when scoped rows were removed during cascade cleanup. - Return type: int
- Raises: TimeoutError – Raised when earlier accepted background extraction for already- known owned threads does not finish before the internal delete wait times out.
Notes
Before deleting the profile, this method waits up to 300 seconds for earlier background extraction already accepted for owned threads known through this agent memory component. This wait applies whether or not cascade cleanup is enabled. Cascading cleanup is planned and executed inside the backing store as one operation. The method does not wait for work accepted after the wait begins or for work started by another agent memory component or process. Concurrent actor-scoped use while deletion is in progress is unsupported.
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
client.add_user("u-delete", "Prefers concise answers.")
'u-delete'
client.delete_user("u-delete")
1
method delete_user_async (async)
Delete a user profile record by identifier asynchronously.
- Parameters:
- user_id
str– User identifier whose profile should be removed. - cascade
bool– WhenTrue(default), also delete records scoped to this user. This includes deleting owned threads themselves, the messages and memory-like records removed with those threads, and any remaining directly user-scoped records such as messages, memories, guidelines, facts, or preferences. This scoped cleanup still runs when the matching user-profile row is already absent. Set toFalseto remove only the profile record.
- user_id
- Returns:
Number of deleted user-profile rows (
0or1). This may still be0when scoped rows were removed during cascade cleanup. - Return type: int
- Raises: TimeoutError – Raised without deleting the profile when earlier accepted background extraction for known owned threads does not finish within 300 seconds.
Notes
This method follows the background-extraction wait and concurrency
behavior documented by delete_user().
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
import asyncio
asyncio.run(client.add_user_async("u-delete", "Prefers concise answers."))
'u-delete'
asyncio.run(client.delete_user_async("u-delete"))
1
method get_thread
Retrieve a previously created thread.
- Parameters:
- thread_id
str– Identifier used when creating the thread. - llm
ILlm– Optional LLM override for the reopened thread. When omitted, the client-level LLM configured at construction time is used. - max_message_token_length
int– Optional override for the maximum prompt-time message size before truncation or summarization during memory extraction and context-summary updates. Stored message content remains unchanged. - message_shortening_input_token_limit
int– Optional override for the maximum size, in tokens, of the message excerpt sent to the LLM when shortening oversized prompt-time message copies. - memory_extraction_config
MemoryExtractionConfig– Optional grouped extraction config for the returnedOracleThreadinstance. Provided fields override saved thread values. An omitted image context uses the saved thread value, then the client value, thenDISABLED. The override applies only to the returnedOracleThreadinstance and is not written back to the stored conversation thread config. - image_input_limit_config
ImageInputLimitConfig– Optional raw-image and LLM image-request limit override. Omitted fields inherit stored thread limits. This override applies only to the returned thread and is not persisted. - search_config
MemorySearchConfig– Optional search configuration for the returnedOracleThread. When omitted, the stored or client-level configuration is used. This override applies only to the returned thread. - context_card_token_limit
int– Optional override for the returnedOracleThreadinstance. It sets the input token budget of the LLM prompt used to build the summary and topic list included in the context card. - context_card_type_search_concurrency
int– Optional override for the returnedOracleThreadinstance. It sets the number of memory-like record searches to run concurrently when building a context card withmin_relevant_results_by_type. -
extract_memories
bool–Optional override for automatic memory extraction on the reopened thread. When omitted, the client-level
extract_memoriessetting is used.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_window
int–Optional override for the number of recent messages used during memory extraction.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
context_summary_update_frequency
int–Optional override for messages after the latest valid summary before automatic refresh.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_frequency
int–Optional override for the frequency of memory extraction updates.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_token_limit
int–Optional override for the maximum size, in tokens, of the LLM prompts used for memory extraction and running summary updates.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_custom_instructions
str | None–Optional override for custom memory extraction instructions. Passing
Noneclears thread-level custom instructions for the returnedOracleThreadinstance without updating the stored conversation thread config; a client-level default still applies when configured.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_inherit_message_metadata
bool | Sequence[str]–Optional override for metadata copied from source messages onto automatically extracted memories. The override applies only to the returned
OracleThreadinstance.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
enable_context_summary
bool–Optional override for whether the reopened thread should keep a running context summary.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead.
- thread_id
- Returns:
An
OracleThreadinstance reconstructed from store metadata. - Return type: OracleThread
- Raises:
- KeyError – If the thread id is unknown to this client instance.
- ValueError – If no LLM is available for automatic memory extraction and the
client was not configured with
memory_extraction_config=MemoryExtractionConfig(extract_memories=False).
Notes
Explicit per-call overrides take precedence. When runtime overrides are omitted, reopened threads use persisted runtime config when available before falling back to SDK defaults.
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
created = client.create_thread(thread_id="c2", user_id="u1")
loaded = client.get_thread("c2")
loaded.user_id
'u1'
method get_thread_async (async)
Retrieve a previously created thread asynchronously.
- Parameters:
- thread_id
str– Identifier used when creating the thread. - llm
ILlm– Optional LLM override for the reopened thread. When omitted, the client-level LLM configured at construction time is used. - max_message_token_length
int– Optional override for the maximum prompt-time message size before truncation or summarization during memory extraction and context-summary updates. Stored message content remains unchanged. - message_shortening_input_token_limit
int– Optional override for the maximum size, in tokens, of the message excerpt sent to the LLM when shortening oversized prompt-time message copies. - memory_extraction_config
MemoryExtractionConfig– Optional grouped extraction config for the returnedOracleThreadinstance. Provided fields override saved thread values. An omitted image context uses the saved thread value, then the client value, thenDISABLED. The override applies only to the returnedOracleThreadinstance and is not written back to the stored conversation thread config. - image_input_limit_config
ImageInputLimitConfig– Optional raw-image and LLM image-request limit override. Omitted fields inherit stored thread limits. This override applies only to the returned thread and is not persisted. - search_config
MemorySearchConfig– Optional search configuration for the returnedOracleThread. When omitted, the stored or client-level configuration is used. This override applies only to the returned thread. - context_card_token_limit
int– Optional override for the returnedOracleThreadinstance. It sets the input token budget of the LLM prompt used to build the summary and topic list included in the context card. - context_card_type_search_concurrency
int– Optional override for the returnedOracleThreadinstance. It sets the number of memory-like record searches to run concurrently when building a context card withmin_relevant_results_by_type. -
extract_memories
bool–Optional override for automatic memory extraction on the reopened thread. When omitted, the client-level
extract_memoriessetting is used.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_window
int–Optional override for the number of recent messages used during memory extraction.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
context_summary_update_frequency
int–Optional override for messages after the latest valid summary before automatic refresh.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_frequency
int–Optional override for the frequency of memory extraction updates.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_token_limit
int–Optional override for the maximum size, in tokens, of the LLM prompts used for memory extraction and running summary updates.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_custom_instructions
str | None–Optional override for custom memory extraction instructions. Passing
Noneclears thread-level custom instructions for the returnedOracleThreadinstance without updating the stored conversation thread config; a client-level default still applies when configured.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_inherit_message_metadata
bool | Sequence[str]–Optional override for metadata copied from source messages onto automatically extracted memories. The override applies only to the returned
OracleThreadinstance.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
enable_context_summary
bool–Optional override for whether the reopened thread should keep a running context summary.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead.
- thread_id
- Returns:
An
OracleThreadinstance reconstructed from store metadata. - Return type: OracleThread
- Raises:
- KeyError – If the thread id is unknown to this client instance.
- ValueError – If no LLM is available for automatic memory extraction and the
client was not configured with
memory_extraction_config=MemoryExtractionConfig(extract_memories=False).
Notes
Explicit per-call overrides take precedence. When runtime overrides are omitted, reopened threads use persisted runtime config when available before falling back to SDK defaults.
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
import asyncio
created = asyncio.run(client.create_thread_async(
thread_id="c2", user_id="u1"
))
loaded = asyncio.run(client.get_thread_async("c2"))
loaded.user_id
'u1'
method link_records
Create a directed relation between two stored records.
Currently, both endpoints must be memory-like records: "memory",
"fact", "guideline", or "preference". Built-in relation
types are "supersedes" ("is_superseded_by"),
"contradicts", "refines" ("is_refined_by"),
"supports" ("is_supported_by"), and "duplicates".
"contradicts" and "duplicates" use the same label in reverse.
Only one orientation can be stored for an endpoint pair.
opposite_relation_type names the relation when traversing from
target to source. For example, if new "supersedes" old,
the reverse traversal is old "is_superseded_by" new.
- Parameters:
- source_record_id
str– Identifier of the source record. - source_record_type
str– Logical type of the source record. - target_record_id
str– Identifier of the target record. - target_record_type
str– Logical type of the target record. - relation_type
str– Label in the source-to-target direction. - opposite_relation_type
str– Optional label to use when traversing this relation in reverse. For built-in memory relation types, omit this to store the predefined reverse label (for example,"supports"becomes"is_supported_by"). For custom relation types, omission uses the same label in both directions. - relation_id
str– Optional stable relation identifier. Omit it to generate one. - timestamp
str | None– Optional timestamp associated with the relation. - metadata
dict[str, Any] | None– Optional metadata stored on the relation.
- source_record_id
- Returns: Identifier of the created relation.
- Return type: str
Examples
client.link_records(
"fact-1", "fact", "memory-1", "memory", "supports"
)
'relation-id'
method link_records_async (async)
Asynchronously create a typed relation between stored records.
Currently, both endpoints must be memory-like records: "memory",
"fact", "guideline", or "preference". Built-in relation
types are "supersedes" ("is_superseded_by"),
"contradicts", "refines" ("is_refined_by"),
"supports" ("is_supported_by"), and "duplicates".
"contradicts" and "duplicates" use the same label in reverse.
- Parameters:
- source_record_id
str - source_record_type
str - target_record_id
str - target_record_type
str - relation_type
str - opposite_relation_type
str - relation_id
str - timestamp
str | None - metadata
dict[str, Any] | None
- source_record_id
- Return type: str
method list_agents
List persisted agent profile records.
- Parameters:
- metadata_filter
dict[str, Any] | None– Metadata filter applied to agent profile metadata. When omitted, no metadata filtering is applied. PassNoneto list only profiles with no stored metadata. - limit
int | None– Optional maximum number of records to return. When omitted, the backing store may apply its default listing cap. PassNoneto disable that cap.
- metadata_filter
- Returns: Agent profile records returned by the backing store.
- Return type: list[AgentProfileRecord]
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
client.add_agent("a1", "Support assistant", metadata={"source": "catalog"})
'a1'
[record.id for record in client.list_agents(metadata_filter={"source": "catalog"})]
['a1']
method list_agents_async (async)
List persisted agent profile records asynchronously.
- Parameters:
- metadata_filter
dict[str, Any] | None– Metadata filter applied to agent profile metadata. When omitted, no metadata filtering is applied. PassNoneto list only profiles with no stored metadata. - limit
int | None– Optional maximum number of records to return. When omitted, the backing store may apply its default listing cap. PassNoneto disable that cap.
- metadata_filter
- Returns: Agent profile records returned by the backing store.
- Return type: list[AgentProfileRecord]
Examples
import anyio
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
async def main():
await client.add_agent_async(
"a1",
"Support assistant",
metadata={"source": "catalog"},
)
records = await client.list_agents_async(metadata_filter={"source": "catalog"})
return [record.id for record in records]
anyio.run(main)
['a1']
method list_images
List persisted standalone image records.
- Parameters:
- image_id
str– Optional image identifier used to narrow the records returned by the backing store. When omitted, no identifier filter is applied. The identifier filter is applied beforelimit. - user_id
str | None– Optional exact user filter. When omitted, images for any user are returned. PassNoneto list only images with no user scope. At least one non-Noneuser, agent, or thread scope is required. - agent_id
str | None– Optional exact agent filter. When omitted, images for any agent are returned. PassNoneto list only images with no agent scope. - thread_id
str | None– Optional exact thread filter. When omitted, images for any thread are returned. PassNoneto list only images with no thread scope. - metadata_filter
dict[str, Any] | None– Metadata filter applied to image metadata. When omitted, no metadata filtering is applied. PassNoneto list only images with no stored metadata. - include_bytes
bool– Whether to load image bytes in each returned record. When omitted orFalse, image bytes are not loaded. Set this toTrueonly with animage_idand at least one exact user, agent, or thread scope filter. - limit
int | None– Optional maximum number of records requested from the backing store. When omitted, the store may apply its default listing cap. PassNoneto disable that cap.
- image_id
- Returns: Matching image records ordered by the backing store.
- Return type: list[ImageRecord]
Examples
images = client.list_images(user_id="u1", limit=10)
[image.id for image in images]
['img-1']
method list_images_async (async)
List persisted standalone image records asynchronously.
- Parameters:
- image_id
str– Optional image identifier used to narrow the records returned by the backing store. When omitted, no identifier filter is applied. The identifier filter is applied beforelimit. - user_id
str | None– Optional exact user filter. When omitted, images for any user are returned. PassNoneto list only images with no user scope. At least one non-Noneuser, agent, or thread scope is required. - agent_id
str | None– Optional exact agent filter. When omitted, images for any agent are returned. PassNoneto list only images with no agent scope. - thread_id
str | None– Optional exact thread filter. When omitted, images for any thread are returned. PassNoneto list only images with no thread scope. - metadata_filter
dict[str, Any] | None– Metadata filter applied to image metadata. When omitted, no metadata filtering is applied. PassNoneto list only images with no stored metadata. - include_bytes
bool– Whether to load image bytes in each returned record. When omitted orFalse, image bytes are not loaded. Set this toTrueonly with animage_idand at least one exact user, agent, or thread scope filter. - limit
int | None– Optional maximum number of records requested from the backing store. When omitted, the store may apply its default listing cap. PassNoneto disable that cap.
- image_id
- Returns: Matching image records ordered by the backing store.
- Return type: list[ImageRecord]
Examples
images = await client.list_images_async(
user_id="u1",
limit=10,
)
[image.id for image in images]
['img-1']
method list_memories
List persisted memory-like records.
- Parameters:
- user_id
str | None– Optional exact user filter. When omitted, memories for any user are returned. PassNoneto list only memories with no user scope. - agent_id
str | None– Optional exact agent filter. When omitted, memories for any agent are returned. PassNoneto list only memories with no agent scope. - thread_id
str | None– Optional exact thread filter. When omitted, memories for any thread are returned. PassNoneto list only memories with no thread scope. - metadata_filter
dict[str, Any] | None– Metadata filter applied to memory metadata. When omitted, no metadata filtering is applied. PassNoneto list only memories with no stored metadata. - limit
int | None– Optional maximum number of records to return. When omitted, the backing store may apply its default listing cap. PassNoneto disable that cap.
- user_id
- Returns:
Memory-like records returned by the backing store, including
"memory","guideline","fact", and"preference"records. - Return type: list[MemoryRecord]
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
client.add_memory("User likes pizza.", user_id="u1", memory_id="mem-1")
'mem-1'
[record.id for record in client.list_memories(user_id="u1", limit=10)]
['mem-1']
method list_memories_async (async)
List persisted memory-like records asynchronously.
- Parameters:
- user_id
str | None– Optional exact user filter. When omitted, memories for any user are returned. PassNoneto list only memories with no user scope. - agent_id
str | None– Optional exact agent filter. When omitted, memories for any agent are returned. PassNoneto list only memories with no agent scope. - thread_id
str | None– Optional exact thread filter. When omitted, memories for any thread are returned. PassNoneto list only memories with no thread scope. - metadata_filter
dict[str, Any] | None– Metadata filter applied to memory metadata. When omitted, no metadata filtering is applied. PassNoneto list only memories with no stored metadata. - limit
int | None– Optional maximum number of records to return. When omitted, the backing store may apply its default listing cap. PassNoneto disable that cap.
- user_id
- Returns:
Memory-like records returned by the backing store, including
"memory","guideline","fact", and"preference"records. - Return type: list[MemoryRecord]
Examples
import anyio
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
async def main():
await client.add_memory_async("User likes pizza.", user_id="u1", memory_id="mem-1")
records = await client.list_memories_async(user_id="u1", limit=10)
return [record.id for record in records]
anyio.run(main)
['mem-1']
method list_messages
List persisted chat message records.
- Parameters:
- user_id
str | None– Optional exact user filter. When omitted, messages for any user are returned. PassNoneto list only messages with no user scope. - agent_id
str | None– Optional exact agent filter. When omitted, messages for any agent are returned. PassNoneto list only messages with no agent scope. - thread_id
str | None– Optional exact thread filter. When omitted, messages for any thread are returned. PassNoneto list only messages with no thread scope. - metadata_filter
dict[str, Any] | None– Metadata filter applied to message metadata. When omitted, no metadata filtering is applied. PassNoneto list only messages with no stored metadata. - limit
int | None– Optional maximum number of records to return. When omitted, the backing store may apply its default listing cap. PassNoneto disable that cap. - include_image_bytes
bool– Whether image parts attached to returned messages include their stored bytes. When omitted orFalse, attached image metadata is returned without loading the bytes. Set toTrueto load the bytes.
- user_id
- Returns: Message records returned by the backing store.
- Return type: list[MessageRecord]
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
thread = client.create_thread(thread_id="c1", user_id="u1")
message_id = thread.add_messages([{"role": "user", "content": "Hello"}])[0]
[record.id for record in client.list_messages(thread_id="c1", limit=10)] == [message_id]
True
method list_messages_async (async)
List persisted chat message records asynchronously.
- Parameters:
- user_id
str | None– Optional exact user filter. When omitted, messages for any user are returned. PassNoneto list only messages with no user scope. - agent_id
str | None– Optional exact agent filter. When omitted, messages for any agent are returned. PassNoneto list only messages with no agent scope. - thread_id
str | None– Optional exact thread filter. When omitted, messages for any thread are returned. PassNoneto list only messages with no thread scope. - metadata_filter
dict[str, Any] | None– Metadata filter applied to message metadata. When omitted, no metadata filtering is applied. PassNoneto list only messages with no stored metadata. - limit
int | None– Optional maximum number of records to return. When omitted, the backing store may apply its default listing cap. PassNoneto disable that cap. - include_image_bytes
bool– Whether image parts attached to returned messages include their stored bytes. When omitted orFalse, attached image metadata is returned without loading the bytes. Set toTrueto load the bytes.
- user_id
- Returns: Message records returned by the backing store.
- Return type: list[MessageRecord]
Examples
import anyio
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
async def main():
thread = await client.create_thread_async(thread_id="c1", user_id="u1")
message_ids = await thread.add_messages_async(
[{"role": "user", "content": "Hello"}]
)
records = await client.list_messages_async(thread_id="c1", limit=10)
return [record.id for record in records] == message_ids
anyio.run(main)
True
method list_threads
List persisted conversation threads.
- Parameters:
- user_id
str | None– Required exact user filter. PassNoneto list only threads with no user scope. - agent_id
str | None– Optional exact agent filter. When omitted, threads for any agent are returned. PassNoneto list only threads with no agent scope. - metadata_filter
dict[str, Any] | None– Metadata filter applied to thread metadata. When omitted, no metadata filtering is applied. PassNoneto list only threads with no stored metadata. - limit
int | None– Optional maximum number of records to return. When omitted, the backing store may apply its default listing cap. PassNoneto disable that cap.
- user_id
- Returns: Thread records returned by the backing store.
- Return type: list[ThreadRecord]
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
client.create_thread(thread_id="c1", user_id="u1").thread_id
'c1'
[record.thread_id for record in client.list_threads(user_id="u1", limit=10)]
['c1']
method list_threads_async (async)
List persisted conversation threads asynchronously.
- Parameters:
- user_id
str | None– Required exact user filter. PassNoneto list only threads with no user scope. - agent_id
str | None– Optional exact agent filter. When omitted, threads for any agent are returned. PassNoneto list only threads with no agent scope. - metadata_filter
dict[str, Any] | None– Metadata filter applied to thread metadata. When omitted, no metadata filtering is applied. PassNoneto list only threads with no stored metadata. - limit
int | None– Optional maximum number of records to return. When omitted, the backing store may apply its default listing cap. PassNoneto disable that cap.
- user_id
- Returns: Thread records returned by the backing store.
- Return type: list[ThreadRecord]
Examples
import anyio
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
async def main():
await client.create_thread_async(thread_id="c1", user_id="u1")
records = await client.list_threads_async(user_id="u1", limit=10)
return [record.thread_id for record in records]
anyio.run(main)
['c1']
method list_users
List persisted user profile records.
- Parameters:
- metadata_filter
dict[str, Any] | None– Metadata filter applied to user profile metadata. When omitted, no metadata filtering is applied. PassNoneto list only profiles with no stored metadata. - limit
int | None– Optional maximum number of records to return. When omitted, the backing store may apply its default listing cap. PassNoneto disable that cap.
- metadata_filter
- Returns: User profile records returned by the backing store.
- Return type: list[UserProfileRecord]
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
client.add_user("u1", "Prefers concise answers.", metadata={"source": "crm"})
'u1'
[record.id for record in client.list_users(metadata_filter={"source": "crm"})]
['u1']
method list_users_async (async)
List persisted user profile records asynchronously.
- Parameters:
- metadata_filter
dict[str, Any] | None– Metadata filter applied to user profile metadata. When omitted, no metadata filtering is applied. PassNoneto list only profiles with no stored metadata. - limit
int | None– Optional maximum number of records to return. When omitted, the backing store may apply its default listing cap. PassNoneto disable that cap.
- metadata_filter
- Returns: User profile records returned by the backing store.
- Return type: list[UserProfileRecord]
Examples
import anyio
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
async def main():
await client.add_user_async(
"u1",
"Prefers concise answers.",
metadata={"source": "crm"},
)
records = await client.list_users_async(metadata_filter={"source": "crm"})
return [record.id for record in records]
anyio.run(main)
['u1']
method search
Search synchronously for records relevant to a query.
- Parameters:
- query
str– Natural-language query string. - user_id
str | None– User identifier filter. OracleAgentMemory client searches require an explicit user scope unlessscopeis provided with one. Pass a concreteuser_idto target that user, or passNoneto target only unscoped user records. - agent_id
str | None– Optional agent identifier filter. Ignored whenscopeis provided. - thread_id
str | None– Optional thread identifier filter. Ignored whenscopeis provided. - exact_user_match
bool– Whether user matching should be strict. OracleAgentMemory client searches require exact user matching and rejectFalse. Ignored whenscopeis provided. - exact_agent_match
bool– Whether agent matching should be strict. Ignored whenscopeis provided. - exact_thread_match
bool– Whether thread matching should be strict. Ignored whenscopeis provided. - max_results
int– Optional maximum number of results to return. When provided, it must be at least1. Omitting this argument uses the default value of10. This is an upper bound: the call may return fewer thanmax_resultsresults when filters are too restrictive, when fewer non-expired matching records exist, or because of implementation-specific search behavior. - token_budget
int– Optional hard limit for the estimated token count of the final formatted results. When omitted, the resolved search configuration is used. Positive values keep complete results in rank order while their cumulative estimate fits the budget. If the first result does not fit, no results are returned. Non-positive values disable this output bound. - soft_token_budget
int– Optional target for the estimated token count of the final formatted results. When omitted, the resolved search configuration is used. The complete result that reaches or exceeds this target is retained. Non-positive values disable this target. Settoken_budgetto a larger value when the output must also have an absolute limit. - record_types
list[str]– Optional list of record types to include, such as"memory","message", or"image". -
metadata_filter
dict[str, Any] | None–Optional metadata filter mapping used as an additional filter after scope and record-type filtering. Entries in
metadata_filterare combined with AND semantics. Entries whose value is not a field-level operator dictionary use exact-match semantics: the requested key must exist in the stored record metadata. Nested dictionaries match nested metadata objects recursively. Scalar and list values must match exactly; list order and length must also match. Omit this argument, or passNone, to search without metadata filtering. Examples includemetadata_filter={"source": "profile_import"}for a scalar field,metadata_filter={"prefs": {"category": "travel"}}for a nested field, andmetadata_filter={"tags": ["survey", "travel"]}for an exact list match. Combine conditions to require all of them:metadata_filter={ "source": "profile_import", "prefs": {"category": "travel"}, "tags": ["survey", "travel"], }To test array membership, use a field-level operator dictionary.
"$array_contains"matches one value, or all values in a list."$array_contains_any"matches at least one value from a list."$not"negates another field-level expression at the same field, including an operator dictionary or raw exact-match value. Negated expressions match when the positive expression would fail, including missing fields; negated array membership also matches non-array fields:metadata_filter={ "source": "profile_import", "tags": { "$array_contains": "travel", "$not": {"$array_contains": "archived"}, }, } - include_invalid_results
bool– Whether results include records in the invalid status. Omit this argument or passTrueto include them. PassFalseto exclude them. - num_hops
int– Number of memory-link edges to follow from each direct memory result. Values from0through5are supported; omit for direct results only. Expansion follows links in either direction. - max_linked_results
int– Maximum linked memories across all hops attached to each direct result. Omit for the default of100; pass0to return no linked context. - scope
SearchScope– Optional prebuilt search scope. Provide eitherscopeor the explicit identifier and exact-match arguments, not both. OracleAgentMemory client searches require the resolved scope to include an explicituser_idwithexact_user_match=True. Useuser_id=Noneto target only unscoped user records.
- query
- Returns:
Search results ordered by decreasing relevance. The list may
contain fewer than
max_resultsentries. - Return type: list[SearchResult]
- Raises:
ValueError – If
scopeis combined with explicit identifier or exact-match arguments, ifmax_resultsis less than1, ifmetadata_filteris neither a dictionary norNone, or if the implementation rejects the resolved client search scope. OracleAgentMemory client searches reject omitted user scope and rejectexact_user_match=False.
Notes
Explicit None scope values still follow the resolved exact-match
rules: exact_*_match=False leaves that dimension unconstrained,
while exact_*_match=True matches only records unscoped on that
dimension.
method search_async (async)
Search asynchronously for records relevant to a query.
- Parameters:
- query
str– Natural-language query string. - user_id
str | None– User identifier filter. OracleAgentMemory client searches require an explicit user scope unlessscopeis provided with one. Pass a concreteuser_idto target that user, or passNoneto target only unscoped user records. - agent_id
str | None– Optional agent identifier filter. Ignored whenscopeis provided. - thread_id
str | None– Optional thread identifier filter. Ignored whenscopeis provided. - exact_user_match
bool– Whether user matching should be strict. OracleAgentMemory client searches require exact user matching and rejectFalse. Ignored whenscopeis provided. - exact_agent_match
bool– Whether agent matching should be strict. Ignored whenscopeis provided. - exact_thread_match
bool– Whether thread matching should be strict. Ignored whenscopeis provided. - max_results
int– Optional maximum number of results to return. When provided, it must be at least1. Omitting this argument uses the default value of10. - token_budget
int– Optional hard limit for the estimated token count of the final formatted results. When omitted, the resolved search configuration is used. Positive values keep complete results in rank order while their cumulative estimate fits the budget. If the first result does not fit, no results are returned. Non-positive values disable this output bound. - soft_token_budget
int– Optional target for the estimated token count of the final formatted results. When omitted, the resolved search configuration is used. The complete result that reaches or exceeds this target is retained. Non-positive values disable this target. Settoken_budgetto a larger value when the output must also have an absolute limit. - record_types
list[str]– Optional list of record types to include, such as"memory","message", or"image". -
metadata_filter
dict[str, Any] | None–Optional metadata filter mapping used as an additional filter after scope and record-type filtering. Entries in
metadata_filterare combined with AND semantics. Entries whose value is not a field-level operator dictionary use exact-match semantics: the requested key must exist in the stored record metadata. Nested dictionaries match nested metadata objects recursively. Scalar and list values must match exactly; list order and length must also match. Omit this argument, or passNone, to search without metadata filtering. Examples includemetadata_filter={"source": "profile_import"}for a scalar field,metadata_filter={"prefs": {"category": "travel"}}for a nested field, andmetadata_filter={"tags": ["survey", "travel"]}for an exact list match. Combine conditions to require all of them:metadata_filter={ "source": "profile_import", "prefs": {"category": "travel"}, "tags": ["survey", "travel"], }To test array membership, use a field-level operator dictionary.
"$array_contains"matches one value, or all values in a list."$array_contains_any"matches at least one value from a list."$not"negates another field-level expression at the same field, including an operator dictionary or raw exact-match value. Negated expressions match when the positive expression would fail, including missing fields; negated array membership also matches non-array fields:metadata_filter={ "source": "profile_import", "tags": { "$array_contains": "travel", "$not": {"$array_contains": "archived"}, }, } - include_invalid_results
bool– Whether results include records in the invalid status. Omit this argument or passTrueto include them. PassFalseto exclude them. - num_hops
int– Number of memory-link edges to follow from each direct memory result. Values from0through5are supported; omit for direct results only. Expansion follows links in either direction. - max_linked_results
int– Maximum linked memories across all hops attached to each direct result. Omit for the default of100; pass0to return no linked context. - scope
SearchScope– Optional prebuilt search scope. Provide eitherscopeor the explicit identifier and exact-match arguments, not both. OracleAgentMemory client searches require the resolved scope to include an explicituser_idwithexact_user_match=True. Useuser_id=Noneto target only unscoped user records.
- query
- Returns: Search results ordered by decreasing relevance.
- Return type: list[SearchResult]
- Raises:
ValueError – If
scopeis combined with explicit identifier or exact-match arguments, ifmax_resultsis less than1, ifmetadata_filteris neither a dictionary norNone, or if the implementation rejects the resolved client search scope. OracleAgentMemory client searches reject omitted user scope and rejectexact_user_match=False.
Notes
Explicit None scope values still follow the resolved exact-match
rules: exact_*_match=False leaves that dimension unconstrained,
while exact_*_match=True matches only records unscoped on that
dimension.
method update_image
Update a stored image record by identifier.
- Parameters:
- image_id
str– Identifier of the image record to update. - image
bytes– Optional replacement image bytes. Provide bytes to replace the stored image. When omitted, the stored image is preserved. - description
str | None– Optional replacement description. When omitted, the stored description is preserved. PassingNonegenerates a new description with the configured LLM. A non-null string replaces the stored description and searchable text directly. - mime_type
ImageMimeType– MIME type of the replacement image bytes.imageandmime_typemust be provided together. Omit both to preserve the stored image and MIME type. - metadata
dict[str, Any] | None– Optional replacement metadata mapping. When omitted, the stored metadata is preserved. When provided, it replaces the stored metadata object; this API does not deep-merge metadata. - timestamp
str | None– Optional new timestamp for this image. When omitted, the stored timestamp is preserved. PassNoneto clear it. - ttl_days
int | None– Optional expiration refresh in days. Omit this argument together withttl_anchorto leave the current expiration unchanged. PassNoneto clear expiration. Expiration for an image attached to a message must be changed through the parent message. - ttl_anchor
TimeToLiveAnchor– Optional time-to-live anchor for an expiration refresh. Providingttl_anchorwithoutttl_daysuses the schema default time-to-live duration. When omitted during a refresh, stores useTimeToLiveAnchor.CREATED_AT. - **kwargs (Any) – Unexpected keyword arguments are rejected by implementations.
- image_id
- Returns: Identifier of the updated image record.
- Return type: str
- Raises: ValueError – If expiration settings are supplied for an image attached to a message.
Notes
Omitted fields remain unchanged. Scope updates are not supported by this API. Metadata replacement is whole-object replacement, not recursive JSON merge.
method update_image_async (async)
Update one standalone image through the configured store.
Omit image to preserve the existing bytes. If image is
provided, mime_type must be provided with it. Omit description
to preserve the existing description. Pass None to generate a new
description with the configured LLM; a non-null description replaces
it directly. Metadata,
timestamp, and expiration settings are updated when supplied.
- Parameters:
- image_id
str– Identifier of the image to update. - image
bytes– Optional replacement raw image bytes. - description
str | None– Optional replacement description. Omit it to preserve the current description. PassNoneto generate a new description with the configured LLM. - mime_type
ImageMimeType– MIME type required when replacement image bytes are supplied. - metadata
dict[str, Any] | None– Optional replacement metadata. - timestamp
str | None– Optional replacement event timestamp. - ttl_days
int | None– Optional expiration settings. These cannot be changed through this method when the image is attached to a message. - ttl_anchor
TimeToLiveAnchor– Optional expiration settings. These cannot be changed through this method when the image is attached to a message. - kwargs
Any
- image_id
- Returns: The updated image identifier.
- Return type: str
- Raises: ValueError – If expiration settings are supplied for an image attached to a message.
method update_memory
Update a stored memory-like record by identifier.
- Parameters:
- memory_id
str– Identifier of the memory-like record to update. - content
str– Optional replacement content. Provide a string to replace the stored content. When omitted, the stored content is preserved. Omitcontentto keep the current value, or usedelete_memory()to remove the record. - metadata
dict[str, Any] | None– Optional replacement metadata mapping. When omitted, the stored metadata is preserved. When provided, it replaces the stored metadata object; this API does not deep-merge metadata. - timestamp
str | None– Optional new timestamp for this memory. It represents when the memory was created. When omitted, the stored timestamp is preserved. PassNoneto clear the saved timestamp and use the time the record was created in the store. Whenttl_anchorisTimeToLiveAnchor.TIMESTAMP, ISO-8601 timestamps without a timezone are treated as UTC. - ttl_days
int | None– Optional expiration refresh in days. Omit this argument to leave the current expiration unchanged unlessttl_anchoris provided. PassNoneto useMemoryRetentionConfig.max_ttl_dayswhen the retention configuration sets one, or to clear expiration when it does not. Values aboveMemoryRetentionConfig.max_ttl_daysare clamped to that maximum with a warning. Expired memories are unavailable to this client API and cannot be refreshed. - ttl_anchor
TimeToLiveAnchor– Optional time-to-live anchor for an expiration refresh. UseTimeToLiveAnchor.CREATED_ATfor the memory creation time orTimeToLiveAnchor.TIMESTAMPfor the replacementtimestampsupplied in the same update, or the stored event timestamp whentimestampis omitted. Providingttl_anchorwithoutttl_daysuses the schema default time-to-live duration. Whenttl_anchoris omitted during a refresh, the client usesTimeToLiveAnchor.CREATED_AT. ISO-8601 timestamps without a timezone are treated as UTC. - status
RecordStatus– Optional replacement lifecycle status for this memory-like record. Omit it to preserve the current status. - **kwargs (Any) – Unexpected keyword arguments are rejected.
- memory_id
- Returns: Identifier of the updated memory-like record.
- Return type: str
Notes
Omitted fields are preserved from the stored record. Stored scope remains unchanged. Metadata replacement is whole-object replacement, not recursive JSON merge.
method update_memory_async (async)
Update a stored memory-like record by identifier asynchronously.
- Parameters:
- memory_id
str– Identifier of the memory-like record to update. - content
str– Optional replacement content. Provide a string to replace the stored content. When omitted, the stored content is preserved. Omitcontentto keep the current value, or usedelete_memory()to remove the record. - metadata
dict[str, Any] | None– Optional replacement metadata mapping. When omitted, the stored metadata is preserved. When provided, it replaces the stored metadata object; this API does not deep-merge metadata. - timestamp
str | None– Optional new timestamp for this memory. It represents when the memory was created. When omitted, the stored timestamp is preserved. PassNoneto clear the saved timestamp and use the time the record was created in the store. Whenttl_anchorisTimeToLiveAnchor.TIMESTAMP, ISO-8601 timestamps without a timezone are treated as UTC. - ttl_days
int | None– Optional expiration refresh in days. Omit this argument to leave the current expiration unchanged unlessttl_anchoris provided. PassNoneto useMemoryRetentionConfig.max_ttl_dayswhen the retention configuration sets one, or to clear expiration when it does not. Values aboveMemoryRetentionConfig.max_ttl_daysare clamped to that maximum with a warning. Expired memories are unavailable to this client API and cannot be refreshed. - ttl_anchor
TimeToLiveAnchor– Optional time-to-live anchor for an expiration refresh. UseTimeToLiveAnchor.CREATED_ATfor the memory creation time orTimeToLiveAnchor.TIMESTAMPfor the replacementtimestampsupplied in the same update, or the stored event timestamp whentimestampis omitted. Providingttl_anchorwithoutttl_daysuses the schema default time-to-live duration. Whenttl_anchoris omitted during a refresh, the client usesTimeToLiveAnchor.CREATED_AT. ISO-8601 timestamps without a timezone are treated as UTC. - status
RecordStatus– Optional replacement lifecycle status for this memory-like record. Omit it to preserve the current status. - **kwargs (Any) – Unexpected keyword arguments are rejected.
- memory_id
- Returns: Identifier of the updated memory-like record.
- Return type: str
Notes
Omitted fields are preserved from the stored record. Stored scope remains unchanged. Metadata replacement is whole-object replacement, not recursive JSON merge.
Examples
import asyncio
memory_id = asyncio.run(client.add_memory_async("Original memory"))
(
asyncio.run(client.update_memory_async(
memory_id, content="Updated memory"
))
== memory_id
)
True
method update_record_link
Update mutable fields of one stored relation.
Omitted values are preserved. When relation_type changes to a
built-in memory relation type, its fixed reverse label replaces
opposite_relation_type. Pass None for timestamp or
metadata to clear that value.
- Parameters:
- relation_id
str– Identifier of the relation to update. - relation_type
str– Optional replacement source-to-target label. - opposite_relation_type
str– Optional replacement reverse-traversal label. Omit it to preserve the stored label. - timestamp
str | None– Optional replacement timestamp. PassNoneto clear it. - metadata
dict[str, Any] | None– Optional replacement metadata. It replaces the stored object.
- relation_id
- Returns:
Number of updated relations, either
0or1. - Return type: int
Examples
client.update_record_link("relation-id", relation_type="supports")
1
method update_record_link_async (async)
Asynchronously update one stored relation.
- Parameters:
- relation_id
str - relation_type
str - opposite_relation_type
str - timestamp
str | None - metadata
dict[str, Any] | None
- relation_id
- Return type: int
method update_thread
Persist thread metadata and durable runtime configuration updates.
- Parameters:
- thread_id
str– Identifier of the thread to update. - metadata
dict[str, Any] | None– Optional metadata update for the conversation thread. When omitted, the stored metadata is left unchanged. PassingNoneexplicitly clears stored metadata. When a mapping is provided, it replaces the stored metadata object. - llm
ILlm– Optional LLM override for the returnedOracleThreadinstance. This is not persisted, but it participates in the same validation rules asget_threadandcreate_thread. -
extract_memories
bool–Optional durable override for automatic memory extraction.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. - max_message_token_length
int– Optional durable override for the maximum prompt-time message size used during extraction and summarization. - message_shortening_input_token_limit
int– Optional durable override for the maximum excerpt size sent to the LLM when shortening oversized messages. -
memory_extraction_window
int–Optional durable override for the extraction window size.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
context_summary_update_frequency
int–Optional durable override for messages after the latest valid summary before automatic refresh.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_frequency
int–Optional durable override for how many appended messages trigger automatic memory extraction.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_token_limit
int–Optional durable override for extraction and running-summary prompt budgets.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. - context_card_token_limit
int– Optional durable override for the input token budget of the LLM prompt used to build the summary and topic list included in the context card. -
enable_context_summary
bool–Optional durable override for whether running context summaries stay enabled.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_custom_instructions
str | None–Optional durable custom instructions appended to the memory extraction system prompt. Passing
Noneclears any stored thread-level custom instructions; a client-level default still applies when configured.Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. -
memory_extraction_inherit_message_metadata
bool | Sequence[str]–Optional durable override for metadata copied from source messages onto automatically extracted memories.
Deprecated
Deprecated since version 26.6.0: This parameter was deprecated in 26.6.0 and will be removed in 27.1. Please use
memory_extraction_configinstead. - memory_extraction_config
MemoryExtractionConfig– Optional grouped durable extraction config update. Provided fields are written to the stored thread config and used by later loadedOracleThreadinstances and later background extraction jobs. Omitted fields retain their saved values when present. Threads created before image-context settings were persisted fall back to the client value, thenDISABLED, when no saved image context exists. - image_input_limit_config
ImageInputLimitConfig– Optional durable raw-image and LLM image-request limit update. Omitted fields retain the stored values; provided fields are used by subsequently loaded thread instances. - search_config
MemorySearchConfig– Optional search configuration to store for the thread. The supplied configuration is used by subsequent loaded thread instances. - **kwargs (Any) – Additional implementation-specific options.
OracleAgentMemorycurrently rejects unknown keyword arguments.
- thread_id
- Returns:
Updated
OracleThreadinstance reflecting the persisted metadata and runtime configuration. - Return type: OracleThread
- Raises:
- KeyError – If the thread id is unknown to this client instance.
- ValueError – If no LLM is available for automatic memory extraction after resolving the effective runtime configuration.
Notes
Runtime configuration is resolved from the stored conversation thread plus the
explicit overrides passed to this call, matching get_thread
semantics before persisting the result. Omitted metadata and runtime
config updates are resolved from stored data, not from any
previously loaded OracleThread instance, and only explicitly provided metadata
updates or durable runtime-config overrides are written back.
Metadata replacement is whole-object replacement, not recursive JSON
merge. Thread ownership is not mutable through this API, so
user_id and agent_id remain unchanged. Mutable runtime state,
such as extraction counters, is left untouched.
Examples
from oracleagentmemory.core import OracleAgentMemory
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
llm=llm,
)
updated = client.update_thread(
"c1",
metadata={"flags": {"vip": True}},
message_shortening_input_token_limit=12_000,
)
updated.message_shortening_input_token_limit
12000
method update_thread_async (async)
Persist updated thread metadata and durable runtime configuration asynchronously.
- Parameters:
- thread_id
str– Identifier of the thread to update. - metadata
dict[str, Any] | None– Optional metadata update for the conversation thread. When omitted, the stored metadata is left unchanged. PassingNoneexplicitly clears stored metadata. When a mapping is provided, it replaces the stored metadata object. - **kwargs (Any) – Additional durable runtime-configuration updates and per-call
overrides accepted by
update_thread().
- thread_id
- Returns:
Updated
OracleThreadinstance reflecting the persisted metadata and runtime configuration. - Return type: OracleThread
method wait_for_memory_extraction
Wait for earlier background memory extraction started by this client.
This method waits for background extraction already started through
this OracleAgentMemory instance, across all threads owned by this
agent memory component. It does not wait for extraction started after
this wait begins, for extraction started by another agent memory
component, or for extraction running in another process. Extraction
failures count as finished for this wait.
- Parameters:
timeout
float | None– Optional maximum number of seconds to wait. Defaults to300. PassNoneto wait until this agent memory component has no pending extraction. - Raises: TimeoutError – Raised when the timeout expires before the earlier background extraction finishes.
- Return type: None
Examples
client = OracleAgentMemory(
connection=db_pool,
embedder=embedder,
memory_extraction_config=MemoryExtractionConfig(extract_memories=False),
)
client.wait_for_memory_extraction(timeout=10)
method wait_for_memory_extraction_async (async)
Asynchronously wait for earlier background memory extraction.
This method follows the same behavior as
wait_for_memory_extraction().
- Parameters:
timeout
float | None– Optional maximum number of seconds to wait. Defaults to300. PassNoneto wait indefinitely. - Raises: TimeoutError – Raised when the timeout expires before the earlier background extraction finishes.
- Return type: None
Examples
import asyncio
asyncio.run(client.wait_for_memory_extraction_async(timeout=10))
Image Input Limits
class oracleagentmemory.core.ImageInputLimitConfig
Bases: object
Configure raw image and LLM image-request limits.
Omitted fields inherit from the next broader configuration scope. Client fields inherit SDK defaults, while per-thread fields inherit the client configuration. Validation cannot be disabled, and resolved values cannot exceed the SDK’s absolute maxima.
- Parameters:
- max_raw_image_bytes
int– Maximum raw byte length of one image. The SDK default is 10 MiB and the absolute maximum is 32 MiB. - max_images_per_llm_request
int– Maximum number of images in one LLM request. The SDK default is 100 and the absolute maximum is 512. - max_total_raw_image_bytes_per_llm_request
int– Maximum combined raw byte length of images in one LLM request. Text, metadata, JSON framing, and base64 expansion are excluded. The SDK default is 100 MiB and the absolute maximum is 256 MiB.
- max_raw_image_bytes
Examples
from oracleagentmemory.core import ImageInputLimitConfig
config = ImageInputLimitConfig(
max_raw_image_bytes=16 * 1024 * 1024,
max_images_per_llm_request=200,
)
Memory Extraction
class oracleagentmemory.core.MemoryExtractionImageContext
Bases: str, Enum
Select how images participate in automatic memory extraction.
DISABLED omits images and image descriptions from extraction prompts. IMAGE sends original image parts. CAPTION sends image descriptions as text and requires every selected image to have a non-blank description.
CAPTION = ‘caption’
Include descriptions as text and require one for every selected image.
DISABLED = ‘disabled’
Do not include images or image descriptions in extraction prompts.
IMAGE = ‘image’
Include original image parts in extraction prompts.
MEMORY = ‘memory’
Image-specific memory extraction is not currently supported.
class oracleagentmemory.core.MemoryExtractionConfig
Bases: object
Grouped settings for automatic memory extraction.
Pass this object to OracleAgentMemory, create_thread,
get_thread, or update_thread to configure automatic extraction.
extraction_mode and the background queue settings also control
automatic image-description generation.
Each field is resolved independently. A value supplied for an operation
takes precedence, followed by a saved thread value, the client value, and
the SDK default. New and standalone threads have no saved thread value.
- Parameters:
- memory_extraction_window
int– Recent-message window used for extraction prompts.-1means the extraction prompt uses only the newly added messages. When omitted, use the resolution order above. - context_summary_update_frequency
int– Number of messages after the latest valid summary before automatically refreshing it. When memory extraction is enabled, the check happens after each due extraction, so refresh can occur later. Values less than or equal to0refresh at every check. When omitted, use the resolution order above. - memory_extraction_frequency
int– Number of appended messages between memory extraction runs. Values below0extract after every append. When omitted, use the resolution order above. - memory_extraction_token_limit
int– Input token budget for extraction and summary prompts. Values below1disable the prompt budget limit. When omitted, use the resolution order above. - extract_memories
bool– Whether automatic memory extraction is enabled. Set toFalseto disable automatic extraction and allow operation without an extraction LLM. When omitted, use the resolution order above. - enable_context_summary
bool– Whether extraction prompts maintain and use a running context summary. When omitted, use the resolution order above. - memory_extraction_custom_instructions
str | None– Optional caller instructions appended to the extraction system prompt. PassNoneonupdate_threadto clear stored thread-level instructions. When omitted, use the resolution order above. - memory_link_extraction_custom_instructions
str | None– Optional caller instructions appended to the automatic link-resolution system prompt. PassNoneonupdate_threadto clear stored thread-level instructions. When omitted, use the resolution order above. This setting is ignored whenmemory_link_extraction_modeisMemoryLinkExtractionMode.DISABLED. - memory_extraction_image_context
oracleagentmemory.core.extractors.memoryextractionconfig.MemoryExtractionImageContext– Select the image representation used during extraction.DISABLEDomits images and image descriptions from prompts,IMAGEsends raw image parts, andCAPTIONsends image descriptions as text and requires every selected image to have a non-blank description.MEMORYis not currently supported. When omitted, use the saved thread value, then the client value, thenDISABLED. Omitting this field never enables image processing. - memory_extraction_inherit_message_metadata
bool | collections.abc.Sequence[str]– Controls metadata copied from source messages onto extracted memories.Truecopies all source-message metadata,Falsecopies none, and a sequence copies only matching top-level metadata keys. When omitted, use the resolution order above. - extraction_mode
oracleagentmemory.core.extractors.memoryextractionconfig.MemoryExtractionMode– Controls when automatic memory extraction and image-description generation run.MemoryExtractionMode.INLINEcompletes them before the write method returns.MemoryExtractionMode.BACKGROUNDreturns after the raw write succeeds and attempts to queue the derived work. In background mode, generated descriptions and derived memories may appear later or may never be written if the work cannot complete. For example,update_message()can return before a later memory read reflects the updated message content. When omitted, use the resolution order above. The SDK default isBACKGROUND. Settingextract_memories=Falsedisables memory extraction but does not disable image-description generation. - memory_link_extraction_mode
oracleagentmemory.core.extractors.memoryextractionconfig.MemoryLinkExtractionMode– How links to existing memories are resolved for newly extracted memories.DURING_EXTRACTIONincludes bounded candidates in the extraction request.POST_EXTRACTIONuses one additional link-resolution request for the extraction batch.DISABLEDcreates no automatic links. When omitted, use the resolution order above. The SDK default isPOST_EXTRACTION. - memory_link_extraction_token_limit
int– Total input token budget for all post-extraction link-resolution requests in one extraction pass. Values below1disable its prompt budget. This setting is ignored whenmemory_link_extraction_modeisDURING_EXTRACTIONorDISABLED. Calls toadd_memory(autonomous_linking=True)use the same post-store resolver and budget independently of extraction mode. When omitted, use the resolution order above. - background_extraction_queue_full_behavior
oracleagentmemory.core.extractors.memoryextractionconfig.BackgroundExtractionQueueFullBehavior– In background mode, controls what happens when automatic extraction or image-description generation cannot queue immediately.DROPlogs a warning and continues without waiting.WAIT_THEN_DROPwaits for queue capacity up to the configured timeout, then logs a warning and continues.WAIT_THEN_RAISEwaits for queue capacity up to the configured timeout, then raisesTimeoutErrorafter the raw write succeeds. When omitted, use the resolution order above. The SDK default isDROP. - background_extraction_queue_put_timeout_seconds
float– In background mode, maximum number of seconds automatic extraction or image-description generation waits for queue capacity whenbackground_extraction_queue_full_behaviorisWAIT_THEN_DROPorWAIT_THEN_RAISE. When omitted, use the resolution order above. The SDK default is300.0seconds.
- memory_extraction_window
Examples
from oracleagentmemory.core import (
MemoryExtractionImageContext,
MemoryExtractionConfig,
MemoryExtractionMode,
MemoryLinkExtractionMode,
)
config = MemoryExtractionConfig(
extract_memories=True,
memory_extraction_image_context=MemoryExtractionImageContext.CAPTION,
extraction_mode=MemoryExtractionMode.BACKGROUND,
memory_link_extraction_mode=MemoryLinkExtractionMode.POST_EXTRACTION,
memory_link_extraction_token_limit=8_000,
)
What to do when extraction or image descriptions cannot queue immediately.
Omitted values resolve to DROP.
Maximum seconds background work waits for queue capacity in wait modes.
Omitted values resolve to 300.0 seconds.
Messages after the latest valid summary before automatic refresh.
Values less than or equal to 0 refresh at every check.
Whether OAM maintains context summaries for thread reads and extraction prompts.
Whether extraction and image descriptions run inline or in background work.
Omitted values resolve to BACKGROUND.
Messages between extraction runs; values below 0 extract after every append.
Image representation; omission resolves to thread, client, then DISABLED.
Source-message metadata copied onto extracted memories.
Input token budget for prompts; values below 1 disable the limit.
Recent-message window used for extraction prompts; -1 uses only new messages.
Optional caller instructions appended to automatic link-resolution prompts.
How automatic links are resolved for extracted memories.
Omitted values resolve to POST_EXTRACTION.
Total input token budget for POST_EXTRACTION link resolution.
Values below 1 disable the limit.
class oracleagentmemory.core.MemoryExtractionMode
Bases: str, Enum
Controls when automatic extraction and image descriptions run.
INLINE completes derived work before the write method returns.
BACKGROUND returns after the raw write succeeds and attempts to queue
that work. Background work is best effort: generated descriptions and
derived memories may appear later or may never be written if it cannot
complete.
BACKGROUND = ‘BACKGROUND’
Return after the raw write and run derived work in the background.
INLINE = ‘INLINE’
Complete extraction and image descriptions before the write returns.
class oracleagentmemory.core.BackgroundExtractionQueueFullBehavior
Bases: str, Enum
Controls what happens when configured background work cannot queue in time.
Despite the extraction-specific name, this setting also applies to automatic image-description generation in background mode.
DROP = ‘DROP’
Log a warning and continue immediately when queue capacity is unavailable.
WAIT_THEN_DROP = ‘WAIT_THEN_DROP’
Wait for queue capacity up to the configured timeout, then log a warning and continue.
WAIT_THEN_RAISE = ‘WAIT_THEN_RAISE’
Wait for queue capacity up to the configured timeout, then raise TimeoutError.