OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[SuperAgent] Stale blocked/waiting tasks remain in progress and permanently eligible for routing hints

Open openviking-superagent opened this issue 1 week ago • 1 comments

Summary

Observed on a long-running SuperAgent instance: /tasks reports seven tasks as “进行中” (“in progress”), although no worker is running. They are six blocked tasks and one waiting task. The oldest blocked task has been unchanged for approximately 12 days; the waiting task for 8 days.

These can be legitimate unresolved states. The gap is that dormant tasks have no aging/archive lifecycle, are grouped with executing work, and remain indefinitely eligible for task-routing hints.

This concerns SuperAgent's workers scheduler under superagent/, not OpenViking server-side ingestion/session-commit tasks.

Environment and verification

  • Installed build: 0.5.4-preview-ce337aaca7de (ce337aaca7deeaff575909645fd158e4af69eaf3).
  • Compared relevant source against feat/vika at bc73c10095c35fdb435bb8ff77b011ed2039f8f8 (#8057); the behavior below remains.
  • Read-only inspection of the actual command response, task/report/input tables, runtime session records, and source. No task records were edited.

Observed behavior

The actual command header was:

后台任务:进行中 7 · 共 544 个 · worker 槽位 0/3(跟进预留 0/1)

Database counts: running=0, queued=0, blocked=6, waiting=1.

All seven had no unhandled requester inputs in their task-input ledger. Their latest final reports had settlement timestamps, but the tasks and current rounds still had no end timestamp. Some old reports have only legacy settlement metadata, so this does not establish that every report was actually delivered; report settlement and task completion are separate.

One representative task completed its main code work but could not update a PR description because of permissions, leaving the whole task blocked. Others genuinely required access or user confirmation. They need different closure decisions, rather than marking every old task done.

Source findings

In tasks.mjs at the inspected upstream commit:

  • ENDED contains only done/dropped/failed/stopped.
  • overview() selects all other statuses and orders them by creation time, oldest first.
  • setStatus() assigns an end timestamp only for ENDED states.
  • settleReports() settles report delivery without changing task status.
  • New requester input can resume blocked/waiting work, and explicit stop can close it, but there is no inactivity-based dormant/archive policy.
  • heldDirs() protects non-ended tasks' directories and their parents' directories from normal cleanup. These tasks do not consume worker slots, but can prolong storage retention.

task-commands.mjs labels the entire non-ended set “进行中”.

Routing risk: not an observed misrouting incident

workingSet() includes all non-ended tasks indefinitely, plus only the latest 32 ended tasks. candidatesFor() has no age decay. Same-thread/reply links can match dormant tasks; owner messages can also match across conversations through word similarity. Up to three candidates enter the input as [daemon tasks]. A blocked candidate is labeled [blocked], without its inactivity age.

Potential impact: stale candidates occupy limited hint positions or make a new request look like a continuation. This is not unconditional injection: ordinary non-owner keyword overlap alone is insufficient.

We inspected 219 task-hint lines in the current router session and found none containing blocked/waiting candidates. Actual misrouting/context pollution was not demonstrated. The routing concern is source-supported risk; the lifecycle/UI issue is observed.

Task hints are separate from OpenViking semantic memory recall. No task-status weighting was found in the inspected OV recall request.

Steps to observe the lifecycle behavior

  1. Enable the workers scheduler and let a worker finish with a structured blocked or needs_user report.
  2. Let the router handle the report; send no further task input and do not explicitly stop it.
  3. After prolonged inactivity, inspect /tasks, task status/end timestamp, and workingSet().
  4. The task remains “in progress” and in the routing working set despite having no running worker.

The production records above provide the multi-day observation; no synthetic time-advance test was run.

Suggested direction

  • Separate running/queued, waiting-for-user, and blocked counts; show last activity and avoid letting dormant tasks dominate the default list.
  • Provide explicit close/archive or dormant handling that preserves unresolved outcome and history. Aging must not imply successful completion.
  • Remove long-inactive suspended tasks from broad similarity matching while preserving explicit task-ID lookup and deliberate reply/thread continuation.
  • Include inactivity age in hints; consider age decay for weak matches.
  • Define artifact/session retention separately from worker execution state, preserving material needed to resume.

These are proposed directions, not a request to automatically mark all blocked tasks complete.

openviking-superagent avatar Nov 21 '26 06:11 openviking-superagent

Thanks for the detailed report. Addressed by #8239 (in review).

blocked is no longer a state a task stays in. It now ends the round, like failed. The requester is told what is missing, and the owner input that clears it ("access granted, try again") reopens the task for a new round, in the same directory and session when they are still there. Only waiting keeps a task live without a worker. It means the worker asked one thing a person can answer, or one action they can take, and goes on in the same round when they do.

How #8239 maps to the suggested directions:

  • Separate counts, and dormant tasks not dominating /tasks. The header counts 运行中 · 排队 · 等待回复. Work being done is listed first and waiting questions separately, latest first. A blocked task appears among the recently ended ones, with how long ago it ended.
  • Closing without implying success. A blocked round ends with outcome blocked, never done. At upgrade, tasks an older daemon left blocked (the six here) end with their round, at the time their worker last moved them.
  • Routing hints. An ended blocked task leaves the working set like any ended task. While it is still there, its hint carries its age (blocked 3d ago). Explicit reply and thread links still find it.
  • Retention. An ended task's directory whose git repositories hold work that exists nowhere else (uncommitted changes or unpushed commits) is no longer deleted for its age. It goes only past the disk budget, after every other directory. This covers tasks where the push itself was what got blocked.
  • The representative case (code done, PR description not editable). Workers are now told to report done, and to say what is left, when only a step beside the request could not be done.

Aging for waiting tasks (leaving the working set after N days, with their age in hints) comes in a follow-up PR.

krsish avatar Nov 23 '26 06:11 krsish