Skip to content

session_status leaks stale task context in chat (/status shows old completed jobs) #58661

Description

@VACInc

Summary

/status (session_status) in chat can include stale/noisy task context that feels unrelated to the current conversation state.

In our Telegram topic sessions, the 📌 Tasks: line kept surfacing old completed subagent work (and previously, synthetic internal task text), even when there were no active tasks.

What I observed

  • session_status builds the task line from listTasksForRelatedSessionKeyForOwner(...) and includes latest task context even when there are 0 active tasks.
  • In practice, this keeps old completed subagent jobs visible in /status for that session/topic.
  • Previously, synthetic task rows also appeared in status context:
    • OpenClaw runtime context (internal): ...
    • async followup artifacts (An async command did not run..., An async command the user already approved has completed...)

Exact cleanup I performed (production state DB)

SQLite DB: ~/.openclaw/tasks/runs.sqlite

  1. Removed synthetic terminal task rows across sessions (plus delivery-state rows)
  • Match criteria:
    • runtime='cli'
    • status IN ('succeeded','failed','cancelled','timed_out','lost')
    • task text contains one of:
      • OpenClaw runtime context (internal):
      • An async command did not run.
      • An async command the user already approved has completed.
  • Removed: 15 rows
  • Backup: ~/.openclaw/tasks/runs.sqlite.bak-20260331-214143-synthetic-clean
  1. Removed completed Telegram-topic subagent rows (plus delivery-state rows)
  • Match criteria:
    • runtime='subagent'
    • owner_key LIKE 'agent:main:telegram:group:-1003826723328:topic:%'
    • status IN ('succeeded','failed','cancelled','timed_out','lost')
  • Removed: 10 rows
  • Backup: ~/.openclaw/tasks/runs.sqlite.bak-20260331-215741-tg-subagent-clean
  • Removed task_ids:
    • 12cbc768-b53e-4500-809d-da6dfe0a28a9
    • add11ddf-2545-43f5-91bf-7b8fb7b6bd2a
    • 52c5802c-e81b-48e3-950d-c5980d3c8cfe
    • fabfcae0-ab70-433d-93b9-9659502467ee
    • eed27730-d56c-4559-bb2c-da19d291d32e
    • 686eb40a-add1-4136-8ada-380635110ac3
    • c20898e4-89cc-4566-8d38-0537a0721ed6
    • 674c1529-964f-40d1-b322-79b2aa496cb2
    • fdb4f45b-23e2-4961-a82d-6f9c8aca4d06
    • 3d4e2eef-b86d-41d5-8807-00f09ef74ea0

Why this seems buggy

For chat UX, /status should prioritize current state. Showing old completed task context by default is noisy and misleading when there are no active tasks.

Suggested fix

  • In session_status/buildStatusText task-line logic, prefer:
    1. show task line only when there are active tasks, or
    2. show only recent failures (short window), or
    3. gate “latest succeeded ...” behind an explicit verbose/debug mode.
  • Also ensure synthetic internal followup/runtime-context tasks are never treated as user-facing status context.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions