Skip to content

fix(storage): 优化 SQL 存储兼容性#60

Merged
weimch merged 1 commit into
mainfrom
bugfix/sql_error
May 12, 2026
Merged

fix(storage): 优化 SQL 存储兼容性#60
weimch merged 1 commit into
mainfrom
bugfix/sql_error

Conversation

@raychen911
Copy link
Copy Markdown
Contributor

  • 新增通用的 Content 清理逻辑,在 SQL Session 和 Memory 存储读写时过滤空的 Content Part。
  • 修复 MySQL 下 DynamicPickleType 写入 LONGBLOB 时未序列化导致的类型错误。
  • 支持通过 sessionmaker_kwargs 向 SqlStorage 传递 sessionmaker 配置,例如 expire_on_commit。
  • 将 SQL Session 中显式更新 update_time 的逻辑改为使用 datetime.now(),避免 func.now() 带来的 ORM 状态问题。
  • 统一通过当前事件循环创建 Session 和 Memory 服务的清理任务。
  • 优化 SQL Session 示例输出,在助手回复前打印用户问题。
  • 在 SQL Memory/Session 示例中关闭 thinking 输出,使演示结果更清晰。
  • 增加 SQL Content 清理和 MySQL DynamicPickleType 序列化相关测试。

@raychen911 raychen911 force-pushed the bugfix/sql_error branch 3 times, most recently from 9e0117b to d288007 Compare May 12, 2026 02:36

self.__cleanup_stop_event = asyncio.Event()
self.__cleanup_task = asyncio.create_task(self._cleanup_loop())
self.__cleanup_task = asyncio.get_event_loop().create_task(self._cleanup_loop())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

这是兼容python314的改动吗?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

如果协程没启动,使用asyncio.create_task会报错,换成这个asyncio.get_event_loop就不会报错,这个是是构建协程任务投递,在初始化的时候调用,此时协程还没有运行

)
if event.content:
storage_event.content = event.content.model_dump(exclude_none=True, mode="json")
storage_event.content = sanitize_content_json(event.content.model_dump(exclude_none=True, mode="json"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

没看懂这个content为空会导致啥问题

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

当出现error的时候这个Content为空会导致校验失败

- 新增通用的 Content 清理逻辑,在 SQL Session 和 Memory
  存储读写时过滤空的 Content Part。
- 修复 MySQL 下 DynamicPickleType 写入 LONGBLOB
  时未序列化导致的类型错误。
- 支持通过 sessionmaker_kwargs 向 SqlStorage 传递 sessionmaker
  配置,例如 expire_on_commit。
- 将 SQL Session 中显式更新 update_time 的逻辑改为使用
  datetime.now(),避免 func.now() 带来的 ORM 状态问题。
- 统一通过当前事件循环创建 Session 和 Memory 服务的清理任务。
- 优化 SQL Session 示例输出,在助手回复前打印用户问题。
- 在 SQL Memory/Session 示例中关闭 thinking 输出,使演示结果更清晰。
- 增加 SQL Content 清理和 MySQL DynamicPickleType 序列化相关测试。
@weimch weimch merged commit f83ef6a into main May 12, 2026
5 checks passed
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