fix: preserve interaction replies across chat recovery
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { tool } from "../tool.js";
|
||||
import { interactionQuestionsSchema } from "../../src/chat/interaction-request-contract.js";
|
||||
import { hostQuestionBridge } from "../host-question-policy.js";
|
||||
|
||||
export default tool({
|
||||
description: "向用户提出最多三个澄清问题。先完成其他工具,再单独调用;问题由宿主持久保存,调用成功后本轮结束,等待用户回答。不要猜测答案,不要继续调用工具,不代替业务审批。选项使用稳定 id;支持单选、多选和自定义文字。",
|
||||
args: { questions: tool.schema.array(tool.schema.object({
|
||||
question_id: tool.schema.string().min(1).max(128), title: tool.schema.string().min(1).max(200), body: tool.schema.string().min(1).max(2000),
|
||||
options: tool.schema.array(tool.schema.object({ id: tool.schema.string().min(1).max(128), label: tool.schema.string().min(1).max(200) }).strict()).max(12),
|
||||
mode: tool.schema.enum(["single", "multiple"]), allow_custom: tool.schema.boolean(), required: tool.schema.boolean(),
|
||||
}).strict()).min(1).max(3) },
|
||||
async execute(args, context) {
|
||||
if (!context.callID) throw new Error("Question requires a trusted tool call ID");
|
||||
return JSON.stringify(await hostQuestionBridge("create", {
|
||||
session_id: context.sessionID, call_id: context.callID, tool: "ask_user", questions: interactionQuestionsSchema.parse(args.questions),
|
||||
}, context.signal));
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user