Skip to content

Stale background subagents persist in UI after session restart/compaction #27373

@fruch

Description

@fruch

Description

Background subagents (e.g. librarian, explore) that were launched in a previous session context (before compaction or restart) persist in the UI's "Subagentes" panel as running tasks indefinitely. They cannot be cleared.

Steps to Reproduce

  1. Start a session and launch background subagents (e.g. task(subagent_type="librarian", run_in_background=true, ...))
  2. Session gets compacted (context reset) or OpenCode is restarted
  3. The subagent entries remain visible in the UI sidebar showing "running" state
  4. background_cancel(all=true) returns "No running or pending background tasks to cancel"
  5. Restarting OpenCode does not clear them

Expected Behavior

  • Stale subagent entries should be cleared on session restart or compaction
  • Or: provide a CLI command like opencode session clear-tasks <sessionID> to manually clear them
  • Or: the UI should detect orphaned tasks and remove/mark them as stale

Actual Behavior

The UI shows ghost entries forever:

▼ Subagentes
  [ ] Research regional MIGs (librarian) ↳ 23:36:01
  [ ] Find GCE aggregated machineType… (librarian) ↳ 23:38:48

These are not actually running — they're leftover references from a pre-compaction context that no longer exists.

Environment

  • OpenCode version: 0.6.1
  • OS: Linux

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions