fix(agent): 放宽出诊清单输出与历史工具结果保留长度
输出上限支持按端配置并放宽到 escort 3000 / admin 5000;医院与网页类工具结果入历史保留 3000 字,数据库类维持 300 字,避免出诊信息被截断或追问时丢失。
This commit is contained in:
+17
-1
@@ -13,6 +13,16 @@ import logger from "../../utils/logger.js";
|
||||
|
||||
// tool 结果保留的字符数,超出部分以标记代替
|
||||
export const TOOL_RESULT_MAX_CHARS = 300;
|
||||
// 网页正文/医院档案类结果:下一轮追问常要引用其中的排班、流程明细,保留更长的开头
|
||||
export const LARGE_TOOL_RESULT_MAX_CHARS = 3000;
|
||||
// 这些工具的输出属于“资料型”内容,数据库类查询仍用上面的小上限,避免记录列表挤占对话
|
||||
export const LARGE_TOOL_RESULT_TOOLS = new Set([
|
||||
"hospital_knowledge_read",
|
||||
"hospital_knowledge_list",
|
||||
"web_fetch",
|
||||
"web_search",
|
||||
"http_get",
|
||||
]);
|
||||
// 子代理(task 工具)的完整回答:主 agent 需要据此转述,上限放宽,仍避免整篇塞进历史
|
||||
export const SUBAGENT_RESULT_MAX_CHARS = 4000;
|
||||
|
||||
@@ -30,7 +40,13 @@ export function appendToolMessage(messages, msg, max) {
|
||||
messages.push(msg);
|
||||
return msg;
|
||||
}
|
||||
const limit = max ?? (msg.name === "task" ? SUBAGENT_RESULT_MAX_CHARS : TOOL_RESULT_MAX_CHARS);
|
||||
const limit = max ?? (
|
||||
msg.name === "task"
|
||||
? SUBAGENT_RESULT_MAX_CHARS
|
||||
: LARGE_TOOL_RESULT_TOOLS.has(msg.name)
|
||||
? LARGE_TOOL_RESULT_MAX_CHARS
|
||||
: TOOL_RESULT_MAX_CHARS
|
||||
);
|
||||
const stored = Object.assign(Object.create(Object.getPrototypeOf(msg)), msg);
|
||||
if (typeof stored.content === "string") {
|
||||
stored.content = truncateToolResult(stored.content, limit);
|
||||
|
||||
Reference in New Issue
Block a user