Skip to content

feat: 引用回复、Python 解释器增强与 Responses API 支持#47

Merged
69gg merged 21 commits intomainfrom
feature/reply-and-better-python
Mar 8, 2026
Merged

feat: 引用回复、Python 解释器增强与 Responses API 支持#47
69gg merged 21 commits intomainfrom
feature/reply-and-better-python

Conversation

@69gg
Copy link
Owner

@69gg 69gg commented Mar 7, 2026

功能概述

本 PR 新增消息引用回复、Python 解释器安全增强,并完整支持 OpenAI Responses API 传输层与配置系统改进。

主要变更

1. 消息引用回复 (reply_to)

  • 支持在发送消息时引用回复特定消息
  • send_messagesend_private_message 工具新增 reply_to 参数
  • 历史记录管理器支持记录被回复的消息 ID

2. Python 解释器增强与安全加固

  • 支持通过 libraries 参数安装第三方 Python 库(pip install)
  • 支持通过 send_files 参数发送容器内生成的文件(图片、数据文件等)
  • 安全加固:依赖安装与代码执行分离,用户代码在无网络、只读根文件系统的容器中运行
  • 路径穿越防护send_files 路径解析防止符号链接逃逸和目录穿越攻击

3. OpenAI Responses API 完整支持

  • 新增 openai_transport.py 实现 Responses API 传输层(流式/非流式)
  • 支持 api_mode = "responses" 配置切换传输协议
  • responses_tool_choice_compat:兼容模式,将字符串 tool_choice 转为 Responses 格式
  • responses_force_stateless_replay:强制无状态重放,tool call 后续轮次不依赖历史
  • 支持 reasoning 配置(o1/o3 系列推理模型)

4. 配置系统改进

  • 支持 request_params 自定义模型请求参数(temperature、top_p 等)
  • WebUI 配置模板同步:保留用户注释、合并新增字段、支持数组表格(pool models)
  • 多行字符串正确转义(TOML 三引号格式)
  • 模型池配置传递 responses_* 兼容标志

5. 其他优化

  • 消息发送器修复:正确提取嵌套 data.message_id 字段(OneBot 响应格式)
  • 史官和侧写提示词优化
  • reply_to 参数解析失败时静默忽略而非报错
  • 新增配置同步脚本 scripts/sync_config_template.py

测试覆盖

  • Python 解释器路径穿越防护测试
  • 消息 ID 提取测试(嵌套响应格式)
  • 模型池 responses 标志传递测试
  • 配置模板同步数组表格合并测试
  • LLM 请求参数构建测试
  • Responses API 运行时探测测试

破坏性变更

无。所有新功能默认关闭或向后兼容。

相关文档

  • docs/configuration.md:新增 Responses API 和 request_params 配置说明
  • scripts/README.md:新增配置同步脚本文档
  • AGENTS.md:更新 Agent 配置示例

Open with Devin

69gg and others added 17 commits March 4, 2026 18:49
打通 message_id 全链路:存储 → 暴露 → 发送。

- history.py: add_group/private_message 增加 message_id 可选参数
- handlers.py: 用户消息入历史时传入 trigger_message_id
- sender.py: 调整为先发送再写历史,提取 bot message_id;
  增加 reply_to 参数,在消息段开头插入 reply 段
- prompts.py: 历史消息 XML 标签增加 message_id 属性
- get_recent_messages/get_messages_by_time: XML 输出增加 message_id
- send_message/send_private_message: 新增 reply_to 工具参数

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 新增 libraries 参数:可选指定 pip 安装的第三方库列表,启用网络下载
- 新增 send_files 参数:代码执行成功后自动发送生成的文件给用户
- 图片文件通过 CQ 码内联发送,其他文件通过上传接口发送为附件
- 代码写入脚本文件执行,避免 shell 引号转义问题
- 库名正则校验防止 requirements.txt 注入(-r/-e/--index-url)
- 有库时内存上限 512m、超时 10 分钟;无库时保持原有安全限制

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…el configs

- python_interpreter: separate pip install (with network) from code
  execution (network=none, read-only), add path traversal protection
  for send_files via _resolve_output_host_path
- sender: extract _extract_message_id to handle nested data.message_id
  envelope from OneBot responses
- model_selector: pass responses_tool_choice_compat and
  responses_force_stateless_replay through pool model selection
- config_sync/toml_render: support array-of-tables (pool models) in
  template merge and comment augmentation
- Add tests for python interpreter handler, sender, model pool flags,
  and config sync pool model merging

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 9 additional findings.

Open in Devin Review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

69gg and others added 2 commits March 8, 2026 00:10
Handle Responses replies from gateways that return top-level output_text, preserve tool replay offsets after prefetch injection, and avoid racing temp cleanup with OneBot file reads while lowering container privileges.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

69gg and others added 2 commits March 8, 2026 10:40
Use the current host uid/gid for Docker bind mounts so the mounted temp directory remains accessible without opening it to world-writable permissions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@69gg 69gg merged commit 0be20a1 into main Mar 8, 2026
1 of 2 checks passed
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 18 additional findings in Devin Review.

Open in Devin Review

@69gg
Copy link
Owner Author

69gg commented Mar 8, 2026

Devin Review found 1 new potential issue.

View 18 additional findings in Devin Review.

Open in Devin Review

will be resolved in the next pr

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.

1 participant