Repository navigation
perf(coderd/x/chatd): read a subagent's report from its newest messages - #367
Conversation
…de, settle and spawn
…ons while settling an archive
…he chat tree and list_agents
|
$> Coder Agents acted on behalf of @ibetitsmike.\n\n@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
$> Coder Agents acted on behalf of @ibetitsmike.\n\n@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
# Conflicts: # coderd/x/chatd/fork_family_reads_internal_test.go
|
$> Coder Agents acted on behalf of @ibetitsmike.\n\n@codex review\n\nMerged the restacked #366 head 1cd7c5c into this branch. |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
$> Coder Agents acted on behalf of @ibetitsmike.\n\n@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
$> Coder Agents acted on behalf of @ibetitsmike.\n\n@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Deleting a family root sets root_chat_id and the promoted child's parent_chat_id to NULL, so the root_chat_id predicate returned only one level below the promoted root. GetDescendantChatsByRootIDs now walks parent_chat_id with a recursive CTE, and list_agents starts the walk at the listed chat.
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
A one-level list_agents call walked up to 64 levels and discarded every row below the direct children. GetDescendantChatsByRootIDs now takes a max_depth, capped at 64.
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…gent # Conflicts: # coderd/database/dbmetrics/fork_forkdb.go
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Merged at head Gates on this exact head:
Tests I ran on
Review notes: the change is a read path only. Not exercised: a running server and |
Closes #302
This is the last PR of a stack of three for #302:
main, withmainmerged in): item 5, wait_agent reads a subagent's report from its newest messages.The issue deferred item 5 to #303. The lead asked for it in this stack, so it is here.
Problem
latestSubagentAssistantMessageincoderd/x/chatd/subagent_operations.goreads the whole visible history of the subagent withGetChatMessagesByChatIDand scans it from the end for the newest assistant message with text. wait_agent, and every report that needs a subagent's last answer, pays for a full history read. A long subagent can have thousands of messages.Change
GetChatReportMessagesincoderd/database/forkdb/queries/chat_subagent_reports.sql. It returns the assistant messages of a chat that the user sees and that are not deleted, newest first, below an optional id bound, with a limit. It selects onlyid,contentandcontent_version. The indexidx_chat_messages_chat_role_id (chat_id, role, id DESC) WHERE deleted = falseserves it.GetChatMessagesByChatID. dbmetrics wraps it.forkLatestSubagentReportincoderd/x/chatd/fork_subagent_report.goreads one message first. It reads pages of 50 only when the newest assistant messages have no text, for example tool calls only. It parses and trims each message the same way as upstream.latestSubagentAssistantMessage. A store without fork queries, such as the gomock stores inTestStoreSubagentReportSummary, keeps the upstream full read.The result is the same string as before, so the change is not behind an experiment.
Tests
TestForkLatestSubagentReport(coderd/x/chatd/fork_subagent_report_internal_test.go) counts the pages, the rows and the full history reads. Each case also runs the upstream full read and requires the same report.Negative control: with the hook removed every case fails with
{pages:0, rows:0, fullReads:1}.Commands run, all with
flock ~/.fork-go.lock:go test ./coderd/x/chatd/... ./coderd/database/forkdb/... -count=1: PASS.go test ./coderd/database/dbauthz/ ./coderd/database/dbmetrics/ -count=1: PASS, includingTestForkQuerier/GetChatReportMessages.golangci-lint run --fix=falseon the changed packages: no findings in the changed files.gofmt -l: clean.Not verified
make lintandmake genwere not run. The fork queries were generated withcoderd/database/forkdb/generate.sh.