dsh-aiyayi 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/lib/presence.js +59 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,3 +76,4 @@ GUI 新建会话 → agent preset 选「**阿依娅伊**」。聊天即可;她
|
|
|
76
76
|
20. **核心记忆超限的静默截断会把最新条目丢掉(2026-11-05 实测;1.2.3 已修)**:`renderCore` 原来 `text.slice(0, MAX_CORE_CHARS)`(6000 字符)——①从中间切,条目行被切碎;②保住的是最老的一批,**最新写的条目反而全被截掉**,她以为"带了 51 条核心"其实只注入了 34 条,11-04 中午之后的记忆(含 11-05 新写)全没进上下文。修法:上限提到 12000;超限时改为**头部(人设/约定)+ 尾部(最新)整条保留**,中间批次丢弃,并在注入文本里写明"共 X 字符超限、只注入最前 a 条 + 最新 b 条、中间 c 条(最早 ~ 最晚)先不带,用 recall 或 memory_organize 的 read 查",头部行也标"本次只注入 N 条"。整条边界截断,永不切碎。教训:内存注入的字符上限要用"整条丢"而不是"切字符串",且被丢的部分必须显式告知,否则她以为带着、实际没有。
|
|
77
77
|
21. **子智能体手写 memory.md 会产生双类别前缀污染(2026-11-05 实测;1.2.3 已修)**:小伙伴在派活收尾时有时会"帮她补记",直接把 `用户|用户|…`、`关系|关系|…` 这种带前缀的整句写进 core 行,导致条目类别前缀叠了两层(实测 7 条:关系×1、用户×3、事情×2)。修法:`parseLine` 新增 `stripRepeatedKindPrefix`——遇到连续 `类别|类别|…` 前缀循环剥到只剩一层(任何读取路径都免疫);`remember` 写入前也先剥 content 自带前缀(防再生);存量 7 条已一次性手工修复。教训:凡是"别人代写她记忆文件"的路径都要在解析层兜底,不能指望写手守规矩。
|
|
78
78
|
22. **子代(小伙伴)失败原因不透传到本体(2026-11-05 实测;1.2.3 已修)**:宿主对派出去的子智能体的结算消息只有一句 `failed before it finished` / `It left no closing message.`——真实原因(HTTP_402 积分余额不足、上游限流、403、Illegal API invocation)只躺在子会话自己的 `turn/end` error 事件里(宿主 `terminal.diagnostic` 只有在 provider 主动给时才透传,本地 spawn 的 provider 不给)。她不知道为啥失败 → 盲目重派 3 轮白耗 ~20 分钟。修法:`aiyayi-presence` 的 `session/event` 监听不再丢弃非本体的会话事件,改把 `header.origin==="subagent"`(或带 `header.parentSession`)的子会话 `turn/end` error 记进 `childFailures`(上限 20、只记 error、错误串截 120 字符),下一个 pre-step 注入 `⚠ [小伙伴] 你派出去干活的小智能体有 N 个报错了(宿主只回一句"failed before it finished",真原因在这):…`(每次最多列 3 条、已报过的去重不唠叨)。原理:session/event 总线对所有会话广播,插件端按 `agentsById` 过滤才是它之前只见本体的原因;子会话 header 带 `parentSession` 链接,可归属到正确的父会话。
|
|
79
|
+
23. **新会话首次对话时提醒"关闭思考"(2026-11-05 新增;1.2.4 已做)**:日常闲聊用不上深度思考,回复慢还费 token。`aiyayi-presence` 在每个**新会话的首次对话**(pre-step step===1、每会话只提醒一次)注入 `💡 小建议`:当本体模型的 `reasoningEffort` 已显式选了一个思考档位(有档位 = 必支持"关闭思考",见 pi-ai 校验规则"reasoningEfforts offers no level beyond off → refuse")或通过 `ctx.llm.resolveModelInfo()` 探到 `reasoning.efforts` 里有 `off` 档时,提醒她去模型选项里选「关闭思考」。已选 `off`/`none`、探不到模型信息(`ctx.llm` 不可用、resolveModelInfo 失败)或非推理模型(`reasoning: undefined`)都不打扰。教训:判断"模型支持某个能力"优先用运行时解析(resolveModelInfo),拿不到再退化为显式配置信号,且**只在首轮提醒一次**,别每轮唠叨。
|
package/lib/presence.js
CHANGED
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
* 也在 session/event 总线上;子会话 turn/end 报错时,把错误原因记下来,
|
|
18
18
|
* 在她下一次开口的[状态]里附上一段,告诉她派出去的活为什么断了
|
|
19
19
|
* (宿主结算消息只有一句"failed before it finished",原因要自己看子会话)。
|
|
20
|
+
* 6. 💡 关闭思考建议:新会话首次对话时,如果当前模型支持"关闭思考"
|
|
21
|
+
* (有 off 思考档位)且还没关掉,就提醒她劝用户去模型选项里选"关闭思考"
|
|
22
|
+
* (日常闲聊用不上深度思考,回复更快、更省 token);每个会话只提醒一次。
|
|
20
23
|
*
|
|
21
24
|
* 只在 aiyayi 预设作用域挂载;她的子智能体(standard/worker 预设)不受影响。
|
|
22
25
|
* 新注册的工具是 scoped 的,不受 restrict 掩码影响(掩码只动全局继承面)。
|
|
@@ -68,6 +71,29 @@ const childFailures = new Map()
|
|
|
68
71
|
/** 已经透传过的 childSessionId(同一断因不重复念叨)。 */
|
|
69
72
|
const childFailuresReported = new Set()
|
|
70
73
|
|
|
74
|
+
/* ------------------------------------------------------------------ *
|
|
75
|
+
* 💡 关闭思考建议(新会话首次对话只提醒一次)。
|
|
76
|
+
* ------------------------------------------------------------------ */
|
|
77
|
+
|
|
78
|
+
/** 已经给过"关闭思考"建议的 sessionId(同一会话不重复提醒)。 */
|
|
79
|
+
const thinkingSuggestedSessions = new Set()
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 判断当前模型是否支持"关闭思考"(reasoning 档位里有 off)。
|
|
83
|
+
* @returns {Promise<boolean|null>} true=支持 / false=不支持 / null=拿不到信息(此时不打扰)。
|
|
84
|
+
*/
|
|
85
|
+
async function modelSupportsThinkingOff(provider, model, ctx) {
|
|
86
|
+
if (!provider || !model) return null
|
|
87
|
+
try {
|
|
88
|
+
const info = await ctx?.llm?.resolveModelInfo?.(provider, model)
|
|
89
|
+
const efforts = info?.reasoning?.efforts
|
|
90
|
+
if (!Array.isArray(efforts)) return null
|
|
91
|
+
return efforts.some((e) => e && e.id === 'off')
|
|
92
|
+
} catch {
|
|
93
|
+
return null
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
71
97
|
/**
|
|
72
98
|
* 子会话断因回放:会话不在 agentsById 里、但 header 表明是子智能体
|
|
73
99
|
* (origin==="subagent" 或带 parentSession)时,把它 turn/end 的报错记下来。
|
|
@@ -506,7 +532,39 @@ export function apply(ctx) {
|
|
|
506
532
|
|
|
507
533
|
const reunion = renderReunion(previous, now)
|
|
508
534
|
const childFails = renderChildFailures(sessionId)
|
|
509
|
-
|
|
535
|
+
|
|
536
|
+
// 💡 关闭思考建议:新会话首次对话、模型支持"关闭思考"且当前没关时,提醒一次。
|
|
537
|
+
let thinkingTip = ''
|
|
538
|
+
if (sessionId && !thinkingSuggestedSessions.has(sessionId)) {
|
|
539
|
+
let cfg = v.config
|
|
540
|
+
if (!cfg) {
|
|
541
|
+
try {
|
|
542
|
+
const h = agent?.session?.requestHeader?.()?.config
|
|
543
|
+
if (h?.provider && h?.model) {
|
|
544
|
+
cfg = { provider: String(h.provider), model: String(h.model), reasoningEffort: h.reasoningEffort }
|
|
545
|
+
}
|
|
546
|
+
} catch {
|
|
547
|
+
/* 拿不到就算了 */
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
const provider = cfg?.provider
|
|
551
|
+
const model = cfg?.model
|
|
552
|
+
const effort = cfg?.reasoningEffort
|
|
553
|
+
if (provider && model && effort !== 'off' && effort !== 'none') {
|
|
554
|
+
// 显式选了一个思考档位 → 该模型必有 off 档(pi-ai 校验规则);
|
|
555
|
+
// 没显式设置时用 resolveModelInfo 探测(拿不到信息就不打扰)。
|
|
556
|
+
const supportsOff =
|
|
557
|
+
typeof effort === 'string' && effort.length > 0
|
|
558
|
+
? true
|
|
559
|
+
: (await modelSupportsThinkingOff(provider, model, ctx)) === true
|
|
560
|
+
if (supportsOff) {
|
|
561
|
+
thinkingSuggestedSessions.add(sessionId)
|
|
562
|
+
thinkingTip = `💡 小建议:当前模型(${provider}/${model})支持"关闭思考"——日常闲聊用不上深度思考,可以在模型选项里选"关闭思考",回复更快也更省 token。`
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
const sections = [reunion, vitals.changed ? vitals.text : '', reminder, thinkingTip, childFails].filter(Boolean)
|
|
510
568
|
if (sections.length > 0) {
|
|
511
569
|
return {
|
|
512
570
|
...decision,
|