feat(server): add database-backed persistence for task and runtime state#305
Draft
liujuanjuan1984 wants to merge 4 commits intomainfrom
Draft
feat(server): add database-backed persistence for task and runtime state#305liujuanjuan1984 wants to merge 4 commits intomainfrom
liujuanjuan1984 wants to merge 4 commits intomainfrom
Conversation
Collaborator
Author
|
本轮审查结论:实现方向合理, 发现 1 个需要明确的风险和 1 个非阻塞清理点:
除此之外,这个 PR 的 |
Collaborator
Author
|
已基于当前分支修掉上一轮审查里的两个点:
补充验证:
新增 commit:
|
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.
概要
实现
#304:为当前仓库引入可配置的 database-backed store,并将目前需要跨重启保留的核心业务状态接入同一持久化后端。改动模块
1. 配置与依赖
pyproject.tomluv.locksrc/opencode_a2a/config.py新增:
A2A_TASK_STORE_BACKENDA2A_TASK_STORE_DATABASE_URLA2A_TASK_STORE_TABLE_NAMEA2A_TASK_STORE_CREATE_TABLE补充
sqlalchemy/aiosqlite依赖,并在 database backend 下要求显式提供 database URL。说明:
A2A_TASK_STORE_CREATE_TABLE现在统一控制 database backend 下 task store table 与 runtime state tables 的自动创建。2. Task Store 装配
src/opencode_a2a/server/task_store.pysrc/opencode_a2a/server/application.py实现 task store builder,按配置选择:
InMemoryTaskStoreDatabaseTaskStore在 app lifespan 中负责初始化和释放 database-backed store / engine。
3. Session / Interrupt 状态持久化
src/opencode_a2a/runtime_state.pysrc/opencode_a2a/server/state_store.pysrc/opencode_a2a/execution/session_manager.pysrc/opencode_a2a/opencode_upstream_client.pysrc/opencode_a2a/execution/stream_runtime.pysrc/opencode_a2a/jsonrpc/application.pysrc/opencode_a2a/execution/executor.py新增 repository 抽象与 memory/database 双后端,接入:
4. 文档与测试
docs/guide.mdtests/server/test_task_store_factory.pytests/server/test_state_store.pytests/server/test_database_app_persistence.py新增覆盖:
A2A_TASK_STORE_CREATE_TABLE=false时不自动创建 state tables当前边界
仍保持进程内状态,不进入数据库:
验证
uv sync --all-extrasuv run pre-commit run --all-filesuv run pytest357 passed相关 commits
10573d5feat(server): add database-backed task store backend (#304)e51bc97feat(server): persist session and interrupt state in database backend (#304)3328523test(server): cover app restart persistence for database backend (#304)8a5889dfix(server): align database state tables with create-table config (#304)Closes #304
Relates to #264