Skip to content

Commit 3eba8a8

Browse files
author
龚震宇
committed
fix: update __internal metadata value to string in checkpoint and task status
1 parent 21c2c09 commit 3eba8a8

6 files changed

Lines changed: 40 additions & 8 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# 计划:checkpoint 统一使用字符串 "true"
2+
3+
- 调整 `checkpoint_metadata()` 写入 `__internal="true"`
4+
- 简化 `checkpoint_filters()` 回到仅字符串过滤
5+
- 移除本地二次过滤与相关兼容函数
6+
- 同步修正同步/异步加载逻辑
7+
- 更新单元测试断言以匹配字符串写入
8+
9+
文件清单:
10+
- `utils/checkpoint.py`
11+
- `tests/unit/utils/test_checkpoint.py`
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# 计划:修复检查点过滤导致的回读失败
2+
3+
- 阅读 `utils/checkpoint.py` 中过滤与加载逻辑,定位过滤条件与测试不一致点
4+
- 调整 `checkpoint_filters()`,避免对 `__internal` 进行过于严格的服务端过滤
5+
-`_load_items()` 中增加本地二次过滤,兼容 `True`/`"true"` 等格式
6+
- 同步修改异步加载路径,确保行为一致
7+
- 保持返回结构不变,只修复匹配逻辑以通过现有测试
8+
- 完成后检查相关文件的 lint 提示
9+
10+
文件清单:
11+
- `utils/checkpoint.py`
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# 计划:统一任务状态的 __internal 过滤兼容性
2+
3+
- 阅读 `utils/task_status.py` 的保存/加载流程,确认过滤路径
4+
- 调整 `task_status_filters()` 参数化 `__internal` 条件,避免过度依赖字符串格式
5+
- 在加载与存在性检查中增加本地二次过滤,兼容 True/"true"
6+
- 同步处理同步与异步管理器,确保行为一致
7+
- 更新单元测试以匹配新的过滤行为
8+
9+
文件清单:
10+
- `utils/task_status.py`
11+
- `tests/unit/utils/test_task_status_filters.py`
12+

tests/unit/utils/test_checkpoint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def delete(self, memory_id: str) -> dict[str, Any]:
9090

9191
def test_checkpoint_metadata_shape() -> None:
9292
md = checkpoint_metadata()
93-
assert md["__internal"] is True
93+
assert md["__internal"] == "true"
9494
assert md["internal_type"] == "checkpoint"
9595
assert md["version"] == CHECKPOINT_VERSION
9696

@@ -125,7 +125,7 @@ def test_save_checkpoint_add_and_update(monkeypatch: pytest.MonkeyPatch) -> None
125125
assert ok is True
126126
assert new_id is not None
127127
assert mem.added
128-
assert mem.added[0]["metadata"]["__internal"] is True
128+
assert mem.added[0]["metadata"]["__internal"] == "true"
129129
assert mem.added[0]["user_id"] == "u1"
130130
assert mem.added[0]["agent_id"] is None
131131

utils/checkpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
def checkpoint_metadata() -> dict[str, Any]:
3535
return {
36-
"__internal": True,
36+
"__internal": "true",
3737
"internal_type": "checkpoint",
3838
"version": CHECKPOINT_VERSION,
3939
}

utils/task_status.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ExtractionTaskStatus:
5151
def task_status_metadata(*, task_id: str) -> dict[str, Any]:
5252
"""Build metadata for task status storage."""
5353
return {
54-
"__internal": True,
54+
"__internal": "true",
5555
"internal_type": "extraction_task",
5656
"version": TASK_STATUS_VERSION,
5757
"task_id": task_id,
@@ -164,10 +164,8 @@ def load(
164164
user_id=TASK_STATUS_USER_ID, limit=1, filters=filters
165165
)
166166
items = result.get("results", []) if isinstance(result, dict) else []
167-
168167
if not items or not isinstance(items, list) or not items:
169168
return None, None
170-
171169
item = items[0]
172170
memory_id = str(item.get("id") or "").strip() or None
173171
raw = str(item.get("memory") or item.get("text") or "").strip()
@@ -394,10 +392,8 @@ async def load(
394392
user_id=TASK_STATUS_USER_ID, limit=1, filters=filters
395393
)
396394
items = result.get("results", []) if isinstance(result, dict) else []
397-
398395
if not items or not isinstance(items, list) or not items:
399396
return None, None
400-
401397
item = items[0]
402398
memory_id = str(item.get("id") or "").strip() or None
403399
raw = str(item.get("memory") or item.get("text") or "").strip()

0 commit comments

Comments
 (0)