fix: prevent agent debug from blocking chat

This commit is contained in:
2026-07-13 12:27:07 +08:00
parent 2453816364
commit 0864f9305b
4 changed files with 43 additions and 6 deletions

View File

@@ -85,7 +85,7 @@ async def debug_agent(
retrieval_log_id=rag_result.retrieval_log_id,
tool_trace=rag_result.tool_trace,
)
result = ModelClientService.debug_model(
result = await ModelClientService.debug_model_async(
model,
rag_result,
{

View File

@@ -1,5 +1,6 @@
from __future__ import annotations
import asyncio
import json
from dataclasses import dataclass
from typing import Any
@@ -93,6 +94,11 @@ class ModelClientService:
"knowledgeIds": rag_result.knowledge_ids,
}
@staticmethod
async def debug_model_async(model: ModelConfig, rag_result: RagResult, overrides: dict[str, Any]) -> dict[str, Any]:
"""Run the blocking provider client outside the ASGI event loop."""
return await asyncio.to_thread(ModelClientService.debug_model, model, rag_result, overrides)
def _mock_answer(rag_result: RagResult) -> str:
if not rag_result.is_hit: