Skip to content

fix: keep VS Code todo lists through the memory strip so Context Management names each item - #399

Open
Abhiram Shaji (abhiramshaji-cyber) wants to merge 3 commits into
microsoft:mainfrom
abhiramshaji-cyber:fix/keep-todo-snapshot
Open

Abhiram Shaji (abhiramshaji-cyber) wants to merge 3 commits into
microsoft:mainfrom
abhiramshaji-cyber:fix/keep-todo-snapshot

Conversation

@abhiramshaji-cyber

@abhiramshaji-cyber Abhiram Shaji (abhiramshaji-cyber) commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

Hi, hope you're doing well! In Context Management, every VS Code todo event was named after the todo tool instead of the item, and this PR keeps the parsed todo lists so each event shows its item and progress.

Thanks Sanjay Singh (@san360) for such a clear report. Tracing the snapshot from extractTodoSnapshot to the strip that nulls it, and pointing out that the strip's doc comment was wrong, made this one quick to follow.

What this code is for

stripSingleSession runs on every parsed session to keep memory down: it cuts messageText to 500 characters and empties responseText. The VS Code parser calls it right after each workspace, and the parse worker calls it again through stripSessionsForMemory before analysis. Context Management's session timeline (buildSessionTimelineEvents) then reads each request's todoSnapshot to place todo markers and bands.

Before this PR

A developer uses VS Code agent mode, and the agent keeps a todo list with manage_todo_list.

  1. extractTodoSnapshot reads the last manage_todo_list call and sets todoSnapshot to a list of { id, title, status }.
  2. stripSessionsFrom calls stripSingleSession, which runs if (r.todoSnapshot) r.todoSnapshot = null.
  3. The parse worker strips again, and the cache saves the session with no snapshot.
  4. buildSessionTimelineEvents finds no todoSnapshot, so it calls addToolFallbackTodoEvents.
  5. Every todo event is labeled manage_todo_list, counted as an addition, and never shows progress.

After this PR

Same developer, same session.

  1. Same as above through step 1.
  2. stripSingleSession keeps the list, rebuilt with only id, title and status.
  3. CACHE_VERSION is now 35, so sessions cached without snapshots are parsed again.
  4. buildSessionTimelineEvents finds the snapshot and calls addTodoSnapshotEvents.
  5. Each item gets its own todo-add, todo-progress and todo-complete events, named after the item.
flowchart LR

classDef box fill:#eef1ff,stroke:#4c5bd4,color:#111827
classDef bad fill:#ffd6d6,stroke:#cc0000,color:#111827,stroke-width:3px
classDef good fill:#c8f0c8,stroke:#008800,color:#111827,stroke-width:3px

subgraph BEFORE["BEFORE: every todo event named manage_todo_list"]
direction TB
  B1["agent updates its todo list"] --> B2["extractTodoSnapshot keeps the list"]
  B2 --> B3["stripSingleSession"]
  B3 --> B4{"todoSnapshot set to null"}
  B4 -->|"no snapshot left"| B5["addToolFallbackTodoEvents uses the tool name"]
  B4 -->|"request had no todo list"| B6["no todo events"]
end

subgraph AFTER["AFTER: each event named after its item"]
direction TB
  A1["agent updates its todo list"] --> A2["extractTodoSnapshot keeps the list"]
  A2 --> A3["stripSingleSession"]
  A3 --> A4{"THE CHANGE: keep id, title, status"}
  A4 -->|"snapshot kept"| A5["addTodoSnapshotEvents names each item"]
  A4 -->|"request had no todo list"| A6["no todo events, same as before"]
end

B1 ~~~ A1

class B1,B2,B3,B6 box
class A1,A2,A3,A6 box
class B4,B5 bad
class A4,A5 good

linkStyle 3 stroke:#cc0000,stroke-width:5px
linkStyle 8 stroke:#008800,stroke-width:5px

style BEFORE fill:#fff5f5,stroke:#cc0000,color:#111827
style AFTER fill:#f3fff3,stroke:#008800,color:#111827
Loading

stripSingleSession and its callers
The four functions that call stripSingleSession, Functions view in Architect

The change

  • In stripSingleSession, r.todoSnapshot = null becomes a map to { id, title, status }. Those are the only fields the timeline reads from it in buildSessionTimelineEvents, and running the strip twice gives the same result. This is the fix.
  • The doc comment line saying the snapshot is only used by the session detail view is removed.
  • CACHE_VERSION goes from 34 to 35, so caches saved without snapshots are parsed again once.
  • Tests: cache.test.ts now expects the snapshot kept, a new case checks that extra fields on an item are dropped, and another checks that a version 34 cache is parsed again. context-mgmt-guides.test.ts strips a session and checks that the analyzer still names Plan and Build, with their progress and completion. The new checks fail on main.
  • changelog.d/399.md adds a Fixed entry for the new changelog flow.

What changes for a user

  • VS Code todo markers, bands and tooltips in Context Management show each item's title, with when it was added, started and completed.
  • Requests without a todo list behave as before, and sessions with no snapshot at all still use the tool name fallback.
  • The first launch after updating parses everything again, because of the cache version bump.
  • Each request with a todo list now keeps a small list of ids, titles and statuses in memory and in the cache.

One question: is that small memory cost OK with you, or would you rather keep a different shape, like the timeline events built at parse time? I went with the slim snapshot for now since it's the smallest change, but I'm happy to switch.

Related Issues

Fixes #330
Fixes #360 (same bug, filed later)

Akhil Gupta (@akhil9tiet), I saw you offered to take #360. Sorry if I'm stepping on that! If you already have something going, I'm very happy to close this or work on it together.

Checklist

  • npm run check passes (typecheck + lint + spellcheck + knip + tests): typecheck, lint, spellcheck, knip and lockfile-lint pass; the tests pass except image-data.test.ts (2) and canvas-entry.test.ts (1), which fail the same way on main on my macOS machine with Node 26
  • Changes are covered by tests (if applicable)
  • Documentation updated (if applicable)
  • User-visible changes are described in a changelog.d/<PR number>.md fragment

…agement names each item

stripSingleSession set todoSnapshot to null on every request, so Context
Management's session timeline never saw the parsed to-do lists and fell
back to the tool name for every to-do event. The strip now keeps each
item's id, title and status, which is all the timeline reads.

CACHE_VERSION goes to 32 so sessions cached without their snapshots are
parsed again.

Fixes microsoft#330
@abhiramshaji-cyber

Copy link
Copy Markdown
Contributor Author

Hi, hope you're doing well! I merged the latest main in. The cache version is now 35, since main already uses 32 to 34, and I added a changelog.d/399.md entry for the new changelog flow. Does the wording read okay, and is there anything you'd like changed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant