Open
Conversation
fix: request wait telemetry id fix: register request wait before enqueue add log
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
markwhen
approved these changes
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
将写接口 wait 改为请求级完成
Summary
把 add-resource、add-skill、content/write 的 wait=True 从“等待全局队列清空”改成“等待当前
请求自己的异步处理链完成”。本次改造同时覆盖:
外部 API 不变,wait_processed() 继续保留全局等待语义。响应里继续返回 queue_status,但其语
义从“全局队列状态”改成“当前请求聚合状态”。
实现策略是最大化复用现有机制:
Key Changes
1. 新增 RequestWaitTracker
新增一个最小版请求级等待跟踪器,职责只有两件事:
内部按 telemetry_id 维护:
最小接口:
输出格式保持与现有兼容:
{
"Semantic": {
"processed": 1,
"error_count": 0,
"errors": []
},
"Embedding": {
"processed": 3,
"error_count": 0,
"errors": []
}
}
2. 范围明确覆盖 HTTP 和 local SDK
当前两条公开调用链都会创建启用态 OperationTelemetry,因此都有可用 telemetry_id:
因此本次范围明确包括:
本次不新增 request id / task id。
3. add_resource(wait=True) 改造
文件:
实现:
msg.id)
request_wait_tracker.wait_for_request(telemetry_id, timeout)
结果:
4. semantic 完成链复用现有 EmbeddingTaskTracker
文件:
当前已有:
本次在这个现成链路末尾补请求级通知:
不改变 EmbeddingTaskTracker 的原职责,它仍然只负责一个 semantic_msg_id 下 embedding 子任
务的归零与回调。
5. content/write(wait=True) 改造
文件:
实现:
register_semantic_root(telemetry_id, msg.id)
注意 memory 分支:
6. add_skill(wait=True) 按单 embedding root 实现
文件:
现状:
本次最小实现:
不抽象通用 embedding batch。以后如果 skill 变成多条 embedding message,再扩展。
7. queue_status 与 telemetry summary 分离
文件:
原则:
这样可以保证:
8. re-enqueue 状态机
请求级等待必须正确处理 retry / re-enqueue:
这条规则适用于:
因此:
9. queue_status 成本控制
本次继续返回 queue_status,但不再通过全局队列状态生成它,也不让它成为主要成本来源。
做法:
10. 保持全局等待接口不变
文件:
不改:
它们继续调用 QueueManager.wait_complete(),保持全局 drain 语义。
Test Plan
HTTP 路径
local SDK 路径
上层 SDK 路径
状态机与错误
回归
summary 继续正确输出请求级统计
优先修改/新增测试:
建议新增:
Assumptions