@@ -75,14 +75,18 @@ async def write_note(self, note: Entity, *, overwrite: bool) -> WriteNoteRespons
7575 )
7676 return write_note_response_adapter .validate_json (response .content )
7777
78- async def create_entity (self , entity_data : dict [str , Any ]) -> EntityResponse :
78+ async def create_entity (self , entity_data : dict [str , Any ]) -> EntityResponseV2 :
7979 """Create a new entity.
8080
8181 Args:
8282 entity_data: Entity data including title, content, folder, etc.
8383
8484 Returns:
85- EntityResponse with created entity details
85+ EntityResponseV2 with created entity details. The endpoint's
86+ response_model is EntityResponseV2 (it carries file_checksum /
87+ db_checksum, not the legacy EntityResponse.checksum key), so the
88+ response must be parsed as that type or those fields silently
89+ default to None (#1586).
8690
8791 Raises:
8892 ToolError: If the request fails
@@ -102,21 +106,22 @@ async def create_entity(self, entity_data: dict[str, Any]) -> EntityResponse:
102106 operation = "create_entity" ,
103107 path_template = "/v2/projects/{project_id}/knowledge/entities" ,
104108 )
105- return EntityResponse .model_validate (response .json ())
109+ return EntityResponseV2 .model_validate (response .json ())
106110
107111 async def update_entity (
108112 self ,
109113 entity_id : str ,
110114 entity_data : dict [str , Any ],
111- ) -> EntityResponse :
115+ ) -> EntityResponseV2 :
112116 """Update an existing entity (full replacement).
113117
114118 Args:
115119 entity_id: Entity external_id (UUID)
116120 entity_data: Complete entity data for replacement
117121
118122 Returns:
119- EntityResponse with updated entity details
123+ EntityResponseV2 with updated entity details. See create_entity
124+ for why this must be EntityResponseV2, not EntityResponse (#1586).
120125
121126 Raises:
122127 ToolError: If the request fails
@@ -136,7 +141,7 @@ async def update_entity(
136141 operation = "update_entity" ,
137142 path_template = "/v2/projects/{project_id}/knowledge/entities/{entity_id}" ,
138143 )
139- return EntityResponse .model_validate (response .json ())
144+ return EntityResponseV2 .model_validate (response .json ())
140145
141146 async def get_entity (
142147 self ,
@@ -215,15 +220,16 @@ async def patch_entity(
215220 self ,
216221 entity_id : str ,
217222 patch_data : dict [str , Any ],
218- ) -> EntityResponse :
223+ ) -> EntityResponseV2 :
219224 """Partially update an entity.
220225
221226 Args:
222227 entity_id: Entity external_id (UUID)
223228 patch_data: Partial entity data to update
224229
225230 Returns:
226- EntityResponse with updated entity details
231+ EntityResponseV2 with updated entity details. See create_entity
232+ for why this must be EntityResponseV2, not EntityResponse (#1586).
227233
228234 Raises:
229235 ToolError: If the request fails
@@ -243,7 +249,7 @@ async def patch_entity(
243249 operation = "patch_entity" ,
244250 path_template = "/v2/projects/{project_id}/knowledge/entities/{entity_id}" ,
245251 )
246- return EntityResponse .model_validate (response .json ())
252+ return EntityResponseV2 .model_validate (response .json ())
247253
248254 async def delete_entity (self , entity_id : str ) -> DeleteEntitiesResponse :
249255 """Delete an entity.
0 commit comments