OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: add_resource --wait timeout returns no task_id; background pipeline keeps running with no way to poll

Open livechenjt-prog opened this issue 4 months ago • 2 comments

Issue Origin

Observed or reproduced in a real environment

Bug Description

add_resource (both HTTP API and ov add-resource --wait) returns a bare timeout error when the wait budget is exceeded, but the underlying embedding / summarization pipeline keeps running in the background and eventually succeeds. The client has no task_id in the timeout response, so there is no way to:

  1. Poll the actual completion status of the still-running task.
  2. Distinguish "timed out but succeeded in the background" from "genuinely failed".
  3. Cancel the task if we no longer want it.

The only workaround today is to fire a search against the expected content some time later and infer success from a hit — which is not deterministic and forces callers to hard-code arbitrary sleep loops.

Steps to Reproduce

  1. Import a mid-size resource (~5–20 MB of mixed text) with --wait and a short-ish timeout that is realistic for a slow VLM backend:
ov add-resource /path/to/repo \
  --to viking://resources/test-import/ \
  --wait --timeout 60
  1. Wait for the client to return with a timeout error.
  2. Poll viking_search "<known-content-from-repo>" in a loop.

Expected Behavior

When --wait times out but the task is still running, the response body should include a task_id (and ideally a poll_url), so the caller can:

ov task info <task_id>   # -> pending | running | succeeded | failed
ov task cancel <task_id> # optional

This is already the shape of the connector_import TaskRecord introduced in v0.4.10 (#3084). Extending the same TaskRecord contract to all add_resource paths — not just Connector-delegated imports — would close the loop.

Minimum acceptable outcome:

  • Timeout response contains task_id.
  • A public GET /tasks/<task_id> (and ov task info <task_id>) returns terminal state.
  • The CLI prints a copy-pasteable follow-up hint on timeout:
Timeout after 60s. Task 8f3c...c1 still running.
Poll:   ov task info 8f3c...c1
Cancel: ov task cancel 8f3c...c1

Actual Behavior

On timeout:

  • HTTP response body carries only a timeout / deadline-exceeded error.
  • CLI prints the timeout message and exits non-zero.
  • No task_id is surfaced.
  • The embedding pipeline continues in the background; viking_search can eventually confirm success — but only if the caller keeps polling and knows what to search for.

Minimal Reproducible Example

try:
    client.add_resource(
        source="/path/to/repo",
        to="viking://resources/test-import/",
        wait=True,
        timeout=60,
    )
except TimeoutError as e:
    # No task_id anywhere; nothing to poll.
    print("failed?", e)

# The actual write may still land ~2-5 minutes later.

Error Logs

Timeout waiting for add_resource to complete (deadline=60s)

(No task_id or handle attached to the exception.)

OpenViking Version

0.4.7

Python Version

3.10

Operating System

Linux

Model Backend

Volcengine (Doubao)

Additional Context

  • v0.4.10 already introduced connector_import TaskRecord in #3084 for external Connector imports. This issue asks to unify: every add_resource invocation should own a TaskRecord that outlives the client wait window.
  • Related but distinct: #2383 (repeated add_resource still re-embeds unchanged content) — orthogonal, same add_resource family.
  • Companion issues in this batch: #3305 (viking_read on directory URIs returning bare INVALID_ARGUMENT), and #3307 (content-aware add_resource with --if-newer / --if-changed). All three sit under "make add_resource / read lifecycle observable and idempotent".
  • Contribution: happy to work on the CLI wiring for ov task info / ov task cancel once the server-side TaskRecord contract is extended.

livechenjt-prog avatar Jul 16 '26 14:07 livechenjt-prog

我会去掉 add-resource wait timeout 的逻辑,如果需要timeout,可以在请求级设置超时

qin-ctx avatar Jul 23 '26 08:07 qin-ctx

Thanks for reporting this! #4888 preserves the background task ID when add_resource --wait reaches its deadline. The HTTP error includes details.task_id, and the error message explains that only the wait ended and provides the status command:

ov task status <task_id>

The background task is not cancelled by this timeout. Closing as resolved on main. If a version containing #4888 still loses the ID, please reopen, or comment requesting reopening, with the server/client versions, request or CLI command and sanitized timeout response.

qin-ctx avatar Sep 18 '26 08:09 qin-ctx