Skip to content

[BUG] Parent tasks disappear from history when files temporarily unavailable, orphaning child tasks #11172

@SannidhyaSah

Description

@SannidhyaSah

Problem (one or two sentences)

Parent tasks in delegation chains (Orchestrator mode and subtasks) are being permanently deleted from task history when their api_conversation_history.json file is temporarily unavailable, causing child tasks to become orphaned and unable to navigate back to their parent.

Context (who is affected and when)

This affects users who:

  • Use Orchestrator mode to delegate tasks to child modes
  • Create long chains of subtasks (A → B → C)
  • Try to navigate back to a parent task using the "Back to Parent Task" button
  • Have slow disk I/O or filesystem latency

The issue is particularly severe during delegation transitions when parent tasks are disposed and child tasks are created, creating a race condition window.

Reproduction steps

  1. Environment/setup:

    • Any OS with Roo Code extension
    • Any API provider
    • Use Orchestrator mode or any mode that delegates tasks via new_task tool
  2. Exact actions:

    • Start a parent task in Orchestrator mode
    • Let it create a subtask (delegation)
    • While subtask is running, if any file I/O latency occurs:
      • Or manually: delete/rename the parent's api_conversation_history.json file in global storage
    • Click "Back to Parent Task" button in the subtask
    • Or wait for subtask to complete and auto-resume parent
  3. What you observed:

    • Parent task entry disappears from task history completely
    • Child task shows "Back to Parent Task" button but clicking it fails
    • Error "Task not found" is thrown
    • In longer chains (A→B→C), completing C may orphan B, then A becomes unreachable

Expected result

Parent tasks should remain in task history even if their files are temporarily unavailable. Navigation should either retry, show an error without deleting data, or gracefully handle the missing file scenario.

Actual result

Parent tasks are permanently deleted from taskHistory global state when getTaskWithId() is called and the api_conversation_history.json file doesn't exist. This happens via deleteTaskFromState() being called unconditionally when files are missing.

Variations tried (optional)

This is a code analysis finding. The vulnerable code path is:

  • src/core/webview/ClineProvider.ts lines 1658-1693 (getTaskWithId())
  • The code includes a // FIXME comment acknowledging the issue: "this seems to happen sometimes when the json file doesnt save to disk for some reason"

Related vulnerable paths include:

  • showTaskWithId() - Navigation triggers the deletion
  • reopenParentFromDelegation() - Delegation resume can trigger deletion
  • deleteTaskWithId() - Cascading deletions can occur

App Version

Any version with the current getTaskWithId() implementation (verified in current main)

API Provider

Not Applicable / Other (affects all providers)

Additional Technical Context

Root cause location: getTaskWithId() in src/core/webview/ClineProvider.ts (lines 1658-1693)

// If task exists in history but file is missing, it gets DELETED:
await this.deleteTaskFromState(id)  // Line 1691
throw new Error("Task not found")   // Line 1692

Impact severity: High - Data loss, broken navigation, orphaned tasks

Related metadata fields in HistoryItem:

  • parentTaskId - becomes a dangling reference when parent is deleted
  • childIds - parent loses track of children if deleted
  • awaitingChildId, delegatedToId, completedByChildId - all become invalid

Key code paths affected:

  1. getTaskWithId() - Primary bug location
  2. showTaskWithId() - UI navigation triggers deletion
  3. reopenParentFromDelegation() - Auto-resume can fail and delete parent
  4. delegateParentAndOpenChild() - Race window during delegation
  5. deleteTaskWithId() - Cascading effects when orphan detection fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions