fix: "等用户的工具"要豁免 60 秒的工具执行超时(v2.0.44 的"不限时"只做了一半)
用户要求"AI 询问界面不要限时"。v2.0.44 改了界面侧(AiSurface 无限等)和
工具侧(ask_user 的 timeout 默认 0),但**漏了内核的工具执行超时**:
实测:弹窗 135 秒确实还在,但工具调用在 60.0 秒返回
{"ok":false,"error":"工具执行超时(60s)"} —— 用户后来点的选项根本
回不到模型手里,模型已经拿着"超时"自己往下写了。
改动:
- builtin_tools.run_with_timeout:timeout_s <= 0 = 不限时(thread.join() 不带参)
- tools/ask_user.py、tools/show_ui.py:声明 WAIT_FOR_USER = True
- tools_runtime:新增 _waits_for_user(),会等用户的工具把超时预算设成 0;
普通工具仍是 60 秒(死循环的安全网没丢)
验证(scripts/probe-ask-user-forever.py,真机跑):
修之前 60.0 秒 → {"ok":false,"error":"工具执行超时(60s)"}
修之后 66.2 秒 → {"ok":true,"result":{...,"choice":"B","timeout":false}}
守门:scripts/verify-ui-tools.py 新增一节(声明在不在、豁免逻辑在不在、
预算 0 是不是真的无限等、普通工具的 60 秒还在不在)。
文档:docs/AI界面能力.md 补"不限时要三处一起改"和客户端长连接为什么不断
(15 秒心跳 vs 120 秒 readTimeout)。
版本 2.0.45。
This commit is contained in:
@@ -33,6 +33,12 @@ from _ui_bridge import call_device, conversation_id # noqa: E402
|
||||
MIN_TIMEOUT_S = 5.0
|
||||
MAX_TIMEOUT_S = 3600.0
|
||||
|
||||
# ★★ 告诉内核:这个工具在 wait=true 时**会停下来等用户**,别拿 60 秒的
|
||||
# 工具超时卡它(wait=false 时它立刻就返回,不受影响)。
|
||||
# 不声明的后果和 ask_user 那边一样:界面还开着,模型却已经收到"工具超时"。
|
||||
# 见 android/kernel/tools_runtime.py 的 _waits_for_user。
|
||||
WAIT_FOR_USER = True
|
||||
|
||||
TOOL = {
|
||||
"name": "show_ui",
|
||||
"description": (
|
||||
|
||||
Reference in New Issue
Block a user