Skip to content

普通对话补齐思考转发开关#830

Open
buyun14 wants to merge 8 commits intoikechan8370:v3from
buyun14:v3
Open

普通对话补齐思考转发开关#830
buyun14 wants to merge 8 commits intoikechan8370:v3from
buyun14:v3

Conversation

@buyun14
Copy link
Copy Markdown

@buyun14 buyun14 commented Mar 10, 2026

提交 1:给普通对话补齐思考转发开关

  1. 新增配置项 basic.sendReasoning,用于控制 @/前缀触发的普通对话是否发送“思考过程”转发。
    config.js
  2. 普通对话发送链路接入该开关,分别拦截:
  • 工具调用回调中的转发
  • 最终回复中的转发
    chat.js
  1. 新增管理指令(主人权限):
  • #chatgpt开启思考转发
  • #chatgpt关闭思考转发
    并在 #chatgpt状态 中展示普通对话与伪人模式两种转发开关状态。
    management.js
  1. 更新文档:配置示例与命令说明。
    README.md

提交 2:修复“命令显示已关闭但仍开启/仍转发”的根因

  1. 增加统一布尔解析工具 parseBooleanFlag,避免 "false" 这类字符串被 JS 当成真值。
    common.js
  2. 将普通对话转发判断改为严格布尔解析(不再直接依赖 truthy/falsy)。
    chat.js
  3. 伪人模式同样改为严格布尔解析,并补上 onMessageWithToolCall 路径的开关判断一致性。
    bym.js
  4. 修复 toYunzai 在多段 reasoning 合并时返回字段错误(newForward -> forward)。
    message.js
  5. 修复配置持久化关键问题:startSync 返回的代理对象重新绑定回全局配置实例,确保嵌套字段赋值可触发落盘。
    index.js
  6. 管理命令切换后强制 saveToFile('code') 并打印日志;#chatgpt状态 展示改为严格布尔解析,避免误报“开启”。
    management.js
  • 之前出现“命令回复已关闭,但状态仍显示开启/仍发送思考转发”,根因是“配置布尔值可能以字符串形态参与判断 + 配置代理未正确接回导致嵌套改动不稳定落盘”。本次两次提交分别完成“功能补齐”和“稳定性修复”。

Copilot AI review requested due to automatic review settings March 10, 2026 10:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 为“普通对话”补齐并修复“思考/推理过程转发”开关:新增 basic.sendReasoning 配置与管理指令,并通过统一的布尔解析工具修复“显示已关闭但仍转发”的根因,同时修正配置持久化与转发字段返回问题。

Changes:

  • 新增并接入普通对话思考过程转发开关(含管理指令与状态展示)
  • 引入 parseBooleanFlag 统一布尔解析,修复字符串布尔导致的开关误判,并补齐 bym 工具回调路径一致性
  • 修复配置代理回绑定以增强嵌套字段落盘稳定性;修复 toYunzai 多段 reasoning 合并返回字段

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
utils/message.js 修复多段 reasoning 合并时返回字段,统一为 forward
utils/common.js 新增 parseBooleanFlag 用于严格解析布尔开关
models/memory/extractor.js 增强异常日志,输出 API 细节字段
index.js startSync 返回的代理对象回绑定到全局配置实例,提升嵌套写入落盘稳定性
config/config.js 新增 basic.sendReasoning 配置项(同时涉及 enableGroupContext 默认值变更)
apps/management.js 新增普通对话思考转发开关命令;状态展示加入普通对话/伪人开关状态
apps/chat.js 普通对话链路中对工具回调与最终回复的 reasoning 转发增加开关拦截
apps/bym.js 伪人模式对 reasoning 转发判断改为严格布尔解析,并补齐工具回调路径开关判断
README.md 更新配置示例与命令说明

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +254 to +257
const detail = err?.error ?? err?.body ?? err?.response ?? err?.cause
if (detail) {
logger.error('Failed to extract group facts (API detail):', typeof detail === 'object' ? JSON.stringify(detail) : detail)
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在 catch 里对 detailJSON.stringify(detail) 可能因为循环引用(常见于 HTTP client 的 response/error 对象)而再次抛错,导致本应吞掉并返回 [] 的异常反而向外抛出。建议改为安全序列化(try/catch 包裹 stringify、或使用 util.inspect/safe-stringify)。

Copilot uses AI. Check for mistakes.
Comment on lines +307 to +310
const detail = err?.error ?? err?.body ?? err?.response ?? err?.cause
if (detail) {
logger.error('Failed to extract user memories:', typeof detail === 'object' ? JSON.stringify(detail) : detail)
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里同样在 catch 中 JSON.stringify(detail) 可能因循环引用再次抛错,改变函数原本“捕获错误并返回 []”的行为。建议使用安全序列化方式(try/catch 包裹 stringify、或使用 util.inspect/safe-stringify)。

Copilot uses AI. Check for mistakes.
Comment thread config/config.js
blockWordMask: '***',
// 是否开启群组上下文
enableGroupContext: false,
enableGroupContext: true,
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enableGroupContext 默认值从 false 变成了 true,会导致群聊默认注入上下文(token/费用/隐私暴露面都会增加)。PR 描述未提及该行为变更;如果不是刻意修改,建议恢复为原默认值或在 PR 描述/文档中明确说明。

Copilot uses AI. Check for mistakes.
Comment thread apps/chat.js
Comment on lines +57 to 61
if (parseBooleanFlag(Config.basic.sendReasoning, true)) {
for (let forwardElement of forward) {
this.reply(forwardElement)
}
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的 parseBooleanFlag(Config.basic.sendReasoning, true) 会在配置值为 undefined/null/无法识别字符串 时回退为 true,与 config.jsbasic.sendReasoning 默认值 false 不一致,可能导致用户配置异常时仍然转发思考过程。建议回退值改为 false(或不传 defaultValue)。

Copilot uses AI. Check for mistakes.
Comment thread apps/chat.js
Comment on lines +123 to 127
if (parseBooleanFlag(Config.basic.sendReasoning, true)) {
for (let forwardElement of forward) {
this.reply(forwardElement)
}
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的 parseBooleanFlag(Config.basic.sendReasoning, true)basic.sendReasoning 的默认值 false 不一致;当配置值为 undefined/null/非法字符串 时会错误地按开启处理。建议将回退值改为 false(或不传 defaultValue)。

Copilot uses AI. Check for mistakes.
Comment thread apps/management.js
Comment on lines +168 to +170
const chatReasoningEnabled = parseBooleanFlag(ChatGPTConfig.basic.sendReasoning, true)
const bymReasoningEnabled = parseBooleanFlag(ChatGPTConfig.bym.sendReasoning, false)
msgs.push(`普通对话思考过程转发:${chatReasoningEnabled ? '开启' : '关闭'}\n伪人思考过程转发:${bymReasoningEnabled ? '开启' : '关闭'}`)
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

状态展示这里 parseBooleanFlag(ChatGPTConfig.basic.sendReasoning, true) 在配置值异常(undefined/null/非法字符串)时会回退为开启,可能造成“状态显示开启但实际应为关闭”的误报。建议与配置默认值保持一致(回退为 false 或不传 defaultValue)。

Copilot uses AI. Check for mistakes.
buyun14 added 6 commits April 14, 2026 12:03
- 添加authKey变更时的空值检查和重复性验证
- 改进配置合并过程中对authKey的处理逻辑
- 增加当前认证密钥的备份和恢复机制
- 避免不必要的全局配置同步操作

refactor(package): 更新项目依赖包版本

- 升级better-sqlite3从9.4.3到12.8.0版本
- 新增puppeteer相关依赖用于浏览器自动化
- 添加turndown依赖用于HTML到Markdown转换功能
添加了完整的 MCP (Model Context Protocol) 兼容层实现,支持将 MCP
工具动态桥接为 Chaite CustomTool。新增 mcp 配置项,包括启用状态、
工具名称前缀、服务器配置等。实现了 MCP 客户端连接管理、工具路由注
册、桥接工具创建等功能。同时更新了配置文件结构和初始化流程以集成新的 MCP 功能模块。
- 引入initMcpCompatibility函数用于初始化MCP兼容性
- 支持stdio和streamable-http两种传输类型
- 添加环境变量占位符解析功能
- 增加服务器ID和启用状态标准化处理
- 在管理插件中添加刷新MCP工具命令
- 实现MCP工具的动态加载和桥接功能
- 新增normalizeSchemaTypeName函数用于将类型名称标准化为标准JSON Schema类型,
如bool转为boolean,int转为integer,float/double转为number。

- 新增normalizeJsonSchema函数递归处理整个JSON Schema对象,
确保所有类型定义都被正确标准化。构建桥接工具代码时使用标准化后的schema。
启动时不清理旧桥接工具,避免触发工具文件频繁 unlink/rescan 日志刷屏问题。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants