Skip to content

feat(coderd/x/chatd): add the notes tool behind fork-token-budget - #285

Merged
ibetitsmike merged 5 commits into
mainfrom
mike/issue-283-token-budget-notes
Nov 14, 2026
Merged

ibetitsmike merged 5 commits into
mainfrom
mike/issue-283-token-budget-notes

Conversation

@ibetitsmike

Copy link
Copy Markdown
Owner

Coder Agents opened this PR on behalf of @ibetitsmike.

Part of #283. This is PR 1 of 4 in the split from the design note.

What changed

  • New experiment fork-token-budget ("Fork Token Budget"). It gates the whole token-budget stack. This PR adds only the notes tool.
  • New chatdmig node 01a1d71e-84b7-78ae-99dd-2cb2e94742e3_chat_notes adds chatd.chat_notes. Each row has a chat ID, a path and content. It is keyed by (chat_id, path) and cascades on chat delete. Table checks hold the path pattern and the 16384 byte cap. No numbered migration.
  • forkdb queries ListChatNotes, GetChatNote, WriteChatNote and DeleteChatNote, with dbauthz and dbmetrics wrappers. WriteChatNote creates a note only while the chat has fewer than 20 notes, and its append adds the content as a new line.
  • New notes tool in coderd/x/chatd/fork_chat_notes.go. Its actions are list, read, write, append and delete. The tool is bound to its own chat, so no other chat can read the notes, subagents included. The hook is one if in fork_tools.go.
  • Plan-mode turns, explore children and read-only custom agent types do not get the tool, because their allowlists do not list it.
  • Docs: a Tools row and a Notes section in docs/fork/pstack-adapter.md, with evidence lines. coderd/x/chatd/ARCHITECTURE.md lists the table and the tool.

Later PRs use the notes: checkpoint.md becomes the hand-off for the next context window.

Tests run

  • flock ~/.fork-go.lock go test -count=1 ./coderd/x/chatd/ -run TestChatNotesTool: pass. It runs through an authorizing dbauthz store and covers write, append, read, list order and sizes, delete, unknown actions, bad paths, the size cap on write and append, the 20 note cap, isolation between two chats, the plan-mode, explore and read-only filters, and no tool with the experiment off.
  • flock ~/.fork-go.lock go test -count=1 ./coderd/database/dbauthz/ -run TestForkQuerier: pass.
  • flock ~/.fork-go.lock go test -count=1 ./codersdk/ -run 'TestExperimentDisplayNames|TestForkExperiments': pass.
  • flock ~/.fork-go.lock go test -count=1 ./coderd/database/forkdb/... ./coderd/database/migrations/chatdmig/...: pass.
  • go run ./coderd/database/migrations/chatdmig/cmd/chatdmig check: pass.
  • golangci-lint with .golangci.new-code.yaml --new-from-merge-base=origin/main on the changed packages: 0 issues.
  • make lint/markdown lint/emdash lint/check-experiment-keys lint/architecture lint/agents lint/style-claims lint/migrations lint/docs-gen-filter: pass.

Not verified

  • No live chat used the tool against a real model. The tests call the tool directly.
  • The generated API files (coderd/apidoc, docs/reference/api/schemas.md) were edited by hand with only the new experiment value, because a local make gen also reordered unrelated enums. site/src/api/typesGenerated.ts is from make gen.
  • No UI change. The tool call shows as a generic tool card.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 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-14T06:03:59.147073Z 8c5ce72 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: 65cefd956f

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

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 5c369f4360

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

Coder Agents acted on behalf of @ibetitsmike.

Merged origin/main (#279, test only) so the branch is not behind main.

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

ℹ️ 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_notes.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Answered and resolved both P2 findings on f39c448: neither is a regression, so I dropped them with the reasons in the threads.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: f39c4480b5

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

…dget-compaction-96eae88d

# Conflicts:
#	coderd/database/forkdb/sqlc.yaml
#	coderd/x/chatd/ARCHITECTURE.md
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged origin/main (94caf1e, #280 and #282) with a merge commit. The chat_notes chatdmig node now requires 01a1d6ec-bf25-76dd-8035-184db759fb30_chat_subagent_messages, and sqlc.yaml lists it after that node. chatdmig check, the chatdmig tests against Postgres, the forkdb generator and the notes and family tests pass locally.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 1e0df9eef2

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

Coder Agents acted on behalf of @ibetitsmike.

Merged origin/main (8674a00, upstream sync #312) with a merge commit and no conflicts. chatdmig check, the chatdmig tests against Postgres, the forkdb generator and tests, and the notes, replay and restart tests pass locally.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 8c5ce7202b

ℹ️ 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 c7efc9c into main Nov 14, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/issue-283-token-budget-notes branch November 14, 2026 06:19
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged as c7efc9c (squash, --match-head-commit 8c5ce7202b).

Gates on head 8c5ce72:

  1. Head SHA matched the verified SHA at merge time. Main was 8674a00 (upstream sync chore: sync upstream ab325b55fa #312) and the server ran it.
  2. Every check run on the head passed. fork-ci run 43564260598 on this head passed.
  3. Codex receipt on this head: feat(coderd/x/chatd): add the notes tool behind fork-token-budget #285 (comment)
  4. Unresolved review threads: 0.
  5. Behind main: 0.
  6. Test evidence run by the maintainer on the exact head, all passed:
    • chatdmig check (exit 0; chat_notes node requires 01a1d6ec chat_subagent_messages)
    • go test -count=1 ./coderd/database/migrations/chatdmig/... against local Postgres
    • go test -count=1 ./coderd/database/forkdb/
    • go test -count=1 -v -run '(TestChatNotesTool|TestForkMessageAgentReplay|TestChatFamilySurvivesRestart$|TestExperimentDisplayNames)' ./coderd/x/chatd/ ./codersdk/

Not exercised: the notes tool against a real model, and the chat_notes node applying to the live database. The tool is off unless fork-token-budget is enabled.

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