A JSON chat answer blocks the backend event loop for the whole RAG run
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 85/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 领域
- backend, performance
调研方向
从backend/开始,阅读POST /conversations/agent-retriever和POST /helpers/suggestedQuestions的处理程序;issue描述了这两个阻塞调用以及建议使用run_in_threadpool进行修复。使用issue中通过模拟图和httpx.AsyncClient进行复现的方法,验证生成JSON答案时/healthcheck仍会响应。完成标准是两个处理程序都能保持事件循环的响应能力,并且该复现有回归测试覆盖。
由索引模型根据 Issue 内容生成。
描述
POST /conversations/agent-retriever is an async def endpoint. Without "stream": true, it runs the graph synchronously:
output = list(graph.graph.stream(inputs, stream_mode="updates"))
That call holds the event loop for the whole run: retrieval, reranking, and the LLM calls. Until the run ends, the backend answers no other request. The Docker image runs one uvicorn process, so meanwhile:
/healthcheckand/conversations/readywait. The compose healthcheck calls/healthcheckwith a 10 s timeout.- Other users' questions, the Next.js conversation list, and suggested questions wait, so concurrent questions are answered one at a time.
POST /helpers/suggestedQuestions has the same problem on a smaller scale: it calls the synchronous OpenAI client inside async def, and the Next.js app calls it after every answer.
The streaming path is not affected: it uses astream_events, which runs the sync graph nodes in worker threads.
Reproduce
From backend/, with the test setup in CONTRIBUTING.md: a mocked graph whose run takes 2 s (time.sleep(2) in stream), the conversations and healthcheck routers, and an httpx.AsyncClient over ASGITransport. Start a JSON answer, then sleep 0.2 s and call /healthcheck:
sleep(0.2) returned after 2.15s
healthcheck 200 answered 2.16s after the chat request started
Proposed fix
Run both blocking calls in a worker thread with run_in_threadpool, as FastAPI does for def endpoints. The graph then runs off the event loop in the JSON path, as it already does in the streaming path.
- 主要语言
- Python
- 星标
- 51
- 派生
- 27
- 平均合并
- 11 小时 59 分钟
- 30 天内合并 PR
- 33
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
The-OpenROAD-Project/ORAssistant 的其他 Issue
-
Rename a conversation from the sidebar可能已有人在做 @NopeCharon 今天认领。 未关闭
难度 4/5 3-5 天 新手友好度 62/100
The-OpenROAD-Project/ORAssistant#659 ·
维护者通常 1 天内回复
-
Conversations from POST /conversations stay untitled and keep their creation time可能已有人在做 @NopeCharon 今天认领。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
The-OpenROAD-Project/ORAssistant#655 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 20/100
The-OpenROAD-Project/ORAssistant#186 · 1 条评论 ·
维护者通常 1 天内回复
-
Deprecate GOOGLE_APPLICATION_CREDENTIALS可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
The-OpenROAD-Project/ORAssistant#155 · 2 条评论 ·
维护者通常 1 天内回复
-
Add button to OR GUI for easy access可能重新可做 @sparsh-karna 于 164 天前认领,目前没有进行中的 PR。 未关闭
The-OpenROAD-Project/ORAssistant#152 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 The-OpenROAD-Project/ORAssistant 的全部 Issue
相似的 Issue
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionError可能已有人在做 @jejjohnson 今天认领。 未关闭type:bug
难度 2/5 1-3 小时 新手友好度 72/100
jejjohnson/integrix#144 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
finos/ai-governance-framework#459 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
freelawproject/litigant-portal#1307 ·
维护者通常 2 天内回复