refactor(session): 从 runtime 完全拆分会话模块并统一收口到 internal/session#187
Merged
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
refactor(provider):拆分type和openai
Member
|
@Yumiue 解决下代码冲突的问题 |
Collaborator
|
internal/session/store.go:31 这里把 Workdir 继续排除在持久化之外,而 internal/runtime/runtime.go:395 到 internal/runtime/runtime.go:453 仍然用进程内 map 维护它。这样这次“session 完全收口到 internal/session”在行为上还没有完成,重启后 session cwd 还是会丢。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
为明确模块边界并降低
runtime层职责复杂度,本次将会话相关能力从runtime彻底拆分,统一收口到独立的internal/session模块。目标是让主链路保持稳定的前提下,实现:
runtime聚焦 ReAct 主循环与事件编排session统一承载会话模型与持久化实现runtime导出的会话模型类型主要改动
1. 新增独立会话模块
internal/session新增并落地会话相关核心能力:
SessionSummaryStoreJSONStoreNew/NewWithWorkdirNewStore/NewJSONStoreNewIDinternal/session/store_test.go2.
runtime侧彻底去除会话实现与兼容层internal/runtime/session.gointernal/runtime/id.gointernal/runtime/session_test.go(测试已迁移到internal/session)并将
runtime内会话相关引用统一切换为internal/session:Runtime接口返回值改为agentsession.Session/[]agentsession.SummaryService.sessionStore改为agentsession.Storecompact路径中的会话类型改为agentsession.Session3. 应用装配层直接依赖
session模块在
internal/app/bootstrap.go中:agentsession.NewStore(loader.BaseDir())4. TUI 与测试类型统一收口
同步更新
tui与 runtime/tui 测试中的会话类型引用:agentruntime.Session/agentruntime.SessionSummaryagentsession.Session/agentsession.Summary5. 文档同步
README.mdinternal/runtime不再导出会话模型与存储类型internal/session为会话统一归属层docs/session-persistence-design.mdSummary命名说明New Session职责边界说明(结果)
runtime:会话保存时机、循环编排、事件派发session:会话模型、存储抽象、持久化实现tui:仅消费 runtime 暴露数据,不直接做持久化验证情况
已执行并通过以下关键测试:
go test ./internal/session ./internal/runtime ./internal/app ./internal/tui/statego test ./internal/tui -run TestRunSessionWorkdirCommandBranches -count=1影响面与兼容性
runtime、app、tui、文档与相关测试runtime到session的彻底迁移;后续新增会话存储能力应仅在internal/session内扩展并通过接口注入runtime