@@ -26,9 +26,9 @@ def validate_memory_url_path(path: str) -> bool:
2626 >>> validate_memory_url_path("invalid://test") # Contains protocol
2727 False
2828 """
29- # Allow empty path for root URL (memory://)
29+ # Empty paths are not valid
3030 if not path or not path .strip ():
31- return True
31+ return False
3232
3333 # Check for invalid protocol schemes within the path first (more specific)
3434 if "://" in path :
@@ -69,7 +69,13 @@ def normalize_memory_url(url: str | None) -> str:
6969 ValueError: Invalid memory URL path: 'memory//test' contains double slashes
7070 """
7171 if not url :
72- return "memory://" # Return root URL for empty input
72+ raise ValueError ("Memory URL cannot be empty" )
73+
74+ # Strip whitespace for consistency
75+ url = url .strip ()
76+
77+ if not url :
78+ raise ValueError ("Memory URL cannot be empty or whitespace" )
7379
7480 clean_path = url .removeprefix ("memory://" )
7581
@@ -122,7 +128,9 @@ class EntitySummary(BaseModel):
122128 title : str
123129 content : Optional [str ] = None
124130 file_path : str
125- created_at : Annotated [datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })]
131+ created_at : Annotated [
132+ datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })
133+ ]
126134
127135 @field_serializer ("created_at" )
128136 def serialize_created_at (self , dt : datetime ) -> str :
@@ -139,7 +147,9 @@ class RelationSummary(BaseModel):
139147 relation_type : str
140148 from_entity : Optional [str ] = None
141149 to_entity : Optional [str ] = None
142- created_at : Annotated [datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })]
150+ created_at : Annotated [
151+ datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })
152+ ]
143153
144154 @field_serializer ("created_at" )
145155 def serialize_created_at (self , dt : datetime ) -> str :
@@ -155,7 +165,9 @@ class ObservationSummary(BaseModel):
155165 permalink : str
156166 category : str
157167 content : str
158- created_at : Annotated [datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })]
168+ created_at : Annotated [
169+ datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })
170+ ]
159171
160172 @field_serializer ("created_at" )
161173 def serialize_created_at (self , dt : datetime ) -> str :
@@ -169,7 +181,9 @@ class MemoryMetadata(BaseModel):
169181 types : Optional [List [SearchItemType ]] = None
170182 depth : int
171183 timeframe : Optional [str ] = None
172- generated_at : Annotated [datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })]
184+ generated_at : Annotated [
185+ datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })
186+ ]
173187 primary_count : Optional [int ] = None # Changed field name
174188 related_count : Optional [int ] = None # Changed field name
175189 total_results : Optional [int ] = None # For backward compatibility
@@ -234,9 +248,9 @@ class ProjectActivity(BaseModel):
234248 project_path : str
235249 activity : GraphContext = Field (description = "The actual activity data for this project" )
236250 item_count : int = Field (description = "Total items in this project's activity" )
237- last_activity : Optional [Annotated [ datetime , Field ( json_schema_extra = { "type" : "string" , "format" : "date-time" })]] = Field (
238- default = None , description = "Most recent activity timestamp"
239- )
251+ last_activity : Optional [
252+ Annotated [ datetime , Field ( json_schema_extra = { "type" : "string" , "format" : "date-time" })]
253+ ] = Field ( default = None , description = "Most recent activity timestamp" )
240254 active_folders : List [str ] = Field (default_factory = list , description = "Most active folders" )
241255
242256 @field_serializer ("last_activity" )
@@ -252,7 +266,9 @@ class ProjectActivitySummary(BaseModel):
252266 )
253267 summary : ActivityStats
254268 timeframe : str = Field (description = "The timeframe used for the query" )
255- generated_at : Annotated [datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })]
269+ generated_at : Annotated [
270+ datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })
271+ ]
256272 guidance : Optional [str ] = Field (
257273 default = None , description = "Assistant guidance for project selection and session management"
258274 )
0 commit comments