Skip to content

feat(coderd/x/chatd): add the read_chat_transcript tool behind fork-chat-todos - #48

Merged
ibetitsmike merged 8 commits into
mainfrom
mike/todo-transcripts-6-read-transcript
Nov 9, 2026
Merged

ibetitsmike merged 8 commits into
mainfrom
mike/todo-transcripts-6-read-transcript

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 #36 (merged); independent of #43.

Adds read_chat_transcript, a chat tool that reads the stored messages of a chat in pages, so a chat can recover what compaction took out of its context. Behind fork-chat-todos, like the todo tools; appendForkTools adds it.

  • Arguments: chat_id (empty reads the calling chat), after_id cursor, roles, part_types, limit (1 to 100, default 20) and max_bytes (4096 to 65536, default 32768). A page returns next_after_id and has_more; messages that the filters skip still move the cursor.
  • Reads run as the chat owner (httpmw.UserRBACSubject and dbauthz.As, like asOwner in chattool/listtemplates.go), never as chatd, which can read every chat. A chat that does not exist and a chat the owner cannot read return the same error.
  • Descendants: subagent chats have the same owner as their root, so the owner's read access already covers every descendant. The tool adds no separate parent_chat_id walk; a walk would only allow chats the owner can already read.
  • Only rows with both visibility are returned: model-only context (system prompts, the todo snapshot) and user-only projections (the acp_wait_agent user result with the subagent's private reasoning) are skipped. So are hook-notice and source parts, which never reach the model, and rows with a call or result of read_chat_transcript itself, so paging through the calling chat does not return earlier pages again. Messages go through db2sdk.ChatMessage, which applies StripInternal and drops model-only parts, so provider metadata and credentials stay out.
  • Each part's text, pasted file content, args and result are cut with chatloop.TruncateToolResultText to the smaller of 16 KiB and max_bytes; cut args or results become a JSON string because a cut JSON value is not valid. Inline file bytes and parsed commands (a copy of the args) are dropped. The page stops before the message that would pass max_bytes. The first message always goes on the page, so every page moves the cursor, but with only the parts that fit (at least one); omitted_parts counts the rest. One call scans at most 1000 rows.
  • ARCHITECTURE.md: the existing fork tools TODO now names the new tool.

Validation: TestReadChatTranscript passes against Postgres 17 with the store wrapped in dbauthz: paging with cursor and filters, page bounds and truncation, reads as the owner (a root reads its grandchild, another user's chat is refused until it is shared with the owner), and argument errors. Negative controls: reading as chatd, dropping the role filter, dropping truncation, and dropping the byte budget each fail one subtest. ./coderd/x/chatd/... passes; go vet is clean.

UAT on a dev instance with a local model (79832c2, the head, fork-chat-todos and fork-nested-subagents on), from chats owned by a plain member:

  • After a manual /compact that compressed the first messages, the tool returned the first user message verbatim, and the model quoted it in a code block.
  • A seeded reasoning part with provider metadata, identity, model and credential fields came back with only its text; none of those fields or values were in any tool result.
  • An admin's unshared chat returned "does not exist or your user cannot read it"; after the admin shared it with the member (PATCH /chats/{chat}/acl), the same call returned its title and first message.
  • In a root, child and grandchild family made with spawn_agent, the root read the grandchild's first message.

Not in this PR, recorded on #10 as product calls: plan-mode and Explore turns do not get the tool (the same upstream allowlist gap as the todo tools), and the tool can read history from before a /clear. Also not in this PR: the model-only projection of an acp_wait_agent result is not returned, because reading model rows needs a new fork query.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@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-09T12:38:36.433440Z 79832c2 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: 905758a16c

ℹ️ 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_chat_transcript.go Resolved
Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/fork_chat_transcript.go Resolved
Comment thread coderd/x/chatd/fork_tools.go Resolved
@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: 99666619e8

ℹ️ 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_chat_transcript.go Resolved
…-6-read-transcript

# Conflicts:
#	coderd/x/chatd/ARCHITECTURE.md
#	coderd/x/chatd/fork_chat_todos_internal_test.go
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@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: 03081692bc

ℹ️ 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_chat_transcript.go Resolved
@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: 03081692bc

ℹ️ 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_chat_transcript.go Resolved
Comment thread coderd/x/chatd/fork_chat_transcript.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum acted for Mike.

@codex review

@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: bac39dbc51

ℹ️ 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_chat_transcript.go Resolved
Comment thread coderd/x/chatd/fork_chat_transcript.go Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 245e81538e

ℹ️ 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

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: f2481f93b1

ℹ️ 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_chat_transcript.go Resolved
Comment thread coderd/x/chatd/fork_chat_transcript.go Resolved
Comment thread coderd/x/chatd/fork_chat_transcript.go Resolved
@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: 79832c26bf

ℹ️ 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_chat_transcript.go Resolved
@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. Breezy!

Reviewed commit: 79832c26bf

ℹ️ 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 f015332 into main Nov 9, 2026
11 checks passed
@ibetitsmike
ibetitsmike deleted the mike/todo-transcripts-6-read-transcript branch November 9, 2026 13:24
@ibetitsmike

Copy link
Copy Markdown
Owner Author

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

Merge evidence at head 79832c26bf:

  • fork-ci pull_request run 42617535502 green on this head (all checks pass), MERGEABLE/CLEAN, 0 of 14 review threads unresolved.
  • Codex receipt clean on 79832c26bf (12:38:35Z).
  • Remote UAT on 79832c26bf with fork-chat-todos and fork-nested-subagents on, from member-owned chats: verbatim first message after /compact, provider metadata stripped, unshared chat refused and readable once shared, grandchild transcript read from the root.
  • Lead review of the diff against the brief: experiment-gated, reads run as the chat owner through dbauthz, StripInternal applied, only both-visibility rows returned, bounded paging. Declined findings confirmed under the scope rule; product calls recorded on pstack W4: todo list and transcripts #10.
  • Merged after 9a63b6ab78 deployed healthy locally; main had no chatd changes since the PR's last main merge and merge-tree was clean.

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