Skip to content

feat(coderd/x/chatd): restore the todo list after compaction - #35

Merged
ibetitsmike merged 7 commits into
mainfrom
mike/todo-transcripts-3-todo-snapshot
Nov 9, 2026
Merged

ibetitsmike merged 7 commits into
mainfrom
mike/todo-transcripts-3-todo-snapshot

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Part of #10. Follows #34 (merged).

After compaction the model loses the todo list it made: the summary replaces the todo_write and todo_read rows, and a summary keeps at best a paraphrase. In UAT the model misread item statuses from a summary. This PR puts the stored list back into the prompt (behind fork-chat-todos).

  • Before each generation step, syncForkContext runs the project memory index sync as before, then checks the todo list. The prompt's latest carrier is a snapshot this sends or a non-error todo_write/todo_read result, and both name a version. When the stored version differs from the one the prompt last showed, or no carrier is left, it adds a model-only user message with the stored list. That covers compaction, an edit that deleted the tool rows, and a write that raced a read.
  • The snapshot is a header, a Version: n line, and one JSON object per item, so content with line breaks cannot read as another item. A list that was cleared sends (empty), so a plan the summary still mentions is dropped. A chat that never stored a list (version 0) skips the prompt read.
  • The item lines are capped at the tool result budget of the chat's model, the same room its todo_write result gets, and they take no more bytes than that result's items, so they are cut only when the result was. A cut snapshot keeps its header and version, so it is not resent every step.
  • It uses the memory index rules for mid-turn timing: no message right after an assistant row, or while tool calls wait for results. Subagent chats get the snapshot too, since their list is their own. The turn decision reads only user-visible rows, so a snapshot added after a manual /compact does not start another reply.
  • Upstream generation.go changes one line: the call now goes to syncForkContext in the fork file fork_context.go, the place for later fork prompt context. A lookup failure is logged and the turn goes on without the snapshot.
  • ARCHITECTURE.md: the existing TODO(fork-chat-todos) now also names the snapshot.

Validation: TestTodoSnapshotMessage covers the snapshot after a real compaction shape (summary row, earlier rows dropped), subagent chats, current and stale snapshots and results, error and version-less results, a cleared list with and without a carrier, line breaks in content, the largest list on a large and a small context model, no list or experiment off, and pending tool calls. The whole coderd/x/chatd package passes against Postgres 17.

UAT on a dev instance with a local model, last run on 64b224b (later commits change only the cap on oversized lists and test contexts): after POST /chats/{id}/compact, one snapshot row with Version: 3 followed the summary, the model listed the right statuses, no extra reply ran before the next user message, and the next turn added no second snapshot. The PR2 build answered the same question with wrong statuses.

Open question for the follow-ups on #10: after /clear the list comes back like after compaction, as the memory index does.

Compaction replaces the assistant and model-only rows that carry the todo list, so the model is left working from a plan it can no longer see. Before each generation step the fork now appends a model-only snapshot of the stored list when the prompt carries none, the way the project memory index is kept current.
Compaction writes a compressed model-only summary and the prompt drops the rows before it; it does not mark the replaced rows compressed.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T09:49:59.391114Z 43fddae Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 870f3f5416

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/fork_context.go Resolved
A snapshot or a todo result in the prompt only shows the version the model read, so a prefix check left a stale plan in place: a snapshot of an older list survived an edit that deleted the tool rows, and a read that raced a write answered with an earlier version. Both now compare the version the prompt last showed with the stored one, and a list that was emptied sends an empty snapshot so the model drops the plan instead of finishing it.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb5141c64a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/x/chatd/fork_context.go Resolved
Comment thread coderd/x/chatd/fork_context.go Resolved
Comment thread coderd/x/chatd/fork_context.go Resolved
Comment thread coderd/x/chatd/fork_context.go Resolved
Comment thread coderd/x/chatd/fork_context.go Resolved
Skip the prompt read for a chat that never stored a list, send the
empty snapshot when compaction removed every carrier of a cleared list,
render items as JSON lines so content cannot read as another item, and
cap the snapshot at the smallest tool result budget.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8df23bcb7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/x/chatd/fork_context.go Resolved
Comment thread coderd/x/chatd/fork_context.go Resolved
Comment thread coderd/x/chatd/fork_context.go Resolved
Bound the snapshot by the tool result budget of the chat's model, so a
large list stays whole wherever todo_write's result could hold it, and
drop the todo_write instruction from the header, since plan mode turns
do not offer the tool.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 64b224b7a7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/x/chatd/fork_context.go Resolved
Comment thread coderd/x/chatd/fork_context.go Resolved
The parallel subtests shared the parent's 25 second context and could
start after it expired on a busy runner.
The header and version line sit outside the budget, so the items are
cut only when the todo tool result that showed them was cut too.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 43fddae192

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike merged commit 01de159 into main Nov 9, 2026
10 checks passed
@ibetitsmike
ibetitsmike deleted the mike/todo-transcripts-3-todo-snapshot branch November 9, 2026 10:28
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike.

Gates checked on head 43fddae192: fork-ci green on this head (all jobs, including chat-tests after the per-subtest context fix in 2b30310574), Codex found no issues with reviewed commit 43fddae192, 0 unresolved review threads, mergeable and clean against main 7d2145ddb7. UAT on 43fddae192: after /compact the snapshot row (version 3, JSON lines) was written and the model listed the stored statuses; no extra reply after compaction. The no-second-snapshot check ran on 64b224b7a7 with unchanged logic. The change to upstream generation.go is one hook line. Merged after 7d2145ddb7 deployed healthy.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant