supermemory-agent-framework 1.0.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.
@@ -0,0 +1,45 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+ .open-next/
3
+ .sentryclirc
4
+ drizzle.config.ts
5
+
6
+ # Dependencies
7
+ node_modules
8
+ .pnp
9
+ .pnp.js
10
+
11
+ # Local env files
12
+ .env
13
+ .env.local
14
+ .env.development.local
15
+ .env.test.local
16
+ .env.production.local
17
+
18
+ # Testing
19
+ coverage
20
+
21
+ # Turbo
22
+ .turbo
23
+
24
+ # Vercel
25
+ .vercel
26
+
27
+ # Build Outputs
28
+ .next/
29
+ out/
30
+ build
31
+ dist
32
+
33
+
34
+ # Debug
35
+ npm-debug.log*
36
+ yarn-debug.log*
37
+ yarn-error.log*
38
+
39
+ # Misc
40
+ .DS_Store
41
+ *.pem
42
+ .claude
43
+ .venv
44
+ .arch
45
+ __pycache__
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Supermemory
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,383 @@
1
+ Metadata-Version: 2.4
2
+ Name: supermemory-agent-framework
3
+ Version: 1.0.0
4
+ Summary: Memory tools and middleware for Microsoft Agent Framework with supermemory
5
+ Project-URL: Homepage, https://supermemory.ai
6
+ Project-URL: Repository, https://github.com/supermemoryai/supermemory
7
+ Project-URL: Documentation, https://supermemory.ai/docs
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: agent-framework,ai,memory,microsoft,supermemory
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: agent-framework-core>=1.0.0rc3
23
+ Requires-Dist: supermemory>=3.1.0
24
+ Requires-Dist: typing-extensions>=4.0.0
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Supermemory Microsoft Agent Framework SDK
28
+
29
+ Memory tools and middleware for [Microsoft Agent Framework](https://github.com/microsoft/agent-framework) with [Supermemory](https://supermemory.ai) integration.
30
+
31
+ This package provides both **automatic memory injection middleware** and **manual memory tools** for the Microsoft Agent Framework.
32
+
33
+ ## Installation
34
+
35
+ Install using uv (recommended):
36
+
37
+ ```bash
38
+ uv add --prerelease=allow supermemory-agent-framework
39
+ ```
40
+
41
+ Or with pip:
42
+
43
+ ```bash
44
+ pip install --pre supermemory-agent-framework
45
+ ```
46
+
47
+ > **Note:** The `--prerelease=allow` / `--pre` flag is required because `agent-framework-core` depends on pre-release versions of Azure packages.
48
+
49
+ For async HTTP support (recommended):
50
+
51
+ ```bash
52
+ uv add supermemory-agent-framework[async]
53
+ # or
54
+ pip install supermemory-agent-framework[async]
55
+ ```
56
+
57
+ ## Quick Start
58
+
59
+ ### Automatic Memory Injection (Recommended)
60
+
61
+ The easiest way to add memory capabilities is using the `SupermemoryChatMiddleware`:
62
+
63
+ ```python
64
+ import asyncio
65
+ from agent_framework.openai import OpenAIResponsesClient
66
+ from supermemory_agent_framework import (
67
+ SupermemoryChatMiddleware,
68
+ SupermemoryMiddlewareOptions,
69
+ )
70
+
71
+ async def main():
72
+ # Create Supermemory middleware
73
+ middleware = SupermemoryChatMiddleware(
74
+ container_tag="user-123",
75
+ options=SupermemoryMiddlewareOptions(
76
+ mode="full", # "profile", "query", or "full"
77
+ verbose=True, # Enable logging
78
+ add_memory="always" # Automatically save conversations
79
+ ),
80
+ )
81
+
82
+ # Create agent with middleware
83
+ agent = OpenAIResponsesClient().as_agent(
84
+ name="MemoryAgent",
85
+ instructions="You are a helpful assistant with memory.",
86
+ middleware=[middleware],
87
+ )
88
+
89
+ # Use normally - memories are automatically injected!
90
+ response = await agent.run(
91
+ "What's my favorite programming language?"
92
+ )
93
+ print(response.text)
94
+
95
+ asyncio.run(main())
96
+ ```
97
+
98
+ ### Context Provider (Recommended for Sessions)
99
+
100
+ The most idiomatic way to add memory in Agent Framework, using the same pattern as the built-in Mem0 integration:
101
+
102
+ ```python
103
+ import asyncio
104
+ from agent_framework import AgentSession
105
+ from agent_framework.openai import OpenAIResponsesClient
106
+ from supermemory_agent_framework import SupermemoryContextProvider
107
+
108
+ async def main():
109
+ # Create context provider
110
+ provider = SupermemoryContextProvider(
111
+ container_tag="user-123",
112
+ api_key="your-supermemory-api-key",
113
+ mode="full",
114
+ store_conversations=True,
115
+ )
116
+
117
+ # Create agent with context provider
118
+ agent = OpenAIResponsesClient().as_agent(
119
+ name="MemoryAgent",
120
+ instructions="You are a helpful assistant with memory.",
121
+ context_providers=[provider],
122
+ )
123
+
124
+ # Use with a session - memories are automatically fetched and injected
125
+ session = AgentSession()
126
+ response = await agent.run(
127
+ "What's my favorite programming language?",
128
+ session=session,
129
+ )
130
+ print(response.text)
131
+
132
+ asyncio.run(main())
133
+ ```
134
+
135
+ ### Using Memory Tools
136
+
137
+ For explicit tool-based memory access:
138
+
139
+ ```python
140
+ import asyncio
141
+ from agent_framework.openai import OpenAIResponsesClient
142
+ from supermemory_agent_framework import SupermemoryTools
143
+
144
+ async def main():
145
+ # Create memory tools
146
+ tools = SupermemoryTools(
147
+ api_key="your-supermemory-api-key",
148
+ config={"project_id": "my-project"},
149
+ )
150
+
151
+ # Create agent
152
+ agent = OpenAIResponsesClient().as_agent(
153
+ name="MemoryAgent",
154
+ instructions="You are a helpful assistant with access to user memories.",
155
+ )
156
+
157
+ # Run with memory tools
158
+ response = await agent.run(
159
+ "Remember that I prefer tea over coffee",
160
+ tools=tools.get_tools(),
161
+ )
162
+ print(response.text)
163
+
164
+ asyncio.run(main())
165
+ ```
166
+
167
+ ### Combining Middleware and Tools
168
+
169
+ For maximum flexibility, use both middleware (automatic context injection) and tools (explicit memory operations):
170
+
171
+ ```python
172
+ import asyncio
173
+ from agent_framework.openai import OpenAIResponsesClient
174
+ from supermemory_agent_framework import (
175
+ SupermemoryChatMiddleware,
176
+ SupermemoryMiddlewareOptions,
177
+ SupermemoryTools,
178
+ )
179
+
180
+ async def main():
181
+ api_key = "your-supermemory-api-key"
182
+
183
+ middleware = SupermemoryChatMiddleware(
184
+ container_tag="user-123",
185
+ options=SupermemoryMiddlewareOptions(mode="full"),
186
+ api_key=api_key,
187
+ )
188
+
189
+ tools = SupermemoryTools(api_key=api_key)
190
+
191
+ agent = OpenAIResponsesClient().as_agent(
192
+ name="MemoryAgent",
193
+ instructions="You are a helpful assistant with memory.",
194
+ middleware=[middleware],
195
+ )
196
+
197
+ # Middleware injects context automatically,
198
+ # tools let the agent explicitly search/add memories
199
+ response = await agent.run(
200
+ "What do you remember about me?",
201
+ tools=tools.get_tools(),
202
+ )
203
+ print(response.text)
204
+
205
+ asyncio.run(main())
206
+ ```
207
+
208
+ ## Middleware Configuration
209
+
210
+ ### Memory Modes
211
+
212
+ #### `"profile"` mode (default)
213
+ Injects all static and dynamic profile memories into every request.
214
+
215
+ ```python
216
+ SupermemoryMiddlewareOptions(mode="profile")
217
+ ```
218
+
219
+ #### `"query"` mode
220
+ Searches for memories relevant to the current user message.
221
+
222
+ ```python
223
+ SupermemoryMiddlewareOptions(mode="query")
224
+ ```
225
+
226
+ #### `"full"` mode
227
+ Combines both profile and query modes.
228
+
229
+ ```python
230
+ SupermemoryMiddlewareOptions(mode="full")
231
+ ```
232
+
233
+ ### Memory Storage
234
+
235
+ ```python
236
+ # Always save conversations as memories
237
+ SupermemoryMiddlewareOptions(add_memory="always")
238
+
239
+ # Never save conversations (default)
240
+ SupermemoryMiddlewareOptions(add_memory="never")
241
+ ```
242
+
243
+ ### Complete Configuration
244
+
245
+ ```python
246
+ SupermemoryMiddlewareOptions(
247
+ conversation_id="chat-session-456", # Group messages into conversations
248
+ verbose=True, # Enable detailed logging
249
+ mode="full", # Use both profile and query
250
+ add_memory="always" # Auto-save conversations
251
+ )
252
+ ```
253
+
254
+ ## API Reference
255
+
256
+ ### SupermemoryTools
257
+
258
+ Memory tools that integrate with Agent Framework's tool system.
259
+
260
+ ```python
261
+ tools = SupermemoryTools(
262
+ api_key="your-api-key",
263
+ config={
264
+ "project_id": "my-project", # or use container_tags
265
+ "base_url": "https://custom.com", # optional
266
+ }
267
+ )
268
+
269
+ # Get FunctionTool instances for Agent.run()
270
+ agent_tools = tools.get_tools()
271
+
272
+ # Or use directly
273
+ result = await tools.search_memories("user preferences")
274
+ result = await tools.add_memory("User prefers dark mode")
275
+ result = await tools.get_profile()
276
+ ```
277
+
278
+ ### SupermemoryChatMiddleware
279
+
280
+ Chat middleware for automatic memory injection.
281
+
282
+ ```python
283
+ middleware = SupermemoryChatMiddleware(
284
+ container_tag="user-123", # Memory scope identifier
285
+ options=SupermemoryMiddlewareOptions(...),
286
+ api_key="your-api-key", # Or set SUPERMEMORY_API_KEY env var
287
+ )
288
+ ```
289
+
290
+ ### with_supermemory_middleware()
291
+
292
+ Convenience function for creating middleware:
293
+
294
+ ```python
295
+ middleware = with_supermemory_middleware(
296
+ "user-123",
297
+ SupermemoryMiddlewareOptions(mode="full"),
298
+ )
299
+ ```
300
+
301
+ ### SupermemoryContextProvider
302
+
303
+ Context provider for the Agent Framework session pipeline (like Mem0):
304
+
305
+ ```python
306
+ provider = SupermemoryContextProvider(
307
+ container_tag="user-123",
308
+ api_key="your-api-key", # Or set SUPERMEMORY_API_KEY env var
309
+ mode="full", # "profile", "query", or "full"
310
+ store_conversations=True, # Save conversations after each run
311
+ conversation_id="chat-456", # Optional grouping ID
312
+ context_prompt="## Memories\n...", # Custom header for injected memories
313
+ verbose=True, # Enable logging
314
+ )
315
+ ```
316
+
317
+ ## Error Handling
318
+
319
+ ```python
320
+ from supermemory_agent_framework import (
321
+ SupermemoryConfigurationError,
322
+ SupermemoryAPIError,
323
+ SupermemoryNetworkError,
324
+ SupermemoryMemoryOperationError,
325
+ )
326
+
327
+ try:
328
+ middleware = SupermemoryChatMiddleware("user-123")
329
+ except SupermemoryConfigurationError as e:
330
+ print(f"Configuration issue: {e}")
331
+ ```
332
+
333
+ ### Exception Types
334
+
335
+ - **`SupermemoryError`** - Base class for all Supermemory exceptions
336
+ - **`SupermemoryConfigurationError`** - Missing API keys, invalid configuration
337
+ - **`SupermemoryAPIError`** - API request failures (includes status codes)
338
+ - **`SupermemoryNetworkError`** - Network connectivity issues
339
+ - **`SupermemoryMemoryOperationError`** - Memory search/add operation failures
340
+ - **`SupermemoryTimeoutError`** - Operation timeouts
341
+
342
+ ## Environment Variables
343
+
344
+ - `SUPERMEMORY_API_KEY` - Your Supermemory API key (required)
345
+ - `OPENAI_API_KEY` - Your OpenAI API key (required for OpenAI-based agents)
346
+
347
+ ## Dependencies
348
+
349
+ ### Required
350
+ - `agent-framework-core>=1.0.0rc3` - Microsoft Agent Framework
351
+ - `supermemory>=3.1.0` - Supermemory client
352
+ - `requests>=2.25.0` - HTTP requests (fallback)
353
+
354
+ ### Optional
355
+ - `aiohttp>=3.8.0` - Async HTTP requests (recommended)
356
+
357
+ ## Development
358
+
359
+ ```bash
360
+ # Setup
361
+ cd packages/agent-framework-python
362
+ uv sync --dev
363
+
364
+ # Run tests
365
+ uv run pytest
366
+
367
+ # Type checking
368
+ uv run mypy src/supermemory_agent_framework
369
+
370
+ # Formatting
371
+ uv run black src/ tests/
372
+ uv run isort src/ tests/
373
+ ```
374
+
375
+ ## License
376
+
377
+ MIT License - see LICENSE file for details.
378
+
379
+ ## Links
380
+
381
+ - [Supermemory](https://supermemory.ai) - Infinite context memory platform
382
+ - [Microsoft Agent Framework](https://github.com/microsoft/agent-framework) - AI agent framework
383
+ - [Documentation](https://docs.supermemory.ai) - Full API documentation