fix(agent): add memory config validation and fix config id reference

- Add null check for actual_config_id before calling term_memory_save in langchain_agent.py to prevent errors when memory config is unavailable
- Add warning log when skipping term_memory_save due to missing memory config
- Fix incorrect attribute reference from memory_config.id to memory_config.config_id in memory_agent_service.py
- Fix method call from private _get_workspace_default_config to public get_workspace_default_config in memory_config_service.py
- Ensures graceful handling of missing memory configurations and prevents runtime errors
This commit is contained in:
Ke Sun
2026-02-05 10:19:43 +08:00
parent 1e9c32a102
commit a3cf773e75
3 changed files with 11 additions and 5 deletions

View File

@@ -1194,7 +1194,7 @@ def get_end_user_connected_config(end_user_id: str, db: Session) -> Dict[str, An
workspace_id=app.workspace_id
)
memory_config_id = str(memory_config.id) if memory_config else None
memory_config_id = str(memory_config.config_id) if memory_config else None
result = {
"end_user_id": str(end_user_id),

View File

@@ -525,7 +525,7 @@ class MemoryConfigService:
"No memory config ID provided, using workspace default",
extra={"workspace_id": str(workspace_id)}
)
return self._get_workspace_default_config(workspace_id)
return self.get_workspace_default_config(workspace_id)
config = self.db.get(MemoryConfigModel, memory_config_id)
@@ -540,7 +540,7 @@ class MemoryConfigService:
}
)
return self._get_workspace_default_config(workspace_id)
return self.get_workspace_default_config(workspace_id)
def delete_config(
self,