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.
| Field | Parameter name | Default | Notes |
|---|---|---|---|
| Max Memory Size | max_memory_size | 1028 words | Maximum accepted value is 4096. Falls back to 1028 if missing, invalid, or less than 1 |
| Memory Manager Model | memory_manager_model | GPT-5 Mini (6895d6d1d50c89537c1cf237) | Accepts a model asset ID or name. Used when summarizing or optimizing stored content |
| Size Management Policy | size_management_policy | forget | forget drops the oldest lines to fit under the limit. summarize compresses older content while preserving context |
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)
Available Actions
| Action | Description |
|---|---|
insert | Append new content to the memory buffer |
get | Retrieve the current stored memory |
optimize | Compress 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)
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)
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 limitsummarize— 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)
Use with an Agent
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)
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()
Related Documentation
- Tools & Integrations Overview — Learn about all tool types available in aiXplain
- Commercial Integrations — Connect to 230+ external systems via Composio
- aiXplain Marketplace — Browse and discover assets in the Studio UI