supermemory-agent-framework 2.0.0__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: supermemory-agent-framework
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: Memory tools and middleware for Microsoft Agent Framework with supermemory
5
5
  Project-URL: Homepage, https://supermemory.ai
6
6
  Project-URL: Repository, https://github.com/supermemoryai/supermemory
@@ -32,20 +32,20 @@ This package provides both **automatic memory injection middleware** and **manua
32
32
 
33
33
  ## Installation
34
34
 
35
- Adapter version `>=2.0.0,<3` supports the Supermemory Python SDK `>=5.0.0,<6`.
35
+ Adapter version `>=2.1.0,<3` supports the Supermemory Python SDK `>=5.0.0,<6`.
36
36
 
37
37
  The OpenAI client is a separate Agent Framework package. Include `agent-framework-openai` when using the OpenAI examples below, which target its current `OpenAIChatClient` Responses API client. The adapter also supports older framework cores, but their OpenAI client names and model arguments can differ.
38
38
 
39
39
  Install using uv (recommended):
40
40
 
41
41
  ```bash
42
- uv add "supermemory-agent-framework>=2.0.0,<3" agent-framework-openai
42
+ uv add "supermemory-agent-framework>=2.1.0,<3" agent-framework-openai
43
43
  ```
44
44
 
45
45
  Or with pip:
46
46
 
47
47
  ```bash
48
- pip install "supermemory-agent-framework>=2.0.0,<3" agent-framework-openai
48
+ pip install "supermemory-agent-framework>=2.1.0,<3" agent-framework-openai
49
49
  ```
50
50
 
51
51
  ## Quick Start
@@ -66,7 +66,7 @@ from supermemory_agent_framework import (
66
66
  async def main():
67
67
  connection = AgentSupermemory(
68
68
  api_key="your-supermemory-api-key",
69
- container_tag="user-123",
69
+ namespace="user-123",
70
70
  )
71
71
 
72
72
  middleware = SupermemoryChatMiddleware(
@@ -108,7 +108,7 @@ from supermemory_agent_framework import AgentSupermemory, SupermemoryContextProv
108
108
  async def main():
109
109
  connection = AgentSupermemory(
110
110
  api_key="your-supermemory-api-key",
111
- container_tag="user-123",
111
+ namespace="user-123",
112
112
  )
113
113
 
114
114
  provider = SupermemoryContextProvider(
@@ -147,7 +147,7 @@ from supermemory_agent_framework import AgentSupermemory, SupermemoryTools
147
147
  async def main():
148
148
  connection = AgentSupermemory(
149
149
  api_key="your-supermemory-api-key",
150
- container_tag="user-123",
150
+ namespace="user-123",
151
151
  )
152
152
  tools = SupermemoryTools(connection)
153
153
 
@@ -185,7 +185,7 @@ async def main():
185
185
  api_key = "your-supermemory-api-key"
186
186
  connection = AgentSupermemory(
187
187
  api_key=api_key,
188
- container_tag="user-123",
188
+ namespace="user-123",
189
189
  )
190
190
 
191
191
  middleware = SupermemoryChatMiddleware(
@@ -252,7 +252,7 @@ SupermemoryMiddlewareOptions(add_memory="never")
252
252
  ```python
253
253
  connection = AgentSupermemory(
254
254
  api_key="your-supermemory-api-key",
255
- container_tag="user-123", # Memory scope
255
+ namespace="user-123", # Memory scope
256
256
  conversation_id="chat-session-456", # Groups stored conversations
257
257
  entity_context="User is on the pro plan", # Optional fixed context
258
258
  )
@@ -276,7 +276,7 @@ Memory tools that integrate with Agent Framework's tool system.
276
276
  ```python
277
277
  connection = AgentSupermemory(
278
278
  api_key="your-api-key",
279
- container_tag="user-123",
279
+ namespace="user-123",
280
280
  )
281
281
  tools = SupermemoryTools(connection)
282
282
 
@@ -296,12 +296,12 @@ source documents, and the argument is not exposed to the model.
296
296
 
297
297
  ### V5 compatibility
298
298
 
299
- - Keep passing `container_tag` and `conversation_id`. The adapter passes the container tag as the v5 namespace and uses the unchanged `conversation_<conversation_id>` value as the document `id`. Choose a separate container tag for each tenant; the default `msft_agent_chat` is shared, not tenant-specific.
299
+ - Pass `namespace` and `conversation_id`. The adapter calls the v5 `/ns/{namespace}/...` routes and uses the unchanged `conversation_<conversation_id>` value as the document `id`. Choose a separate namespace for each tenant; the default `msft_agent_chat` is shared, not tenant-specific. `container_tag` still works but is deprecated; it is the same string, so existing memories stay visible.
300
300
  - All writes still use add/append, including tool writes and automatic conversation storage. Reusing a conversation ID adds or diffs new content into its document; it does not replace earlier turns. No document update or replacement operation is used.
301
301
  - `entity_context` remains display context prepended to retrieved memories; this migration does not start sending it as ingestion `supporting_context`.
302
302
  - Profile mode makes one profile request, query mode makes one search request, and full mode makes both when there is a user query. V5 profiles no longer accept a query. Profile-associated search keeps the legacy memory-only mode and `0.6` threshold rather than adopting v5's broader defaults; the explicit search tool keeps its hybrid mode and `0.6` threshold. Provider and middleware context still contains fact text rather than `{id, memory}` objects and deduplicates facts across profile/search results.
303
303
  - Tool JSON envelopes remain unchanged: search returns `success`, `results`, and `count`; add returns `success` and `memory`; profile returns `success`, `profile`, and `search_results`. Profile static/dynamic/bucket values remain strings. Profile search results retain `results`, `timing`, and `total` (the number returned). Search results retain a top-level `updated_at` mapped from v5 `system.updated_at`, along with v5 fields. Legacy optional fields that v5 does not return, such as version numbers and file paths, remain present as `null`; their values cannot be reconstructed.
304
- - The provider has no adapter-owned persisted state schema and leaves its scoped session state unchanged. Existing framework session exports remain loadable; keep using the same container tag and conversation ID when reconstructing the connection. The API client's credentials are not serialized into session state.
304
+ - The provider has no adapter-owned persisted state schema and leaves its scoped session state unchanged. Existing framework session exports remain loadable; keep using the same namespace and conversation ID when reconstructing the connection. The API client's credentials are not serialized into session state.
305
305
 
306
306
  This maps requests but does not move server-side data. If existing v3/v4 data has not been migrated into the corresponding v5 namespace, follow the [v5 migration guide](https://supermemory.ai/docs/migration/api-v5) before relying on historical recall. The adapter does not delete or rewrite the old data.
307
307
 
@@ -344,7 +344,7 @@ from supermemory_agent_framework import (
344
344
  )
345
345
 
346
346
  try:
347
- connection = AgentSupermemory(container_tag="user-123")
347
+ connection = AgentSupermemory(namespace="user-123")
348
348
  except SupermemoryConfigurationError as e:
349
349
  print(f"Configuration issue: {e}")
350
350
  ```
@@ -6,20 +6,20 @@ This package provides both **automatic memory injection middleware** and **manua
6
6
 
7
7
  ## Installation
8
8
 
9
- Adapter version `>=2.0.0,<3` supports the Supermemory Python SDK `>=5.0.0,<6`.
9
+ Adapter version `>=2.1.0,<3` supports the Supermemory Python SDK `>=5.0.0,<6`.
10
10
 
11
11
  The OpenAI client is a separate Agent Framework package. Include `agent-framework-openai` when using the OpenAI examples below, which target its current `OpenAIChatClient` Responses API client. The adapter also supports older framework cores, but their OpenAI client names and model arguments can differ.
12
12
 
13
13
  Install using uv (recommended):
14
14
 
15
15
  ```bash
16
- uv add "supermemory-agent-framework>=2.0.0,<3" agent-framework-openai
16
+ uv add "supermemory-agent-framework>=2.1.0,<3" agent-framework-openai
17
17
  ```
18
18
 
19
19
  Or with pip:
20
20
 
21
21
  ```bash
22
- pip install "supermemory-agent-framework>=2.0.0,<3" agent-framework-openai
22
+ pip install "supermemory-agent-framework>=2.1.0,<3" agent-framework-openai
23
23
  ```
24
24
 
25
25
  ## Quick Start
@@ -40,7 +40,7 @@ from supermemory_agent_framework import (
40
40
  async def main():
41
41
  connection = AgentSupermemory(
42
42
  api_key="your-supermemory-api-key",
43
- container_tag="user-123",
43
+ namespace="user-123",
44
44
  )
45
45
 
46
46
  middleware = SupermemoryChatMiddleware(
@@ -82,7 +82,7 @@ from supermemory_agent_framework import AgentSupermemory, SupermemoryContextProv
82
82
  async def main():
83
83
  connection = AgentSupermemory(
84
84
  api_key="your-supermemory-api-key",
85
- container_tag="user-123",
85
+ namespace="user-123",
86
86
  )
87
87
 
88
88
  provider = SupermemoryContextProvider(
@@ -121,7 +121,7 @@ from supermemory_agent_framework import AgentSupermemory, SupermemoryTools
121
121
  async def main():
122
122
  connection = AgentSupermemory(
123
123
  api_key="your-supermemory-api-key",
124
- container_tag="user-123",
124
+ namespace="user-123",
125
125
  )
126
126
  tools = SupermemoryTools(connection)
127
127
 
@@ -159,7 +159,7 @@ async def main():
159
159
  api_key = "your-supermemory-api-key"
160
160
  connection = AgentSupermemory(
161
161
  api_key=api_key,
162
- container_tag="user-123",
162
+ namespace="user-123",
163
163
  )
164
164
 
165
165
  middleware = SupermemoryChatMiddleware(
@@ -226,7 +226,7 @@ SupermemoryMiddlewareOptions(add_memory="never")
226
226
  ```python
227
227
  connection = AgentSupermemory(
228
228
  api_key="your-supermemory-api-key",
229
- container_tag="user-123", # Memory scope
229
+ namespace="user-123", # Memory scope
230
230
  conversation_id="chat-session-456", # Groups stored conversations
231
231
  entity_context="User is on the pro plan", # Optional fixed context
232
232
  )
@@ -250,7 +250,7 @@ Memory tools that integrate with Agent Framework's tool system.
250
250
  ```python
251
251
  connection = AgentSupermemory(
252
252
  api_key="your-api-key",
253
- container_tag="user-123",
253
+ namespace="user-123",
254
254
  )
255
255
  tools = SupermemoryTools(connection)
256
256
 
@@ -270,12 +270,12 @@ source documents, and the argument is not exposed to the model.
270
270
 
271
271
  ### V5 compatibility
272
272
 
273
- - Keep passing `container_tag` and `conversation_id`. The adapter passes the container tag as the v5 namespace and uses the unchanged `conversation_<conversation_id>` value as the document `id`. Choose a separate container tag for each tenant; the default `msft_agent_chat` is shared, not tenant-specific.
273
+ - Pass `namespace` and `conversation_id`. The adapter calls the v5 `/ns/{namespace}/...` routes and uses the unchanged `conversation_<conversation_id>` value as the document `id`. Choose a separate namespace for each tenant; the default `msft_agent_chat` is shared, not tenant-specific. `container_tag` still works but is deprecated; it is the same string, so existing memories stay visible.
274
274
  - All writes still use add/append, including tool writes and automatic conversation storage. Reusing a conversation ID adds or diffs new content into its document; it does not replace earlier turns. No document update or replacement operation is used.
275
275
  - `entity_context` remains display context prepended to retrieved memories; this migration does not start sending it as ingestion `supporting_context`.
276
276
  - Profile mode makes one profile request, query mode makes one search request, and full mode makes both when there is a user query. V5 profiles no longer accept a query. Profile-associated search keeps the legacy memory-only mode and `0.6` threshold rather than adopting v5's broader defaults; the explicit search tool keeps its hybrid mode and `0.6` threshold. Provider and middleware context still contains fact text rather than `{id, memory}` objects and deduplicates facts across profile/search results.
277
277
  - Tool JSON envelopes remain unchanged: search returns `success`, `results`, and `count`; add returns `success` and `memory`; profile returns `success`, `profile`, and `search_results`. Profile static/dynamic/bucket values remain strings. Profile search results retain `results`, `timing`, and `total` (the number returned). Search results retain a top-level `updated_at` mapped from v5 `system.updated_at`, along with v5 fields. Legacy optional fields that v5 does not return, such as version numbers and file paths, remain present as `null`; their values cannot be reconstructed.
278
- - The provider has no adapter-owned persisted state schema and leaves its scoped session state unchanged. Existing framework session exports remain loadable; keep using the same container tag and conversation ID when reconstructing the connection. The API client's credentials are not serialized into session state.
278
+ - The provider has no adapter-owned persisted state schema and leaves its scoped session state unchanged. Existing framework session exports remain loadable; keep using the same namespace and conversation ID when reconstructing the connection. The API client's credentials are not serialized into session state.
279
279
 
280
280
  This maps requests but does not move server-side data. If existing v3/v4 data has not been migrated into the corresponding v5 namespace, follow the [v5 migration guide](https://supermemory.ai/docs/migration/api-v5) before relying on historical recall. The adapter does not delete or rewrite the old data.
281
281
 
@@ -318,7 +318,7 @@ from supermemory_agent_framework import (
318
318
  )
319
319
 
320
320
  try:
321
- connection = AgentSupermemory(container_tag="user-123")
321
+ connection = AgentSupermemory(namespace="user-123")
322
322
  except SupermemoryConfigurationError as e:
323
323
  print(f"Configuration issue: {e}")
324
324
  ```
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "supermemory-agent-framework"
7
- version = "2.0.0"
7
+ version = "2.1.0"
8
8
  description = "Memory tools and middleware for Microsoft Agent Framework with supermemory"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -1,23 +1,37 @@
1
1
  """Shared connection class for Supermemory Agent Framework integrations.
2
2
 
3
- Provides a single connection object that holds the SDK client, container tag,
3
+ Provides a single connection object that holds the SDK client, namespace,
4
4
  conversation ID, and entity context — shared across middleware, tools, and
5
5
  context providers.
6
6
  """
7
7
 
8
8
  import os
9
9
  import uuid
10
+ import warnings
10
11
  from typing import Optional
11
12
 
12
13
  import supermemory
13
14
 
14
15
  from .exceptions import SupermemoryConfigurationError
15
16
 
17
+ _container_tag_warned = False
18
+
19
+
20
+ def _warn_container_tag() -> None:
21
+ global _container_tag_warned
22
+ if not _container_tag_warned:
23
+ _container_tag_warned = True
24
+ warnings.warn(
25
+ "supermemory-agent-framework: container_tag is deprecated, use namespace",
26
+ DeprecationWarning,
27
+ stacklevel=3,
28
+ )
29
+
16
30
 
17
31
  class AgentSupermemory:
18
32
  """Shared Supermemory connection for middleware, tools, and context providers.
19
33
 
20
- Centralizes API client creation, container tag, conversation ID, and
34
+ Centralizes API client creation, namespace, conversation ID, and
21
35
  entity context so that all integration points share the same session.
22
36
 
23
37
  Example:
@@ -26,7 +40,7 @@ class AgentSupermemory:
26
40
 
27
41
  conn = AgentSupermemory(
28
42
  api_key="your-key",
29
- container_tag="user-123",
43
+ namespace="user-123",
30
44
  entity_context="The user is a Python developer who prefers async code.",
31
45
  )
32
46
  ```
@@ -35,18 +49,27 @@ class AgentSupermemory:
35
49
  def __init__(
36
50
  self,
37
51
  api_key: Optional[str] = None,
38
- container_tag: str = "msft_agent_chat",
52
+ namespace: Optional[str] = None,
39
53
  entity_context: Optional[str] = None,
40
54
  conversation_id: Optional[str] = None,
55
+ container_tag: Optional[str] = None,
41
56
  ) -> None:
42
57
  """Initialize the shared Supermemory connection.
43
58
 
44
59
  Args:
45
60
  api_key: Supermemory API key. Falls back to SUPERMEMORY_API_KEY env var.
46
- container_tag: Unique identifier for memory scope (e.g., user ID).
61
+ namespace: v5 namespace that scopes memories (e.g., user ID). Defaults to "msft_agent_chat".
47
62
  entity_context: Custom context about the user/entity to prepend to memories.
48
63
  conversation_id: Conversation ID for grouping messages. Auto-generated if None.
64
+ container_tag: Deprecated alias for namespace.
49
65
  """
66
+ if container_tag is not None:
67
+ _warn_container_tag()
68
+ if namespace is not None and namespace != container_tag:
69
+ raise SupermemoryConfigurationError(
70
+ "namespace and container_tag are both set and differ; pass only namespace."
71
+ )
72
+
50
73
  resolved_api_key = api_key or os.getenv("SUPERMEMORY_API_KEY")
51
74
  if not resolved_api_key:
52
75
  raise SupermemoryConfigurationError(
@@ -57,7 +80,18 @@ class AgentSupermemory:
57
80
  self.client: supermemory.AsyncSupermemory = supermemory.AsyncSupermemory(
58
81
  api_key=resolved_api_key
59
82
  )
60
- self.container_tag: str = container_tag
83
+ self.namespace: str = namespace or container_tag or "msft_agent_chat"
61
84
  self.conversation_id: str = conversation_id or str(uuid.uuid4())
62
85
  self.custom_id: str = f"conversation_{self.conversation_id}"
63
86
  self.entity_context: Optional[str] = entity_context
87
+
88
+ @property
89
+ def container_tag(self) -> str:
90
+ """Deprecated alias for namespace."""
91
+ _warn_container_tag()
92
+ return self.namespace
93
+
94
+ @container_tag.setter
95
+ def container_tag(self, value: str) -> None:
96
+ _warn_container_tag()
97
+ self.namespace = value
@@ -44,7 +44,7 @@ class SupermemoryContextProvider(BaseContextProvider):
44
44
  SupermemoryContextProvider,
45
45
  )
46
46
 
47
- conn = AgentSupermemory(api_key="your-key", container_tag="user-123")
47
+ conn = AgentSupermemory(api_key="your-key", namespace="user-123")
48
48
 
49
49
  provider = SupermemoryContextProvider(
50
50
  conn,
@@ -89,7 +89,7 @@ class SupermemoryContextProvider(BaseContextProvider):
89
89
  super().__init__(source_id=source_id)
90
90
 
91
91
  self._connection = connection
92
- self._container_tag = connection.container_tag
92
+ self._container_tag = connection.namespace
93
93
  self._mode = mode
94
94
  self._store_conversations = store_conversations
95
95
  self._context_prompt = context_prompt
@@ -226,7 +226,7 @@ class SupermemoryChatMiddleware(ChatMiddleware):
226
226
  SupermemoryMiddlewareOptions,
227
227
  )
228
228
 
229
- conn = AgentSupermemory(api_key="your-key", container_tag="user-123")
229
+ conn = AgentSupermemory(api_key="your-key", namespace="user-123")
230
230
 
231
231
  middleware = SupermemoryChatMiddleware(
232
232
  conn,
@@ -253,7 +253,7 @@ class SupermemoryChatMiddleware(ChatMiddleware):
253
253
  options: Optional[SupermemoryMiddlewareOptions] = None,
254
254
  ) -> None:
255
255
  self._connection = connection
256
- self._container_tag = connection.container_tag
256
+ self._container_tag = connection.namespace
257
257
  self._options = options or SupermemoryMiddlewareOptions()
258
258
  self._logger = create_logger(self._options.verbose)
259
259
  self._supermemory_client = connection.client
@@ -85,7 +85,7 @@ class SupermemoryTools:
85
85
  ```python
86
86
  from supermemory_agent_framework import AgentSupermemory, SupermemoryTools
87
87
 
88
- conn = AgentSupermemory(api_key="your-key", container_tag="user-123")
88
+ conn = AgentSupermemory(api_key="your-key", namespace="user-123")
89
89
  tools = SupermemoryTools(conn)
90
90
  agent_tools = tools.get_tools()
91
91
 
@@ -123,7 +123,7 @@ class SupermemoryTools:
123
123
 
124
124
  try:
125
125
  response = await self._client.search(
126
- self._connection.container_tag,
126
+ self._connection.namespace,
127
127
  query=information_to_get,
128
128
  limit=limit,
129
129
  threshold=0.6,
@@ -150,7 +150,7 @@ class SupermemoryTools:
150
150
  """Add (remember) memories/details/information about the user or other facts or entities. Run when explicitly asked or when the user mentions any information generalizable beyond the context of the current conversation."""
151
151
  try:
152
152
  response = await self._client.add(
153
- self._connection.container_tag,
153
+ self._connection.namespace,
154
154
  content=memory,
155
155
  id=self._connection.custom_id,
156
156
  )
@@ -173,7 +173,7 @@ class SupermemoryTools:
173
173
  """Get user profile containing static memories (permanent facts) and dynamic memories (recent context). Optionally include search results by providing a query."""
174
174
  try:
175
175
  response, search = await _fetch_profile_and_search(
176
- self._client, self._connection.container_tag, query=query
176
+ self._client, self._connection.namespace, query=query
177
177
  )
178
178
  result: dict[str, Any] = {
179
179
  "success": True,