Skip to content

Report and archive malformed active local task sessions #6

Description

@mplibunao

Summary

Codex Desktop can become very slow when malformed active local-task sessions accumulate in state_5.sqlite. I have seen this with app-server-driven integrations such as RepoPrompt, and another user reported similar rows from RepoPrompt and the Cursor extension.

The bad rows are active sessions with no user event and unusable workspace roots, commonly:

cwd = '/'
AND has_user_event = 0
AND title LIKE '<codex reminder>%'

In another observed case, synthetic discover-agent rows had has_user_event=0 and a macOS temp-folder cwd under /private/var/folders/.../T.

User-visible symptom

Codex Desktop repeatedly logs:

No cwd found for local task

for those conversation IDs, and thread-list rendering / Desktop navigation becomes very sluggish.

In one affected profile, archiving malformed rows reduced the active Desktop-visible thread set from 915 to 87 and restored normal responsiveness.

Why this belongs in keep-codex-fast

Even if third-party integrations create the malformed rows, they live in Codex's local state and Codex Desktop pays the runtime cost. keep-codex-fast is a good place to detect and safely archive this state because it already follows a backup-first, archive-not-delete maintenance model.

Proposed behavior

  • Report malformed local-task candidates by default.
  • Do not mutate in report mode or normal apply mode.
  • Add an explicit opt-in flag for archiving, e.g. --archive-malformed-local-tasks.
  • Archive only conservative candidates:
    • active/unarchived thread
    • has_user_event=0
    • suspicious cwd, such as / or OS temp folders
    • rollout file exists under ~/.codex/sessions
    • pinned threads are skipped
  • Move rollout JSONL into ~/.codex/archived_sessions/.
  • Set archived=1 and archived_at in SQLite.
  • Write a manifest and restore script.

I have a PR ready that implements this behavior with smoke tests for report-only behavior, explicit opt-in, root cwd, temp cwd, and normal user-event rows not being archived.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions