Skip to main content
Version: v2.0

Shared Memory

Shared Memory is an aiXplain-managed integration that gives agents a persistent memory buffer that survives across runs and sessions. Unlike context passed in a single prompt, memory stored here is durable — it can be written once and read by any agent or workflow that has access to the tool.

View the asset on the aiXplain Marketplace.


Setup

from aixplain import Aixplain

aix = Aixplain(api_key="<AIXPLAIN_API_KEY>")

Configuration

These are the fields exposed in the Studio connect dialog, along with the backend behavior they map to.

FieldParameter nameDefaultNotes
Max Memory Sizemax_memory_size1028 wordsMaximum accepted value is 4096. Falls back to 1028 if missing, invalid, or less than 1
Memory Manager Modelmemory_manager_modelGPT-5 Mini (6895d6d1d50c89537c1cf237)Accepts a model asset ID or name. Used when summarizing or optimizing stored content
Size Management Policysize_management_policyforgetforget drops the oldest lines to fit under the limit. summarize compresses older content while preserving context
note

Shared Memory does not require a third-party OAuth token or API key to connect. Connecting it creates a private aiXplain-managed tool asset in your workspace.

The identifier field is a runtime-only field not shown in the connect dialog. It is passed during insert, get, and optimize calls to keep separate memory buffers per end user. See Per-user memory below.


Create a Shared Memory tool

SHARED_MEMORY_INTEGRATION = "aixplain/shared-memory/aixplain"
DEFAULT_MEMORY_MANAGER_MODEL_ID = "6895d6d1d50c89537c1cf237" # GPT-5 Mini

shared_memory = aix.Tool(
integration=SHARED_MEMORY_INTEGRATION,
name="Shared Memory Demo",
description="Persistent memory for an account support workflow",
config={
"max_memory_size": 256,
"memory_manager_model": DEFAULT_MEMORY_MANAGER_MODEL_ID,
"size_management_policy": "summarize",
},
allowed_actions=["insert", "get", "optimize"],
)
shared_memory.save()

print("Tool ID:", shared_memory.id)
Show output

Available Actions

ActionDescription
insertAppend new content to the memory buffer
getRetrieve the current stored memory
optimizeCompress and clean up the stored memory

Inspect action inputs

for action in shared_memory.list_inputs("insert", "get", "optimize"):
print(action.name)
for input_param in action.inputs or []:
print(" -", input_param.code or input_param.name, "required=", input_param.required)
Show output

Quick Run

Write facts into memory and read them back.

shared_memory.run(
action="insert",
data={"content": "Customer: ACME Corp prefers weekly status updates every Monday."},
)
shared_memory.run(
action="insert",
data={"content": "Customer: ACME Corp uses Jira Cloud and Google Workspace."},
)

memory_result = shared_memory.run(action="get", data={})
print(memory_result.data)
Show output

Size Management

When memory grows past max_memory_size, Shared Memory applies the configured policy:

  • forget — drops the oldest lines until the buffer fits under the limit
  • summarize — sends current content to the configured memory manager model to compress it while preserving context

When size_management_policy is summarize, the same model is also used when calling the optimize action.


Per-User Memory

Pass an identifier to keep separate memory buffers per end user. This is useful when one workflow serves multiple users and each should have isolated context.

user_id = "customer-123"

shared_memory.run(
action="insert",
data={
"identifier": user_id,
"content": "Customer 123 prefers concise answers and CSV exports.",
},
)

user_memory = shared_memory.run(
action="get",
data={"identifier": user_id},
)
print(user_memory.data)
Show output

Use with an Agent

note

When attaching Shared Memory to an agent, set allowed_actions to include ["insert"] or omit it entirely.

shared_memory = aix.Tool(
integration=SHARED_MEMORY_INTEGRATION,
name="Shared Memory Agent Demo",
description="Persistent memory for an account support workflow",
config={
"max_memory_size": 256,
"memory_manager_model": DEFAULT_MEMORY_MANAGER_MODEL_ID,
"size_management_policy": "summarize",
},
allowed_actions=["insert"],
)
shared_memory.save()

agent = aix.Agent(
name="Shared Memory Agent",
description="Answers with account context from shared memory",
instructions=(
"Refer to the account context already available in your system prompt. "
"Do not invent customer preferences that are not present in memory."
),
tools=[shared_memory],
)
agent.save()

response = agent.run(
query="What communication pattern should we use for ACME Corp and which systems do they already use?"
)
print(response.data.output)
Show output

Example Use Cases

  • Customer support — remember account preferences, open issues, and prior resolutions across runs
  • Sales engineering — keep durable account context that multiple agents can reuse during qualification and follow-up
  • Internal operations — share decisions, constraints, and important facts across agents in a shared workflow

Cleanup

shared_memory.delete()
agent.delete()