GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(coderd): add chat project instructions storage and prompt injection by jaaydenh · Pull Request #30367 · coder/coder

Conversation

@jaaydenh

@jaaydenh jaaydenh commented Oct 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Adds storage for project-level instructions in Coder Agents chat projects and injects them into every chat in the project. This is the first of four stacked PRs that replace #30349.

A new chat_project_instructions table (migration 000613) holds at most one row per project, scoped to the project's organization. It records updated_by and cascades on project delete. The dbauthz wrappers authorize against the parent project: read access to get the instructions, update access to upsert or delete them. No new RBAC resource is added; project RBAC comes in a later PR.

chatd loads the instructions on every turn, so edits reach existing chats on their next turn. They are added to the system prompt as a <project-instructions> block after the memory guidance and before personal instructions, so a user's personal instructions still win a conflict. Subagent chats carry no project_id, so they use their root chat's project. A load error other than no rows is logged, and the turn continues without instructions.

What to scrutinize: the prompt ordering in buildSystemPrompt, and the choice to inject per turn rather than snapshot at chat creation. Per-turn injection costs one prompt-cache miss after each edit; the org instructions in #30272 use a creation-time snapshot instead.

Generated (make gen from the migration and queries/chatprojectinstructions.sql): dump.sql, models.go, querier.go, queries.sql.go, dbmetrics/querymetrics.go, dbmock/dbmock.go, and the *_constraint.go files.

coderd/x/chatd/ARCHITECTURE.md gets two TODOs for the PR author to replace with the real description, per AGENTS.md.

Validation: make gen leaves no diff. go test ./coderd/database/dbauthz -run TestMethodTestSuite/TestChats, go test ./coderd/x/chatd -run 'SystemPrompt|ProjectInstructions|Memory', and go test ./coderd/database/migrations/... pass.


Stack (merge top to bottom). #30377 through #29583 are f0ssel's split of the original #29583, and this stack sits on #29583:

  • feat(site/src): add the chat projects data layer and project dialog #30377 data layer and project dialog (f0ssel)
  • feat: lock the new-chat form to a project's organization #30378 new-chat form locked to a project (f0ssel)
  • feat(site/src): add the chat project page #30379 project page route (f0ssel)
  • feat: add chat project folders to the sidebar #29583 sidebar folders (f0ssel), the base of this stack
  • refactor(site): move the composer layout out of AgentCreateForm #30291 composer frame
  • feat(site): keep project chat list caches in sync #30292 project chat list caches
  • feat(site): redesign the project page header #30293 project page header
  • feat(site): list project chats on the project page #30294 project chats list
  • feat(coderd): add chat project instructions storage and prompt injection #30367 instructions storage and prompt injection 👈
  • feat: add chat project instructions API #30368 instructions API
  • feat(site): add the project instructions editor dialog #30369 instructions editor dialog
  • feat(site): show project instructions in the project page details panel #30370 instructions Details panel

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
f0ssel added 30 commits September 19, 2026 01:57
@f0ssel
Merge branch 'f0ssel/chat-project-sharing' into f0ssel/chat-project-m…
0408ba5
…emories

Memory permissions now derive from the project owner and ACL, memory tools
and the extractor use scope-neutral names, and the extraction cursor table
is chat_memory_cursors.
@f0ssel
chore: regenerate rbac resource types for chat project memory
00f6b4b
@f0ssel
Merge branch 'f0ssel/chat-project-memories' into f0ssel/chat-memory-c…
7ccb1ec
…onsolidation

Drops personal memory: consolidation now runs only for project memory and
its journal follows the project ACL.
@f0ssel
Merge remote-tracking branch 'origin/f0ssel/chat-memory-consolidation…
1f0b373
…' into f0ssel/chat-projects-ui-folders
@f0ssel
feat(site): share chat projects and drop the personal memory toggle
08a1a50
The chat sharing popover now takes a chat or project target, and the
project page shows a Share control to users who may share it.
@f0ssel
refactor: take project sharing out of the memory stack
49e7232
Sharing (#29597) is parked; memory permissions follow the project owner
only and the memory migration returns to 000599.
@f0ssel
Merge remote-tracking branch 'origin/f0ssel/chat-project-memories' in…
0df0c77
…to f0ssel/chat-memory-consolidation
@f0ssel
Merge branch 'f0ssel/chat-project-memories' into f0ssel/chat-memory-c…
4dec64b
…onsolidation

Sharing is out of the stack; the consolidation migration returns to 000600.
@f0ssel
Merge remote-tracking branch 'origin/f0ssel/chat-memory-consolidation…
85e49e3
…' into f0ssel/chat-projects-ui-folders
@f0ssel
refactor(site): drop project sharing from the chat projects UI
980f871
Sharing (#29597) is parked; the sharing popover is chat-only again.
@f0ssel
fix(coderd): scope project names to their creator and validate the pr…
679cd04
…oject before other chat updates
@f0ssel
Merge remote-tracking branch 'origin/f0ssel/chat-projects' into f0sse…
df4d197
…l/chat-project-memories

# Conflicts:
#	coderd/database/dump.sql
#	coderd/database/unique_constraint.go
@f0ssel
fix(coderd): extract memory from unpruned history, hand off leftover …
37761d8
…drains, and gate memory lists on the memory resource
@f0ssel
Merge remote-tracking branch 'origin/f0ssel/chat-project-memories' in…
c6be116
…to f0ssel/chat-memory-consolidation

# Conflicts:
#	coderd/x/chatd/memory_extract.go
@f0ssel
refactor(coderd): name the chat project creator column owner_id
3721834
@f0ssel
Merge remote-tracking branch 'origin/f0ssel/chat-projects' into f0sse…
35dcf5e
…l/chat-project-memories

# Conflicts:
#	coderd/database/dump.sql
#	coderd/database/foreign_key_constraint.go
#	coderd/database/unique_constraint.go
#	docs/admin/security/audit-logs.md
@f0ssel
Merge remote-tracking branch 'origin/f0ssel/chat-project-memories' in…
433e8ad
…to f0ssel/chat-memory-consolidation
@f0ssel
fix(coderd): send full memory bodies through a rotating consolidation…
92413eb
… window and reject overlapping mutations
@f0ssel
Merge remote-tracking branch 'origin/f0ssel/chat-memory-consolidation…
f6ee5b4
…' into f0ssel/chat-projects-ui-folders
@f0ssel
fix(site): keep cached project data usable and surface project failur…
40b82ba
…es in the chat sidebar and composer
@f0ssel
Merge remote-tracking branch 'origin/main' into f0ssel/chat-projects
1ad6a2f
# Conflicts:
#	coderd/chat_routes.go
#	codersdk/chats.go
#	site/src/api/typesGenerated.ts
@f0ssel
Merge remote-tracking branch 'origin/f0ssel/chat-projects' into f0sse…
580f015
…l/chat-project-memories

# Conflicts:
#	coderd/chat_routes.go
#	codersdk/chats.go
@f0ssel
Merge remote-tracking branch 'origin/f0ssel/chat-project-memories' in…
0a97292
…to f0ssel/chat-memory-consolidation

# Conflicts:
#	coderd/chat_routes.go
@f0ssel
Merge remote-tracking branch 'origin/f0ssel/chat-memory-consolidation…
4fdadfe
…' into f0ssel/chat-projects-ui-folders

# Conflicts:
#	site/src/pages/AgentsPage/components/AgentCreateForm.tsx
#	site/src/pages/AgentsPage/components/ChatsSidebar/chats/ChatsPanel.tsx
@f0ssel
fix(coderd/x/chatd): reject consolidation merges into memories the mo…
b19f1b4
…del was not shown
@f0ssel
Merge remote-tracking branch 'origin/f0ssel/chat-memory-consolidation…
846302f
…' into f0ssel/chat-projects-ui-folders
@f0ssel
fix(site): deny a locked organization the user cannot use and add ret…
e1b84e9
…ries to project permission and move-menu failures
@f0ssel
fix(coderd): serialize memory renames with consolidation, retry faile…
a0f8003
…d runs at the cap, and record empty applies as skipped
@f0ssel
Merge remote-tracking branch 'origin/f0ssel/chat-memory-consolidation…
ef0433b
…' into f0ssel/chat-projects-ui-folders
@f0ssel
fix(site): reset the project dialog through its open lifecycle instea…
edcc130
…d of remounting it
jaaydenh added 5 commits October 6, 2026 16:00
@jaaydenh
Merge remote-tracking branch 'origin/main' into chat-project-page/com…
412dcb3
…poser-frame
@jaaydenh
Merge remote-tracking branch 'origin/chat-project-page/composer-frame…
f76351c
…' into chat-project-page/list-queries

# Conflicts:
#	site/src/pages/AgentsPage/exp/chatBoard/refreshChatList.test.tsx
@jaaydenh
Merge remote-tracking branch 'origin/chat-project-page/list-queries' …
c6dd81c
…into chat-project-page/header

# Conflicts:
#	site/src/pages/AgentsPage/AgentCreatePage.test.tsx
#	site/src/pages/AgentsPage/components/ProjectComposerFooter.stories.tsx
#	site/src/pages/AgentsPage/components/ProjectComposerFooter.tsx
@jaaydenh
Merge remote-tracking branch 'origin/chat-project-page/header' into c…
1bd2b78
…hat-project-page/chats-list
@jaaydenh
Merge remote-tracking branch 'origin/chat-project-page/chats-list' in…
4f68dfe
…to chat-project-page/instructions-storage

# Conflicts:
#	coderd/database/dump.sql
#	coderd/database/foreign_key_constraint.go
#	coderd/database/queries.sql.go
#	coderd/database/unique_constraint.go
jaaydenh added a commit that referenced this pull request Oct 6, 2026
@jaaydenh @f0ssel @claude
refactor(site): move the composer layout out of AgentCreateForm (#30291)
7d1191c
`AgentCreateForm` no longer takes the `header`/`footer` slots added in
#30378, and no longer owns the page wrapper. The centered `max-w-3xl`
wrapper moves into `AgentCreateFormFrame`, which the new-chat page, the
project page, and the board draft wrap around the form. The project page
renders its existing `ProjectComposerHeader` and `ProjectComposerFooter`
(#30379) around the form inside the frame, so nothing changes visually.
The form keeps its `project` prop, per-project drafts, and remount per
project from #30378.

`ChatDiffStats` (from `ChatTreeNode`) and `ProjectActionsMenuItems`
(from `ProjectFolders`) are moved into their own files unchanged so the
redesigned project page can reuse them.

Most of the `AgentCreateForm.tsx` diff is re-indentation; review with
whitespace hidden.

---

Stack (merge top to bottom). #30377 through #29583 are f0ssel's split of
the original #29583, and this stack sits on #29583:
- #30377 data layer and project dialog (f0ssel)
- #30378 new-chat form locked to a project (f0ssel)
- #30379 project page route (f0ssel)
- #29583 sidebar folders (f0ssel), the base of this stack
- #30291 composer frame 👈
- #30292 project chat list caches
- #30293 project page header
- #30294 project chats list
- #30367 instructions storage and prompt injection
- #30368 instructions API
- #30369 instructions editor dialog
- #30370 instructions Details panel

---------

Co-authored-by: Garrett Delfosse <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
jaaydenh added a commit that referenced this pull request Oct 6, 2026
@jaaydenh @f0ssel @claude
feat(site): keep project chat list caches in sync (#30292)
f32d0b1
Adds a project chat list query family (`projectChatsKey`) next to the
sidebar's chat lists, so the project page's chat list stays current.

- `updateInfiniteChatsCache`, `invalidateChatListQueries`,
`cancelChatListRefetches`, `cancelChatListQueries`, and the
archive-state patching cover both families. Project lists only hold
unarchived chats, so archived chats are dropped.
- `archiveChat` snapshots project lists and restores them when archiving
fails.
- A new project chat invalidates its project list instead of being
prepended. Prepending would shift the offset pages and repeat a row on
the next page.
- `findChatInListCaches` looks a chat up across both families.
`AgentsPageLayout` uses it for the chime's previous status and the
archive-and-delete `created_at`.

The family is kept outside `chatListFamilyKey` because the sidebar
helpers assume sidebar-shaped keys. The query factory that fills these
caches lands with its consumer in the chats list PR.

---

Stack (merge top to bottom). #30377 through #29583 are f0ssel's split of
the original #29583, and this stack sits on #29583:
- #30377 data layer and project dialog (f0ssel)
- #30378 new-chat form locked to a project (f0ssel)
- #30379 project page route (f0ssel)
- #29583 sidebar folders (f0ssel), the base of this stack
- #30291 composer frame
- #30292 project chat list caches 👈
- #30293 project page header
- #30294 project chats list
- #30367 instructions storage and prompt injection
- #30368 instructions API
- #30369 instructions editor dialog
- #30370 instructions Details panel

---------

Co-authored-by: Garrett Delfosse <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
jaaydenh added 2 commits October 6, 2026 16:19
@jaaydenh
Merge commit 'c28dc3c3c9' into resync-30293
7daea55
@jaaydenh
Merge origin/main into chat-project-page/header
de057a1
jaaydenh added a commit that referenced this pull request Oct 6, 2026
@jaaydenh @f0ssel @claude
feat(site): redesign the project page header (#30293)
8d50b9d
Redesigns the top of `/agents/projects/:projectId`: a left-aligned
header with the project icon, name, and an actions menu, then the
description and a badge row. The composer fills the page column.

- **Actions menu:** Edit project and Delete project replace the "Edit
project" button under the composer. Deleting toasts "Project deleted",
clears the project's composer drafts as the sidebar's delete does, and
returns to `/agents`, keeping the sidebar's filter query string.
- **Badges:** Project owner shows "you" for your own projects. Other
owners are looked up, with a skeleton while loading and "Unknown" on
error. Created shows the date, with the full timestamp in a
keyboard-focusable tooltip. Organization only appears when organizations
are shown.

`ProjectComposerHeader` (#30378) and `ProjectComposerFooter` with its
stories (#30379) are removed. The page keeps #30379's loading, "Project
not found", and retryable error states, and the `ProjectLoaded` story
now waits for the actions menu. The `ProjectComposer` story is removed
with the header, so `chatProjectNameMaxChars` and
`chatProjectDescriptionMaxChars` are no longer exported.

---

Stack (merge top to bottom). #30377 through #29583 are f0ssel's split of
the original #29583, and this stack sits on #29583:
- #30377 data layer and project dialog (f0ssel)
- #30378 new-chat form locked to a project (f0ssel)
- #30379 project page route (f0ssel)
- #29583 sidebar folders (f0ssel), the base of this stack
- #30291 composer frame
- #30292 project chat list caches
- #30293 project page header 👈
- #30294 project chats list
- #30367 instructions storage and prompt injection
- #30368 instructions API
- #30369 instructions editor dialog
- #30370 instructions Details panel

---------

Co-authored-by: Garrett Delfosse <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
jaaydenh added 2 commits October 6, 2026 16:39
@jaaydenh
Merge commit 'de057a1622' into resync-30294
7db14d4
@jaaydenh
Merge remote-tracking branch 'origin/main' into resync-30294
b4ea537
Base automatically changed from chat-project-page/chats-list to main October 7, 2026 04:08
jaaydenh added a commit that referenced this pull request Oct 7, 2026
@jaaydenh @f0ssel @claude
feat(site): list project chats on the project page (#30294)
a531ba3
<img width="1506" height="734" alt="Project page"
src="https://github.com/user-attachments/assets/bfcfba12-f229-4dfe-87a2-304bc0551ae1"
/>

Lists the project's unarchived chats below the composer, loaded from
`GET /api/v2/chats?project_id=` with infinite scroll. Each row shows the
status, title, PR state, owner, and AI Gateway cost (when enabled), with
the chat actions menu when the agents layout provides it. Row links keep
the sidebar's filter query string.

Adds the `projectChats` query factory, whose caches the previous PR
keeps in sync.

---

Stack (merge top to bottom). #30377 through #29583 are f0ssel's split of
the original #29583, and this stack sits on #29583:
- #30377 data layer and project dialog (f0ssel)
- #30378 new-chat form locked to a project (f0ssel)
- #30379 project page route (f0ssel)
- #29583 sidebar folders (f0ssel), the base of this stack
- #30291 composer frame
- #30292 project chat list caches
- #30293 project page header
- #30294 project chats list 👈
- #30367 instructions storage and prompt injection
- #30368 instructions API
- #30369 instructions editor dialog
- #30370 instructions Details panel

---------

Co-authored-by: Garrett Delfosse <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
jaaydenh added 5 commits October 7, 2026 07:51
@jaaydenh
Merge commit 'b4ea537a87' into chat-project-page/instructions-storage
1159d13
@jaaydenh
Merge commit 'a531ba39e5^' into chat-project-page/instructions-storage
8144356
@jaaydenh
Merge commit 'a531ba39e5' into chat-project-page/instructions-storage
08b1010
@jaaydenh
Merge remote-tracking branch 'origin/main' into chat-project-page/ins…
7ecde4d
…tructions-storage
@jaaydenh
Merge branch 'main' into chat-project-page/instructions-storage
70e457f
@jaaydenh
jaaydenh added this pull request to stack #30456 October 7, 2026 08:13
@jaaydenh
jaaydenh marked this pull request as ready for review October 7, 2026 14:39
@jaaydenh
jaaydenh requested a review from f0ssel October 7, 2026 14:39
f0ssel
f0ssel approved these changes Oct 7, 2026
View reviewed changes

@f0ssel f0ssel left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Just address TODOs and lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread coderd/x/chatd/ARCHITECTURE.md Outdated

TODO (#27079): messages can now carry a `workspace-file-reference` part (path, name, size, media type, workspace ID) for files uploaded into the chat's workspace. It is metadata only: no file link is written, coderd validates that the path is scoped to the chat's upload directory and that the workspace ID matches the chat's current binding, and prompt conversion renders the reference as text (`[workspace file: <name> (<size>) at <path>]`) so the bytes never reach the model. Describe this here.

TODO (#30349): projects can now hold instructions (`chat_project_instructions`, at most one row per project, organization-scoped, with `updated_by`). They are metadata reached through the project binding, and subagent chats, which carry no `project_id`, use their root chat's project. Describe this here.

@f0ssel f0ssel Oct 7, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Gotta do this one by hand

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread coderd/x/chatd/ARCHITECTURE.md Outdated

<!-- TODO(f0ssel): the memory index no longer lives in the `read_memory` tool description. At turn start the generation loop commits a model-only user row: a full `<project-memory-index>` snapshot when the prompt has none (first turn, or after compaction), otherwise a `<project-memory-index-update>` listing changes since the model last saw it. Tool definitions and the system prompt carry no memory state, so memory writes no longer invalidate the provider's cached prefix. Mid-turn only a snapshot dropped by compaction is restored, and never between an assistant step and its tool results. -->

TODO (#30349): project instructions are loaded on every turn in the parallel prep phase of the generation preparer, gated on the `chat-projects` experiment, sanitized again on read, and added by `buildSystemPrompt` as a `<project-instructions>` block after the memory guidance and before the user prompt. Subagents resolve them through their root chat. A load error other than no rows is logged and the turn continues without them. Because they are read per turn rather than snapshotted at chat creation, edits apply to existing chats on their next turn. Describe this here.

@f0ssel f0ssel Oct 7, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Same

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@linear-code

linear-code Bot commented Oct 8, 2026

Copy link
Copy Markdown

CODAGT-1347

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jaaydenh added 3 commits October 13, 2026 08:08
@jaaydenh
chore: update todo in architecture.md
816e6bc
@jaaydenh
Merge remote-tracking branch 'origin/main' into fix-instructions-stor…
ef8a2a9
…age-migration
@jaaydenh
fix(coderd/database/migrations): renumber chat project instructions m…
7ed37fe
…igration to 000619
@jaaydenh
jaaydenh merged commit ad85646 into main Oct 13, 2026
30 of 31 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@jaaydenh
jaaydenh deleted the chat-project-page/instructions-storage branch October 13, 2026 09:45
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@chatgpt-codex-connector chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] left review comments
@f0ssel f0ssel f0ssel approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@jaaydenh jaaydenh

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@jaaydenh @f0ssel
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.