From 4a453fa42ef9d7a5951de490de8007eac783c442 Mon Sep 17 00:00:00 2001 From: "mayunxiang.26" Date: Fri, 16 Oct 2026 12:41:15 +0800 Subject: [PATCH] fix(resource): report a queued reason commit as accepted Since #6077 on_resource_added returns once the reason commit is queued, but memory_linking.status still said "success", which reads as a finished link. It now says "accepted" (the word connector submissions already use), and the API docs say to poll commit_task_id for the result. Follow-up to the #6077 review. Co-Authored-By: Claude Opus 5.5 --- docs/en/api/02-resources.md | 2 +- docs/zh/api/02-resources.md | 2 +- openviking/service/resource_memory_link_service.py | 10 ++++++---- tests/service/test_resource_memory_link_service.py | 6 +++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/en/api/02-resources.md b/docs/en/api/02-resources.md index 74ad605f115..10d0d5138f6 100644 --- a/docs/en/api/02-resources.md +++ b/docs/en/api/02-resources.md @@ -622,7 +622,7 @@ task_id uuid-xxx | `errors` | array | List of errors encountered during processing | | `warnings` | array | Optional warnings, including partial processing or memory-linking failures | | `queue_status` | object | Queue summary when waiting synchronously or reading a completed task result; grouped by queue with `processed`, `requeue_count`, `error_count`, and `errors` | -| `memory_linking` | object | Optional result of linking the resource URI to memories generated from `reason` | +| `memory_linking` | object | Optional result of linking the resource URI to memories generated from `reason`. `status="accepted"` means the memory commit is queued, not finished: poll `commit_task_id` via `/api/v1/tasks/{task_id}` for its result | **Completed add-resource task result** diff --git a/docs/zh/api/02-resources.md b/docs/zh/api/02-resources.md index 9e4686cb566..4a56b6e2e22 100644 --- a/docs/zh/api/02-resources.md +++ b/docs/zh/api/02-resources.md @@ -621,7 +621,7 @@ task_id uuid-xxx | `errors` | array | 处理过程中的错误列表 | | `warnings` | array | 可选警告,包括部分处理失败或资源记忆关联失败 | | `queue_status` | object | 同步等待或已完成任务结果中的队列汇总,按队列返回 `processed`、`requeue_count`、`error_count` 和 `errors` | -| `memory_linking` | object | (可选,仅当 `reason` 触发记忆生成时)本次资源 URI 与用户记忆的关联结果 | +| `memory_linking` | object | (可选,仅当 `reason` 触发记忆生成时)本次资源 URI 与用户记忆的关联结果。`status="accepted"` 表示记忆提交已入队、尚未完成,需轮询 `/api/v1/tasks/{task_id}`(`commit_task_id`)获取结果 | **完成后的资源添加任务结果** diff --git a/openviking/service/resource_memory_link_service.py b/openviking/service/resource_memory_link_service.py index aa73a77c285..d28ac37dbe4 100644 --- a/openviking/service/resource_memory_link_service.py +++ b/openviking/service/resource_memory_link_service.py @@ -155,9 +155,11 @@ async def on_resource_added( ) -> Dict[str, Any]: """Queue add-resource reason extraction as a normal session commit. - Returns once the commit is queued. Every reason commit serializes on one - shared session, so waiting for it here held the caller behind all earlier - reason commits (one stalled commit could block resource ingestion). + Returns ``status="accepted"`` once the commit is queued; poll + ``commit_task_id`` through the Task API for its result. Every reason commit + serializes on one shared session, so waiting for it here held the caller + behind all earlier reason commits (one stalled commit could block resource + ingestion). """ reason = (reason or "").strip() if not reason: @@ -209,7 +211,7 @@ async def on_resource_added( ) return { - "status": "success", + "status": "accepted", "session_id": session_id, "commit_task_id": commit_result.get("task_id"), "archive_uri": commit_result.get("archive_uri"), diff --git a/tests/service/test_resource_memory_link_service.py b/tests/service/test_resource_memory_link_service.py index 51058a8f0ea..7136ca46d83 100644 --- a/tests/service/test_resource_memory_link_service.py +++ b/tests/service/test_resource_memory_link_service.py @@ -224,7 +224,7 @@ async def test_on_resource_added_bridges_reason_through_fixed_session(request_co ) session_id = result["session_id"] - assert result["status"] == "success" + assert result["status"] == "accepted" assert session_id == _RESOURCE_REASON_SESSION_ID assert session_service.got == [ { @@ -285,7 +285,7 @@ async def wait(self, *args, **kwargs): timeout=3, ) - assert result["status"] == "success" + assert result["status"] == "accepted" assert result["commit_task_id"] == "reason-task" @@ -338,7 +338,7 @@ async def add_from_other_queue(): release.set() results = await asyncio.wait_for(asyncio.gather(first, second, worker), timeout=3) - assert all(result["status"] == "success" for result in results) + assert all(result["status"] == "accepted" for result in results) assert all(result["session_id"] == _RESOURCE_REASON_SESSION_ID for result in results) assert [call["session_id"] for call in session_service.committed] == [ _RESOURCE_REASON_SESSION_ID