Skip to content

Releases: Qixuan112/Tale-AI-legacy

Tale-AI v0.20.0 - StandardPipeline 架构重构完成

Choose a tag to compare

@Qixuan112 Qixuan112 released this 04 Aug 04:59

Tale-AI v0.20.0 - StandardPipeline 架构重构完成

重大更新

StandardPipeline 系统(Issue #180)

将 250 行单体消息处理函数重构为 9 个独立 Stage:

  1. BuildUserInputStage - 用户输入格式化
  2. NameMappingStage - 昵称→ID 映射
  3. SessionInitStage - 会话初始化
  4. ContextBuildStage - 上下文构建
  5. LLMCallStage - LLM 调用(支持 ChatLLM/ChatAgent)
  6. MessageParseStage - XML 解析 + 三路 fallback
  7. ToolExecuteStage - 工具执行 + Agent 多轮循环
  8. ReplyDeliverStage - 消息发送 + 跨会话推送
  9. HistorySaveStage - 持久化 + inbox ack

Feature Flag 灰度系统(Issue #183 P0)

  • 新增 use_pipeline 配置项(默认 false)
  • 支持运行时切换 Legacy ⇄ Pipeline 路径
  • 零风险灰度部署 + 一键回滚

P0 修复

  • 并发控制(Semaphore + per-session lock)
  • ContextBuilder 初始化
  • 文件发送失败通知

技术指标

  • 代码量:+2500 行(实现 + 测试 + 文档)
  • 测试覆盖:170 个测试(100% 通过)
  • 质量保证:5 个 Opus 5 审查 + 2 轮 CodeRabbit
  • 性能提升:2/10 → 8/10
  • 安全性:6/10 → 9/10

使用方式

默认行为(安全):

# data/config/behavior.yaml
use_pipeline: false  # 使用旧版流程

启用 Pipeline(灰度):

use_pipeline: true  # 使用 StandardPipeline

或环境变量:

export TALE_USE_PIPELINE=true

灰度建议

详见 PIPELINE_MIGRATION.md:

  1. Day 1-2: 本地测试验证
  2. Day 3-4: 10% 生产流量
  3. Day 5-6: 50%
  4. Day 7+: 100%

相关资源

注意事项

  • 默认 use_pipeline: false,保持现有行为不变
  • 建议灰度验证后再 100% 切换
  • 回滚方式:设置 use_pipeline: false

完成阶段 1-4 架构重构,系统生产就绪!

Tale-AI v0.17.0

Choose a tag to compare

@Qixuan112 Qixuan112 released this 03 Aug 09:30
a8a0e4c

Tale-AI v0.17.0

🏗️ 架构重构(Issue #170)

阶段1:责任链模式(MessageHandler)

  • 新增 core/handler/ 模块(353行)
  • PermissionHandler:黑白名单权限检查
  • WakeWordHandler:@机器人、唤醒词、引用回复检测
  • QuoteReplyHandler:引用消息检测
  • 86 个单元测试,99% 覆盖率

阶段2:上下文构建模块(ContextBuilder)

  • 新增 core/chat/context_builder/ 模块(497行)
  • ContextBuilder:上下文组装
  • MetadataBuilder:元数据构建(ID脱敏)
  • MediaRecognizer:图片识别(3s超时保护)
  • HistoryProvider:历史记录加载
  • 修复纯图消息无上下文问题(Issue #8)
  • 58 个单元测试,96% 覆盖率

阶段3:ChatAgent 并发控制(P0核心)

  • 新增 core/agent/ 模块(331行)
  • Per-session lock:同一用户串行,不同用户并发
  • Semaphore(3):全局最大并发限制
  • 移除全局 _chat_lock(性能提升 3x)
  • 超时保护:所有 LLM 调用增加 60s 超时
  • 33 个真实执行测试(首次真实验证)
  • 性能验证:3用户并发 0.51s(原 ~1.5s)

🔧 CI/CD

  • 新增 GitHub Actions 自动化测试(Python 3.10/3.11/3.12)

📊 统计数据

  • 15 个 commits
  • 84 个文件变更
  • +13009 / -440 行代码

Tale-AI v0.17.0 - Architecture Refactoring

🏗️ Architecture Refactoring (Issue #170)

Stage 1: Handler Chain Pattern

  • New core/handler/ module (353 lines)
  • PermissionHandler: allow/deny list permission checking
  • WakeWordHandler: @bot, wake word, quote reply detection
  • QuoteReplyHandler: quoted message detection
  • 86 unit tests, 99% coverage

Stage 2: Context Builder Modules

  • New core/chat/context_builder/ module (497 lines)
  • ContextBuilder: context assembly
  • MetadataBuilder: metadata with ID sanitization
  • MediaRecognizer: image recognition (3s timeout)
  • HistoryProvider: history loading
  • Fixed pure-image message without context (Issue #8)
  • 58 unit tests, 96% coverage

Stage 3: ChatAgent Concurrency Control (P0)

  • New core/agent/ module (331 lines)
  • Per-session lock: serial per user, concurrent across users
  • Semaphore(3): global concurrency limit
  • Removed global _chat_lock (3x performance gain)
  • Timeout protection: 60s timeout on all LLM calls
  • 33 real executed tests (first real verification)
  • Performance: 3 users concurrent 0.51s (was ~1.5s)

🔧 CI/CD

  • Added GitHub Actions automated tests (Python 3.10/3.11/3.12)

📊 Statistics

  • 15 commits
  • 84 files changed
  • +13,009 / -440 lines of code

Tale-AI v0.16.0 - 架构优化与性能提升

Choose a tag to compare

@Qixuan112 Qixuan112 released this 30 Jul 08:58
f159df4

Tale-AI v0.16.0

核心更新

Prompt 系统大规模优化

  • 精简 prompt 示例从 574 行到 423 行,减少 26% token 消耗
  • 统一 few-shot 示例格式,提升 AI 理解一致性
  • 优化 user_input 结构,增强 AI 解析清晰度
  • 删除低频 <tool> 标签,简化输出格式
  • 统一 <msg> 标签说明文档

工具系统架构重构

  • 统一工具注册机制,handler 纳入 ToolRegistry
  • 新增统一的工具调用日志和统计功能
  • ToolLLM 支持独立配置,可 fallback 到 plan_llm

性能与稳定性改进

  • 使用 BoundedCache 替换无界 dict,防止内存泄漏
  • 优化 today_plan 位置,启用 prompt 缓存
  • 修复 EventBus 事件序列化问题

视觉能力增强

  • 消息包含图片时自动使用 VLM 识别,无需额外配置

安全性修复

  • 消息元数据 ID 脱敏处理(P0 优先级)

测试覆盖提升

  • 新增 Phase 1 完整测试套件
  • 新增 17 个事件序列化测试
  • 提升核心功能测试覆盖率

统计数据

  • 21 个 commits
  • 25 个文件变更
  • +3659 / -453 行代码
  • 6 个新功能,6 个修复,5 个文档更新

Tale-AI v0.16.0 - Architecture Optimization & Performance Enhancement

Core Updates

Massive Prompt System Optimization

  • Reduced prompt examples from 574 to 423 lines (26% token reduction)
  • Unified few-shot example format for better AI consistency
  • Optimized user_input structure for clearer AI parsing
  • Removed low-frequency <tool> tags to simplify output format
  • Unified <msg> tag documentation

Tool System Architecture Refactor

  • Unified tool registration with handlers integrated into ToolRegistry
  • Added unified tool call logging and statistics
  • ToolLLM now supports independent configuration with fallback to plan_llm

Performance & Stability Improvements

  • Replaced unbounded dict with BoundedCache to prevent memory leaks
  • Optimized today_plan placement to enable prompt caching
  • Fixed EventBus event serialization issues

Vision Capability Enhancement

  • Automatic VLM recognition for messages with images, no extra config needed

Security Fixes

  • Sanitized message metadata IDs (P0 priority)

Test Coverage Improvements

  • Added complete test suite for Phase 1
  • Added 17 event serialization tests
  • Improved core functionality test coverage

Statistics

  • 21 commits
  • 25 files changed
  • +3,659 / -453 lines of code
  • 6 features, 6 fixes, 5 documentation updates

Tale-AI v0.15.0

Choose a tag to compare

@Qixuan112 Qixuan112 released this 27 Jun 02:55
34b4219

批量修复 — 安全/正确性/健壮性

由 @LyaQanYi 贡献的批量修复 PR #116,覆盖安全、正确性、健壮性、并发四类共约 25 处问题。Closes #97, #100, #101, #109, #110, #111, #112, #113, #114, #115。

安全

  • SSRF 加固: 多 A 记录任一私网即拒,连接固定到校验 IP(thread-local pin,线程安全),逐跳重校验重定向;browser.py 与 main.py 图片下载均改用安全请求
  • workspace 沙箱: 参数校验扩展到选项内联路径,子进程最小化环境,白名单移除 make/git/sed/env 等可任意执行命令
  • 插件安全: 禁用插件延迟导入,拒绝自定义插件顶替内置插件 id
  • 计算器 DoS: 限制幂运算指数/底数/结果位数

适配器

  • 微信去重集合改 OrderedDict,心跳按本地收包时刻计时
  • 微信 send_message 仅在真正发出内容时返回 True
  • QQ 指纹去重加入分钟级时间桶;is_bot 消息直接 IGNORE
  • stop_adapter 索引/实例清理移入 finally

LLM / 配置

  • get_active_provider 非 LLM 类型返回 None
  • parse_function_call 增加 isinstance 守卫
  • toolllm 为 None 时降级提示
  • 会话迁移容忍字符串型 chunk
  • context 动态段强制不可缓存

并发 / 跨会话

  • ChatLLM 全局锁覆盖整段临界区
  • pending 超时改按入队时刻判定
  • 新增空闲 sid 淘汰(含孤儿锁回收)
  • 跨会话失败反馈改走 add_system_message

其他

  • 日程跨天处理、HH:MM 严格校验
  • OpenAIEmbedder 兼容不支持 dimensions 的第三方端点
  • WebUI 日志 SSE 改 pub/sub 扇出 + 环形缓冲

Batch Fix — Security / Correctness / Robustness

Contributed by @LyaQanYi in PR #116, ~25 fixes across security, correctness, robustness, and concurrency. Closes #97, #100, #101, #109, #110, #111, #112, #113, #114, #115.

Security

  • SSRF hardening: reject if any A record is private, thread-local IP pinning, per-hop redirect re-validation; secure requests in browser.py and main.py image downloads
  • Workspace sandbox: extended arg validation to inline options, minimized subprocess env, removed make/git/sed/env from allowlist
  • Plugin safety: deferred import for disabled plugins, reject custom plugin overriding built-in IDs
  • Calculator DoS: bounded exponent/base/result for power operations

Adapters

  • WeChat dedup uses OrderedDict, heartbeat timed by local packet receipt
  • WeChat send_message returns True only on actual send
  • QQ fingerprint dedup with minute-level time bucket; is_bot messages IGNORE
  • stop_adapter index cleanup in finally block

LLM / Config

  • get_active_provider returns None for non-LLM types
  • parse_function_call with isinstance guard
  • Graceful fallback when toolllm is None
  • Session migration tolerates string chunks
  • Context dynamic sections forced non-cacheable

Concurrency / Cross-session

  • ChatLLM global lock covering full critical section
  • Pending timeout by enqueue time
  • Idle session eviction (with orphan lock reclamation)
  • Cross-session failure feedback via add_system_message

Others

  • Cross-day plan handling, strict HH:MM validation
  • OpenAIEmbedder compat with 3rd-party endpoints lacking dimensions support
  • WebUI log SSE switched to pub/sub fan-out + ring buffer

Tale-AI v0.13.4

Choose a tag to compare

@Qixuan112 Qixuan112 released this 21 Jun 08:47

v0.13.4 — 跨会话 sid 校验修复

修复

  • session_send 的 id 必须是纯数字群号/用户号,禁止群名/昵称/占位符
  • prompt 强调群号通过 query_group_list 工具获取(返回 group_id)
  • _send_cross_session 增加 target_id.isdigit() 校验,非数字拒绝并反馈源会话

文件变更

2 files changed


v0.13.4 — Cross-Session sid Validation Fix

Fixes

  • session_send id must be pure numeric group/user ID, names/nicknames/placeholders forbidden
  • Prompt emphasizes group ID obtained via query_group_list tool (returns group_id)
  • _send_cross_session adds target_id.isdigit() check, rejects non-numeric and feeds back to source session

File Changes

2 files changed

Tale-AI v0.13.3

Choose a tag to compare

@Qixuan112 Qixuan112 released this 21 Jun 02:02

v0.13.3 — 跨会话主动推送 + 群列表查询工具

新增

  • 跨会话消息改为主动推送:AI 输出 session_send 后机器人真实发送 QQ 消息,用户实时收到
  • 新增 query_group_list 工具:AI 可查询机器人加入的所有群聊列表(群号+群名)
  • 元数据注入发送者ID,AI 可构造正确的私聊 sid

修复

  • bridge.send 权限校验复用,主动推送不绕过安全策略
  • 推送成功后 ack 去重,避免目标会话 consume 重复注入
  • 推送失败时反向写系统消息到源会话反馈
  • prompt 增强:session_send 格式/示例/隐私约束,严禁输出真实 QQ 号

文件变更

3 files changed


v0.13.3 — Cross-Session Active Push + Group List Tool

New Features

  • Cross-session messages now actively pushed: AI session_send triggers real QQ message delivery, user receives in real-time
  • New query_group_list tool: AI can query all groups the bot joined (group ID + name)
  • Metadata injects sender_id, AI can construct correct DM sid

Fixes

  • Reuse bridge.send permission check, active push does not bypass security
  • ack after successful push prevents duplicate injection on consume
  • Failure feedback written back to source session inbox
  • Prompt enhanced: session_send format/example/privacy constraints, real QQ numbers forbidden in output

File Changes

3 files changed

Tale-AI v0.13.2

Choose a tag to compare

@Qixuan112 Qixuan112 released this 20 Jun 16:50

v0.13.2 — 跨会话桥接运行时修复

修复

  • 修复 bridge.py 导入路径错误(from ..utils 改为 .utils,core 是顶层包)
  • 补全 _send_cross_session 方法实现,含 30 秒超时和完整异常捕获

文件变更

1 file changed


v0.13.2 — Cross-Session Bridge Runtime Fixes

Fixes

  • Fixed bridge.py import path (from ..utils to .utils, core is top-level package)
  • Implemented _send_cross_session method with 30s timeout and full exception handling

File Changes

1 file changed

Tale-AI v0.13.1

Choose a tag to compare

@Qixuan112 Qixuan112 released this 20 Jun 12:53
c5feebd

v0.13.1 — 原生跨会话消息桥接 + 上下文管线修复

新增

  • 新增原生跨会话消息桥接模块 core/bridge.py
    • 跨会话消息收发(session_send),参考 KiraAI 设计
    • 两阶段提交 consume/ack,at-least-once 语义
    • UUID 去重(_processed FIFO 1000 + TTL 1h)
    • per-session asyncio.Lock 并发保护
    • 权限校验(同 adapter/同群组)
    • 速率限制(10 次/分钟)
    • 消息长度 500 字符上限,inbox 最多 20 条
  • parse_xml 支持 <session_send> 标签解析
  • prompt 添加 session_send 使用说明和会话列表注入

修复

  • 移除历史文本块重复注入,改为结构化 messages 历史
  • B1: Agent 多步工具调用后最终回复正确写入会话记忆
  • B2: 全局 ChatLLM 锁修复跨会话历史串味
  • B3: 朋友圈消息不再写入错误的会话记忆
  • B4: 上下文窗口逻辑改为正向布尔变量
  • 首次 chat() 调用传 save_to_session=False 消除双重写入

文件变更

5 files changed, 377 insertions(+), 68 deletions(-)


v0.13.1 — Native Cross-Session Bridge + Context Pipeline Fixes

New Features

  • Native cross-session message bridge module core/bridge.py
    • Cross-session messaging (session_send), inspired by KiraAI
    • Two-phase commit consume/ack, at-least-once semantics
    • UUID dedup (_processed FIFO 1000 + TTL 1h)
    • per-session asyncio.Lock concurrency protection
    • Permission validation (same adapter / same group)
    • Rate limiting (10 per minute)
    • Message length cap 500 chars, inbox max 20
  • parse_xml supports <session_send> tag
  • prompt adds session_send instructions and session list injection

Fixes

  • Removed duplicate history text block injection, use structured messages
  • B1: Final reply correctly persisted after multi-step tool calls
  • B2: Global ChatLLM lock fixes cross-session context contamination
  • B3: WeChat Moments no longer written to wrong session memory
  • B4: Context window logic uses positive boolean variable
  • First chat() call passes save_to_session=False to eliminate double-write

File Changes

5 files changed, 377 insertions(+), 68 deletions(-)

Tale-AI v0.13.0

Choose a tag to compare

@Qixuan112 Qixuan112 released this 20 Jun 05:32
5a19cc5

v0.13.0 — 会话管理系统 + 文生图增强 + 修复

新增

  • 添加会话管理系统(Session + SessionManager),参考 KiraAI 设计
  • 添加 WebUI 会话管理页面:查看/编辑/删除会话、切换启用/禁用、增改删单轮记忆
  • 会话历史持久化到 data/sessions/sessions.json,重启不丢失
  • 添加 persistence_enabled 配置开关,可回退旧模式
  • 日志文件自动轮转(5MB/3备份),防止无限膨胀

文生图

  • 拆分文生图为拍照(take_photo)与画画(draw_picture),内置风格润色
  • 新增火山方舟 Seedream 支持

安全修复

  • 修复 data-* 属性存储型 XSS
  • 单条记忆改用递增 id,消除 TOCTOU
  • 修复 enabled 读写双侧门控
  • 修复记忆污染:落库存纯净原文
  • 修复并发竞争:全局 RLock + 唯一临时文件

修复

  • AI 自主决定群聊 @/引用
  • QQ @ 后加空格
  • ChatLLM 集成 SessionManager
  • 中/英/日三语 i18n

文件变更

17 files changed, 1433 insertions(+), 38 deletions(-)


v0.13.0 — Session Management + Image Generation + Fixes

New Features

  • Session management system (Session + SessionManager), designed with reference to KiraAI
  • WebUI session management page: view/edit/delete sessions, toggle enable/disable, add/modify/delete memory
  • Session history persisted to data/sessions/sessions.json, survives restarts
  • Added persistence_enabled config flag to fallback to old mode
  • Log file auto-rotation (5MB/3 backups) to prevent unbounded growth

Image Generation

  • Split into take_photo and draw_picture with built-in style tuning
  • Added Volcengine Seedream support

Security Fixes

  • Fixed stored XSS via data-* attributes: added escapeAttr
  • Changed to incrementing chunk IDs, eliminating TOCTOU
  • Fixed double-sided gating for enabled sessions
  • Fixed memory pollution: stored pure original text
  • Fixed concurrency: global RLock + unique temp files

Fixes

  • AI autonomously decides @/reply in groups
  • Added space after QQ @
  • Integrated ChatLLM with SessionManager
  • Chinese/English/Japanese i18n

File Changes

17 files changed, 1433 insertions(+), 38 deletions(-)

Tale-AI v0.12.0

Choose a tag to compare

@Qixuan112 Qixuan112 released this 19 Jun 11:38
ed30b46

v0.12.0 — 2026-06-19

新功能

  • AI 发图能力(#104 阶段1):AI 可在回复中通过 <image> 标签发送图片(URL 或本地路径)。Message 增加 images 字段,parse_xml 解析 <image> 标签(主路径 + 降级回退),回复流程透传 images 到适配器,支持纯图片消息
  • AI 绘图能力(#104 阶段2):新增 ImageGenProvider 文生图 Provider(OpenAI/SiliconFlow 兼容)+ ImageGenerator 单例 + generate_image 工具,AI 可调用文生图并将结果通过 <image> 标签发出。FC 提示词工具列表改为从 registry 动态生成
  • AI 看图能力(#104 阶段3):修复 VLM 链路死代码(_ensure_client → _ensure_provider),收到图片先下载到 temp 再喂 VLM,支持针对性提问与多图联合推理
  • 图片描述缓存:按 MD5(图片字节 + 识别 prompt) 缓存 VLM 描述到 data/cache/image_desc.json,原子写 + 两阶段锁,避免重复调用

改进

  • QQ 适配器:图片 URL 过 SSRF 安全校验(复用 validate_url),本地路径转 base64:// 编码与部署拓扑解耦
  • ProviderManager:type 判断优先于 format,正确注册 image_gen 类型供应商
  • 配置:默认 routing.yaml 增加 image 字段,services.yaml 增加 image_gen provider 示例
  • 资源管理:文生图 base64 落盘改走 TempFileManager,24h 过期/100MB 上限自动清理
  • 体验:纯图片消息给基础打字延迟,避免瞬发

Bug 修复

  • #105:PlanLLM _extract_json 容错,修复日程解析死循环
  • #103:QQ 适配器启动 TypeError(_run_done 为 None)
  • #98 #99:WebSocket 适配器生命周期缺陷 + RAG 删除清空索引
  • 修复 integration.py 重复方法定义导致的 IndentationError
  • context window VLM 路径 offload 到线程池,修复事件循环阻塞与重复识别

v0.12.0 — 2026-06-19

New Features

  • AI Image Sending (#104 Phase 1): AI can send images via <image> tag in replies (URL or local path). Message gains images field, parse_xml parses <image> (main path + fallback), reply pipeline forwards images to adapter, pure-image messages supported
  • AI Image Generation (#104 Phase 2): New ImageGenProvider text-to-image provider (OpenAI/SiliconFlow compatible) + ImageGenerator singleton + generate_image tool. AI can generate images and send via <image> tag. FC prompt tool list now dynamically generated from registry
  • AI Image Recognition (#104 Phase 3): Fixed dead VLM code (_ensure_client → _ensure_provider), images downloaded to temp before VLM call, supports targeted questions and multi-image joint reasoning
  • Image Description Cache: VLM descriptions cached by MD5(image bytes + recognition prompt) in data/cache/image_desc.json, atomic writes + two-phase lock, avoiding repeated calls

Enhancements

  • QQ Adapter: Image URLs pass SSRF validation (reusing validate_url), local paths converted to base64:// encoding decoupled from deployment topology
  • ProviderManager: type check takes priority over format, correctly registering image_gen providers
  • Config: Default routing.yaml adds image field, services.yaml adds image_gen provider example
  • Resource Management: Text-to-image base64 landing now uses TempFileManager with 24h expiry / 100MB cap auto-cleanup
  • UX: Pure-image messages get base typing delay to avoid instant send

Bug Fixes

  • #105: PlanLLM _extract_json fault tolerance, fixes schedule parsing infinite loop
  • #103: QQ adapter startup TypeError (_run_done is None)
  • #98 #99: WebSocket adapter lifecycle defects + RAG delete clears index
  • Fixed IndentationError from duplicate method definition in integration.py
  • Context window VLM path offloaded to thread pool, fixes event-loop blocking and duplicate recognition