powermem 0.1.0__py3-none-any.whl

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.
Files changed (123) hide show
  1. powermem/__init__.py +103 -0
  2. powermem/agent/__init__.py +35 -0
  3. powermem/agent/abstract/__init__.py +22 -0
  4. powermem/agent/abstract/collaboration.py +259 -0
  5. powermem/agent/abstract/context.py +187 -0
  6. powermem/agent/abstract/manager.py +232 -0
  7. powermem/agent/abstract/permission.py +217 -0
  8. powermem/agent/abstract/privacy.py +267 -0
  9. powermem/agent/abstract/scope.py +199 -0
  10. powermem/agent/agent.py +791 -0
  11. powermem/agent/components/__init__.py +18 -0
  12. powermem/agent/components/collaboration_coordinator.py +645 -0
  13. powermem/agent/components/permission_controller.py +586 -0
  14. powermem/agent/components/privacy_protector.py +767 -0
  15. powermem/agent/components/scope_controller.py +685 -0
  16. powermem/agent/factories/__init__.py +16 -0
  17. powermem/agent/factories/agent_factory.py +266 -0
  18. powermem/agent/factories/config_factory.py +308 -0
  19. powermem/agent/factories/memory_factory.py +229 -0
  20. powermem/agent/implementations/__init__.py +16 -0
  21. powermem/agent/implementations/hybrid.py +728 -0
  22. powermem/agent/implementations/multi_agent.py +1040 -0
  23. powermem/agent/implementations/multi_user.py +1020 -0
  24. powermem/agent/types.py +53 -0
  25. powermem/agent/wrappers/__init__.py +14 -0
  26. powermem/agent/wrappers/agent_memory_wrapper.py +427 -0
  27. powermem/agent/wrappers/compatibility_wrapper.py +520 -0
  28. powermem/config_loader.py +318 -0
  29. powermem/configs.py +249 -0
  30. powermem/core/__init__.py +19 -0
  31. powermem/core/async_memory.py +1493 -0
  32. powermem/core/audit.py +258 -0
  33. powermem/core/base.py +165 -0
  34. powermem/core/memory.py +1567 -0
  35. powermem/core/setup.py +162 -0
  36. powermem/core/telemetry.py +215 -0
  37. powermem/integrations/__init__.py +17 -0
  38. powermem/integrations/embeddings/__init__.py +13 -0
  39. powermem/integrations/embeddings/aws_bedrock.py +100 -0
  40. powermem/integrations/embeddings/azure_openai.py +55 -0
  41. powermem/integrations/embeddings/base.py +31 -0
  42. powermem/integrations/embeddings/config/base.py +132 -0
  43. powermem/integrations/embeddings/configs.py +31 -0
  44. powermem/integrations/embeddings/factory.py +48 -0
  45. powermem/integrations/embeddings/gemini.py +39 -0
  46. powermem/integrations/embeddings/huggingface.py +41 -0
  47. powermem/integrations/embeddings/langchain.py +35 -0
  48. powermem/integrations/embeddings/lmstudio.py +29 -0
  49. powermem/integrations/embeddings/mock.py +11 -0
  50. powermem/integrations/embeddings/ollama.py +53 -0
  51. powermem/integrations/embeddings/openai.py +49 -0
  52. powermem/integrations/embeddings/qwen.py +102 -0
  53. powermem/integrations/embeddings/together.py +31 -0
  54. powermem/integrations/embeddings/vertexai.py +54 -0
  55. powermem/integrations/llm/__init__.py +18 -0
  56. powermem/integrations/llm/anthropic.py +87 -0
  57. powermem/integrations/llm/base.py +132 -0
  58. powermem/integrations/llm/config/anthropic.py +56 -0
  59. powermem/integrations/llm/config/azure.py +56 -0
  60. powermem/integrations/llm/config/base.py +62 -0
  61. powermem/integrations/llm/config/deepseek.py +56 -0
  62. powermem/integrations/llm/config/ollama.py +56 -0
  63. powermem/integrations/llm/config/openai.py +79 -0
  64. powermem/integrations/llm/config/qwen.py +68 -0
  65. powermem/integrations/llm/config/qwen_asr.py +46 -0
  66. powermem/integrations/llm/config/vllm.py +56 -0
  67. powermem/integrations/llm/configs.py +26 -0
  68. powermem/integrations/llm/deepseek.py +106 -0
  69. powermem/integrations/llm/factory.py +118 -0
  70. powermem/integrations/llm/gemini.py +201 -0
  71. powermem/integrations/llm/langchain.py +65 -0
  72. powermem/integrations/llm/ollama.py +106 -0
  73. powermem/integrations/llm/openai.py +166 -0
  74. powermem/integrations/llm/openai_structured.py +80 -0
  75. powermem/integrations/llm/qwen.py +207 -0
  76. powermem/integrations/llm/qwen_asr.py +171 -0
  77. powermem/integrations/llm/vllm.py +106 -0
  78. powermem/integrations/rerank/__init__.py +20 -0
  79. powermem/integrations/rerank/base.py +43 -0
  80. powermem/integrations/rerank/config/__init__.py +7 -0
  81. powermem/integrations/rerank/config/base.py +27 -0
  82. powermem/integrations/rerank/configs.py +23 -0
  83. powermem/integrations/rerank/factory.py +68 -0
  84. powermem/integrations/rerank/qwen.py +159 -0
  85. powermem/intelligence/__init__.py +17 -0
  86. powermem/intelligence/ebbinghaus_algorithm.py +354 -0
  87. powermem/intelligence/importance_evaluator.py +361 -0
  88. powermem/intelligence/intelligent_memory_manager.py +284 -0
  89. powermem/intelligence/manager.py +148 -0
  90. powermem/intelligence/plugin.py +229 -0
  91. powermem/prompts/__init__.py +29 -0
  92. powermem/prompts/graph/graph_prompts.py +217 -0
  93. powermem/prompts/graph/graph_tools_prompts.py +469 -0
  94. powermem/prompts/importance_evaluation.py +246 -0
  95. powermem/prompts/intelligent_memory_prompts.py +163 -0
  96. powermem/prompts/templates.py +193 -0
  97. powermem/storage/__init__.py +14 -0
  98. powermem/storage/adapter.py +896 -0
  99. powermem/storage/base.py +109 -0
  100. powermem/storage/config/base.py +13 -0
  101. powermem/storage/config/oceanbase.py +58 -0
  102. powermem/storage/config/pgvector.py +52 -0
  103. powermem/storage/config/sqlite.py +27 -0
  104. powermem/storage/configs.py +159 -0
  105. powermem/storage/factory.py +59 -0
  106. powermem/storage/migration_manager.py +438 -0
  107. powermem/storage/oceanbase/__init__.py +8 -0
  108. powermem/storage/oceanbase/constants.py +162 -0
  109. powermem/storage/oceanbase/oceanbase.py +1384 -0
  110. powermem/storage/oceanbase/oceanbase_graph.py +1441 -0
  111. powermem/storage/pgvector/__init__.py +7 -0
  112. powermem/storage/pgvector/pgvector.py +420 -0
  113. powermem/storage/sqlite/__init__.py +0 -0
  114. powermem/storage/sqlite/sqlite.py +218 -0
  115. powermem/storage/sqlite/sqlite_vector_store.py +311 -0
  116. powermem/utils/__init__.py +35 -0
  117. powermem/utils/utils.py +605 -0
  118. powermem/version.py +23 -0
  119. powermem-0.1.0.dist-info/METADATA +187 -0
  120. powermem-0.1.0.dist-info/RECORD +123 -0
  121. powermem-0.1.0.dist-info/WHEEL +5 -0
  122. powermem-0.1.0.dist-info/licenses/LICENSE +206 -0
  123. powermem-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,266 @@
1
+ """
2
+ Agent factory for creating agent-related components.
3
+
4
+ This module provides factory classes for creating agent-related components
5
+ such as context managers, scope managers, etc.
6
+ """
7
+
8
+ from typing import Dict, Any, Type
9
+ import logging
10
+
11
+ from powermem.agent.abstract.context import AgentContextManagerBase
12
+ from powermem.agent.abstract.scope import AgentScopeManagerBase
13
+ from powermem.agent.abstract.permission import AgentPermissionManagerBase
14
+ from powermem.agent.abstract.collaboration import AgentCollaborationManagerBase
15
+ from powermem.agent.abstract.privacy import AgentPrivacyManagerBase
16
+
17
+ logger = logging.getLogger(__name__)
18
+
19
+
20
+ class AgentFactory:
21
+ """
22
+ Factory class for creating agent-related components.
23
+
24
+ This factory provides a unified interface for creating various agent
25
+ components such as context managers, scope managers, etc.
26
+ """
27
+
28
+ # Registry of available component types
29
+ _COMPONENT_REGISTRY: Dict[str, Dict[str, Type]] = {
30
+ "context": {},
31
+ "scope": {},
32
+ "permission": {},
33
+ "collaboration": {},
34
+ "privacy": {},
35
+ }
36
+
37
+ @classmethod
38
+ def create_context_manager(
39
+ cls,
40
+ manager_type: str,
41
+ config: Dict[str, Any]
42
+ ) -> AgentContextManagerBase:
43
+ """
44
+ Create a context manager.
45
+
46
+ Args:
47
+ manager_type: Type of context manager to create
48
+ config: Configuration dictionary
49
+
50
+ Returns:
51
+ AgentContextManagerBase instance
52
+
53
+ Raises:
54
+ ValueError: If the manager type is not supported
55
+ """
56
+ if manager_type not in cls._COMPONENT_REGISTRY["context"]:
57
+ raise ValueError(f"Unsupported context manager type: {manager_type}")
58
+
59
+ manager_class = cls._COMPONENT_REGISTRY["context"][manager_type]
60
+
61
+ try:
62
+ manager = manager_class(config)
63
+ manager.initialize()
64
+ logger.info(f"Created {manager_type} context manager successfully")
65
+ return manager
66
+ except Exception as e:
67
+ logger.error(f"Failed to create {manager_type} context manager: {e}")
68
+ raise
69
+
70
+ @classmethod
71
+ def create_scope_manager(
72
+ cls,
73
+ manager_type: str,
74
+ config: Dict[str, Any]
75
+ ) -> AgentScopeManagerBase:
76
+ """
77
+ Create a scope manager.
78
+
79
+ Args:
80
+ manager_type: Type of scope manager to create
81
+ config: Configuration dictionary
82
+
83
+ Returns:
84
+ AgentScopeManagerBase instance
85
+
86
+ Raises:
87
+ ValueError: If the manager type is not supported
88
+ """
89
+ if manager_type not in cls._COMPONENT_REGISTRY["scope"]:
90
+ raise ValueError(f"Unsupported scope manager type: {manager_type}")
91
+
92
+ manager_class = cls._COMPONENT_REGISTRY["scope"][manager_type]
93
+
94
+ try:
95
+ manager = manager_class(config)
96
+ manager.initialize()
97
+ logger.info(f"Created {manager_type} scope manager successfully")
98
+ return manager
99
+ except Exception as e:
100
+ logger.error(f"Failed to create {manager_type} scope manager: {e}")
101
+ raise
102
+
103
+ @classmethod
104
+ def create_permission_manager(
105
+ cls,
106
+ manager_type: str,
107
+ config: Dict[str, Any]
108
+ ) -> AgentPermissionManagerBase:
109
+ """
110
+ Create a permission manager.
111
+
112
+ Args:
113
+ manager_type: Type of permission manager to create
114
+ config: Configuration dictionary
115
+
116
+ Returns:
117
+ AgentPermissionManagerBase instance
118
+
119
+ Raises:
120
+ ValueError: If the manager type is not supported
121
+ """
122
+ if manager_type not in cls._COMPONENT_REGISTRY["permission"]:
123
+ raise ValueError(f"Unsupported permission manager type: {manager_type}")
124
+
125
+ manager_class = cls._COMPONENT_REGISTRY["permission"][manager_type]
126
+
127
+ try:
128
+ manager = manager_class(config)
129
+ manager.initialize()
130
+ logger.info(f"Created {manager_type} permission manager successfully")
131
+ return manager
132
+ except Exception as e:
133
+ logger.error(f"Failed to create {manager_type} permission manager: {e}")
134
+ raise
135
+
136
+ @classmethod
137
+ def create_collaboration_manager(
138
+ cls,
139
+ manager_type: str,
140
+ config: Dict[str, Any]
141
+ ) -> AgentCollaborationManagerBase:
142
+ """
143
+ Create a collaboration manager.
144
+
145
+ Args:
146
+ manager_type: Type of collaboration manager to create
147
+ config: Configuration dictionary
148
+
149
+ Returns:
150
+ AgentCollaborationManagerBase instance
151
+
152
+ Raises:
153
+ ValueError: If the manager type is not supported
154
+ """
155
+ if manager_type not in cls._COMPONENT_REGISTRY["collaboration"]:
156
+ raise ValueError(f"Unsupported collaboration manager type: {manager_type}")
157
+
158
+ manager_class = cls._COMPONENT_REGISTRY["collaboration"][manager_type]
159
+
160
+ try:
161
+ manager = manager_class(config)
162
+ manager.initialize()
163
+ logger.info(f"Created {manager_type} collaboration manager successfully")
164
+ return manager
165
+ except Exception as e:
166
+ logger.error(f"Failed to create {manager_type} collaboration manager: {e}")
167
+ raise
168
+
169
+ @classmethod
170
+ def create_privacy_manager(
171
+ cls,
172
+ manager_type: str,
173
+ config: Dict[str, Any]
174
+ ) -> AgentPrivacyManagerBase:
175
+ """
176
+ Create a privacy manager.
177
+
178
+ Args:
179
+ manager_type: Type of privacy manager to create
180
+ config: Configuration dictionary
181
+
182
+ Returns:
183
+ AgentPrivacyManagerBase instance
184
+
185
+ Raises:
186
+ ValueError: If the manager type is not supported
187
+ """
188
+ if manager_type not in cls._COMPONENT_REGISTRY["privacy"]:
189
+ raise ValueError(f"Unsupported privacy manager type: {manager_type}")
190
+
191
+ manager_class = cls._COMPONENT_REGISTRY["privacy"][manager_type]
192
+
193
+ try:
194
+ manager = manager_class(config)
195
+ manager.initialize()
196
+ logger.info(f"Created {manager_type} privacy manager successfully")
197
+ return manager
198
+ except Exception as e:
199
+ logger.error(f"Failed to create {manager_type} privacy manager: {e}")
200
+ raise
201
+
202
+ @classmethod
203
+ def register_component(
204
+ cls,
205
+ component_type: str,
206
+ component_name: str,
207
+ component_class: Type
208
+ ) -> None:
209
+ """
210
+ Register a new component type.
211
+
212
+ Args:
213
+ component_type: Type of component (context, scope, etc.)
214
+ component_name: Name identifier for the component
215
+ component_class: Class implementing the component interface
216
+ """
217
+ if component_type not in cls._COMPONENT_REGISTRY:
218
+ raise ValueError(f"Unsupported component type: {component_type}")
219
+
220
+ # Validate that the class implements the correct interface
221
+ base_classes = {
222
+ "context": AgentContextManagerBase,
223
+ "scope": AgentScopeManagerBase,
224
+ "permission": AgentPermissionManagerBase,
225
+ "collaboration": AgentCollaborationManagerBase,
226
+ "privacy": AgentPrivacyManagerBase,
227
+ }
228
+
229
+ if not issubclass(component_class, base_classes[component_type]):
230
+ raise ValueError(f"Component class must inherit from {base_classes[component_type].__name__}")
231
+
232
+ cls._COMPONENT_REGISTRY[component_type][component_name] = component_class
233
+ logger.info(f"Registered new {component_type} component: {component_name}")
234
+
235
+ @classmethod
236
+ def get_available_components(cls, component_type: str) -> Dict[str, Type]:
237
+ """
238
+ Get all available components of a specific type.
239
+
240
+ Args:
241
+ component_type: Type of component to get
242
+
243
+ Returns:
244
+ Dictionary mapping component names to their classes
245
+ """
246
+ if component_type not in cls._COMPONENT_REGISTRY:
247
+ raise ValueError(f"Unsupported component type: {component_type}")
248
+
249
+ return cls._COMPONENT_REGISTRY[component_type].copy()
250
+
251
+ @classmethod
252
+ def is_component_supported(cls, component_type: str, component_name: str) -> bool:
253
+ """
254
+ Check if a component is supported.
255
+
256
+ Args:
257
+ component_type: Type of component
258
+ component_name: Name of the component
259
+
260
+ Returns:
261
+ True if supported, False otherwise
262
+ """
263
+ return (
264
+ component_type in cls._COMPONENT_REGISTRY and
265
+ component_name in cls._COMPONENT_REGISTRY[component_type]
266
+ )
@@ -0,0 +1,308 @@
1
+ """
2
+ Configuration factory for creating and managing agent memory configurations.
3
+
4
+ This module provides factory classes for creating and managing different
5
+ types of configurations for the agent memory system.
6
+ """
7
+
8
+ from typing import Dict, Any
9
+ import logging
10
+
11
+ from powermem.configs import (
12
+ MemoryConfig,
13
+ AgentMemoryConfig,
14
+ MultiAgentMemoryConfig,
15
+ MultiUserConfig,
16
+ HybridConfig
17
+ )
18
+
19
+ logger = logging.getLogger(__name__)
20
+
21
+
22
+ class ConfigFactory:
23
+ """
24
+ Factory class for creating and managing agent memory configurations.
25
+
26
+ This factory provides a unified interface for creating different types
27
+ of configurations for the agent memory system.
28
+ """
29
+
30
+ @classmethod
31
+ def create_agent_memory_config(
32
+ cls,
33
+ mode: str = "multi_agent",
34
+ enabled: bool = True,
35
+ **kwargs
36
+ ) -> AgentMemoryConfig:
37
+ """
38
+ Create an agent memory configuration.
39
+
40
+ Args:
41
+ mode: Management mode (multi_agent, multi_user, hybrid)
42
+ enabled: Whether to enable agent memory management
43
+ **kwargs: Additional configuration parameters
44
+
45
+ Returns:
46
+ AgentMemoryConfig instance
47
+ """
48
+ config = AgentMemoryConfig(
49
+ mode=mode,
50
+ enabled=enabled
51
+ )
52
+
53
+ # Apply additional parameters
54
+ for key, value in kwargs.items():
55
+ if hasattr(config, key):
56
+ setattr(config, key, value)
57
+
58
+ logger.info(f"Created agent memory config with mode: {mode}")
59
+ return config
60
+
61
+ @classmethod
62
+ def create_multi_agent_config(
63
+ cls,
64
+ enabled: bool = True,
65
+ default_scope: str = "private",
66
+ enable_collaboration: bool = True,
67
+ **kwargs
68
+ ) -> MultiAgentMemoryConfig:
69
+ """
70
+ Create a multi-agent memory configuration.
71
+
72
+ Args:
73
+ enabled: Whether to enable multi-agent memory management
74
+ default_scope: Default memory scope
75
+ enable_collaboration: Whether to enable collaboration
76
+ **kwargs: Additional configuration parameters
77
+
78
+ Returns:
79
+ MultiAgentMemoryConfig instance
80
+ """
81
+ from powermem.configs import MemoryScope, CollaborationLevel
82
+
83
+ config = MultiAgentMemoryConfig(
84
+ enabled=enabled,
85
+ default_scope=MemoryScope(default_scope),
86
+ default_collaboration_level=(
87
+ CollaborationLevel.COLLABORATIVE if enable_collaboration
88
+ else CollaborationLevel.ISOLATED
89
+ )
90
+ )
91
+
92
+ # Apply additional parameters
93
+ for key, value in kwargs.items():
94
+ if hasattr(config, key):
95
+ setattr(config, key, value)
96
+
97
+ logger.info("Created multi-agent memory config")
98
+ return config
99
+
100
+ @classmethod
101
+ def create_multi_user_config(
102
+ cls,
103
+ user_isolation: bool = True,
104
+ cross_user_sharing: bool = False,
105
+ **kwargs
106
+ ) -> MultiUserConfig:
107
+ """
108
+ Create a multi-user memory configuration.
109
+
110
+ Args:
111
+ user_isolation: Whether to enable user isolation
112
+ cross_user_sharing: Whether to allow cross-user sharing
113
+ **kwargs: Additional configuration parameters
114
+
115
+ Returns:
116
+ MultiUserConfig instance
117
+ """
118
+ config = MultiUserConfig(
119
+ user_isolation=user_isolation,
120
+ cross_user_sharing=cross_user_sharing
121
+ )
122
+
123
+ # Apply additional parameters
124
+ for key, value in kwargs.items():
125
+ if hasattr(config, key):
126
+ setattr(config, key, value)
127
+
128
+ logger.info("Created multi-user memory config")
129
+ return config
130
+
131
+ @classmethod
132
+ def create_hybrid_config(
133
+ cls,
134
+ enabled: bool = True,
135
+ primary_mode: str = "multi_user",
136
+ fallback_mode: str = "multi_agent",
137
+ auto_switch_threshold: float = 0.8,
138
+ **kwargs
139
+ ) -> HybridConfig:
140
+ """
141
+ Create a hybrid memory configuration.
142
+
143
+ Args:
144
+ enabled: Whether to enable hybrid mode
145
+ primary_mode: Primary management mode
146
+ fallback_mode: Fallback management mode
147
+ auto_switch_threshold: Threshold for automatic mode switching
148
+ **kwargs: Additional configuration parameters
149
+
150
+ Returns:
151
+ HybridConfig instance
152
+ """
153
+ config = HybridConfig(
154
+ enabled=enabled,
155
+ primary_mode=primary_mode,
156
+ fallback_mode=fallback_mode,
157
+ auto_switch_threshold=auto_switch_threshold
158
+ )
159
+
160
+ # Apply additional parameters
161
+ for key, value in kwargs.items():
162
+ if hasattr(config, key):
163
+ setattr(config, key, value)
164
+
165
+ logger.info("Created hybrid memory config")
166
+ return config
167
+
168
+ @classmethod
169
+ def create_full_memory_config(
170
+ cls,
171
+ agent_memory_mode: str = "multi_agent",
172
+ agent_memory_enabled: bool = True,
173
+ **kwargs
174
+ ) -> MemoryConfig:
175
+ """
176
+ Create a complete memory configuration with agent memory settings.
177
+
178
+ Args:
179
+ agent_memory_mode: Agent memory management mode
180
+ agent_memory_enabled: Whether to enable agent memory management
181
+ **kwargs: Additional configuration parameters
182
+
183
+ Returns:
184
+ MemoryConfig instance with agent memory configuration
185
+ """
186
+ # Create base memory config
187
+ config = MemoryConfig()
188
+
189
+ # Create agent memory config
190
+ agent_config = cls.create_agent_memory_config(
191
+ mode=agent_memory_mode,
192
+ enabled=agent_memory_enabled
193
+ )
194
+
195
+ # Set agent memory config
196
+ config.agent_memory = agent_config
197
+
198
+ # Apply additional parameters
199
+ for key, value in kwargs.items():
200
+ if hasattr(config, key):
201
+ setattr(config, key, value)
202
+
203
+ logger.info(f"Created full memory config with agent memory mode: {agent_memory_mode}")
204
+ return config
205
+
206
+ @classmethod
207
+ def update_config_from_dict(
208
+ cls,
209
+ config: MemoryConfig,
210
+ config_dict: Dict[str, Any]
211
+ ) -> MemoryConfig:
212
+ """
213
+ Update a memory configuration from a dictionary.
214
+
215
+ Args:
216
+ config: Memory configuration to update
217
+ config_dict: Dictionary containing configuration updates
218
+
219
+ Returns:
220
+ Updated MemoryConfig instance
221
+ """
222
+ for key, value in config_dict.items():
223
+ if hasattr(config, key):
224
+ setattr(config, key, value)
225
+ elif hasattr(config, 'agent_memory') and hasattr(config.agent_memory, key):
226
+ setattr(config.agent_memory, key, value)
227
+
228
+ logger.info("Updated memory config from dictionary")
229
+ return config
230
+
231
+ @classmethod
232
+ def validate_config(cls, config: MemoryConfig) -> Dict[str, Any]:
233
+ """
234
+ Validate a memory configuration.
235
+
236
+ Args:
237
+ config: Memory configuration to validate
238
+
239
+ Returns:
240
+ Dictionary containing validation results
241
+ """
242
+ validation_results = {
243
+ "valid": True,
244
+ "errors": [],
245
+ "warnings": []
246
+ }
247
+
248
+ try:
249
+ # Validate agent memory config if present
250
+ if hasattr(config, 'agent_memory') and config.agent_memory.enabled:
251
+ agent_config = config.agent_memory
252
+
253
+ # Check mode validity
254
+ valid_modes = ["multi_agent", "multi_user", "hybrid"]
255
+ if agent_config.mode not in valid_modes:
256
+ validation_results["errors"].append(
257
+ f"Invalid agent memory mode: {agent_config.mode}"
258
+ )
259
+ validation_results["valid"] = False
260
+
261
+ # Check hybrid config if mode is hybrid
262
+ if agent_config.mode == "hybrid":
263
+ if not agent_config.hybrid_config.enabled:
264
+ validation_results["warnings"].append(
265
+ "Hybrid mode is selected but hybrid config is not enabled"
266
+ )
267
+
268
+ logger.info("Memory config validation completed")
269
+
270
+ except Exception as e:
271
+ validation_results["errors"].append(f"Validation error: {str(e)}")
272
+ validation_results["valid"] = False
273
+ logger.error(f"Memory config validation failed: {e}")
274
+
275
+ return validation_results
276
+
277
+ @classmethod
278
+ def get_config_summary(cls, config: MemoryConfig) -> Dict[str, Any]:
279
+ """
280
+ Get a summary of a memory configuration.
281
+
282
+ Args:
283
+ config: Memory configuration to summarize
284
+
285
+ Returns:
286
+ Dictionary containing configuration summary
287
+ """
288
+ summary = {
289
+ "base_config": {
290
+ "version": config.version,
291
+ "has_vector_store": config.vector_store is not None,
292
+ "has_llm": config.llm is not None,
293
+ "has_embedder": config.embedder is not None,
294
+ }
295
+ }
296
+
297
+ # Add agent memory config summary if present
298
+ if hasattr(config, 'agent_memory'):
299
+ agent_config = config.agent_memory
300
+ summary["agent_memory"] = {
301
+ "enabled": agent_config.enabled,
302
+ "mode": agent_config.mode,
303
+ "has_multi_agent_config": agent_config.multi_agent_config is not None,
304
+ "has_multi_user_config": agent_config.multi_user_config is not None,
305
+ "has_hybrid_config": agent_config.hybrid_config is not None,
306
+ }
307
+
308
+ return summary