feat(agent): initialize checkpointer before chat session retrieval

Add initialization check for `_checkpointer_conn` in `AgentService` to ensure the checkpointer database connection exists before attempting to retrieve chat sessions. This prevents potential null reference errors when the checkpointer hasn't been initialized yet during agent operations.
This commit is contained in:
YueGuobin 2026-03-04 22:09:09 +08:00
parent 03ab9cdf6c
commit 48e2793719

View File

@ -11,7 +11,7 @@ import json
import logging
import os
from datetime import datetime
from typing import AsyncGenerator, Dict, Any, Optional
from typing import AsyncGenerator, Dict, Any, Optional, List
from uuid import uuid4
import aiosqlite
@ -177,6 +177,10 @@ class AgentService:
mode,
)
# Ensure checkpointer is initialized
if not self._checkpointer_conn:
await self._get_checkpointer()
# Get or create chat session
repo = ChatSessionsRepository(self._checkpointer_conn)
session = await repo.get_session_by_thread(session_id)