Repository navigation
feat: add pinned skills to chats - #237
Conversation
Persist skills pinned to a chat in chatd.chat_pinned_skills behind the
fork-pinned-skills experiment, serve them on GET and PUT
/api/v2/chats/fork/{chat}/pinned-skills, and append their bodies as a
model-only message whenever the prompt does not show the current pins,
so they apply on every turn and return after compaction.
# Conflicts: # codersdk/fork_experiments.go
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. |
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8858f5e8b5
ℹ️ 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".
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c5e37faf7
ℹ️ 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".
… list after compaction
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ded66cd934
ℹ️ 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".
Merge evidence for head
|
This lets a user pin skills to a chat, behind the new
fork-pinned-skillsexperiment. Pinned skills apply on every turn until they are unpinned, without the user invoking them in each message. This PR is the backend only; the composer UI to pin skills comes in a later PR.Storage (
coderd/database/forkdb, chatdmig)chatd.chat_pinned_skills (chat_id, skill_source, skill_name), keyed on all three columns, and the forkdb queries to read, delete and insert pins. dbauthz and dbmetrics wrap the new queries.API (
coderd,codersdk)GET /api/v2/chats/fork/{chat}/pinned-skillsreturns the pins of a chat.PUTreplaces them all in one transaction; an empty list unpins every skill. PUT needs update permission on the chat, and only the chat owner may call it (403 otherwise, like sending a message), since pins run with the owner's tools and credentials.@x-apidocgen skip, like the other fork chat routes.chatd (
coderd/x/chatd)syncForkContextaskspinnedSkillsMessagefor a model-only message before each step. It loads each pin with the chat owner's permissions, the same way a skill invocation loads it, and renders the bodies in<pinned-skill>blocks, up to 64 KiB in total. A pin the owner can no longer use (deleted, disabled or unshared) is skipped.(none), so the model stops following an earlier list. A compacted prompt with no pins gets(none)once, because the summary may keep unpinned instructions; a chat that never pinned anything therefore gets one(none)row per compaction.ARCHITECTURE.mdgets two TODOs for the author.Known gaps:
sourceandnameas optional, though PUT rejects a pin without them.Validation on 8858f5e, run in a container:
go build ./coderd/... ./enterprise/... ./codersdk/...andgo veton the touched packages pass.TestPinnedSkillsMessage,TestTodoSnapshotMessage,TestForkChatPinnedSkills,TestForkChatRoutes,TestForkExperimentsand the swagger/endpoint-documented tests incoderd/coderdtestandenterprise/coderd/coderdenttestpass.TestPinnedSkillsMessagefail atfork_pinned_skills_internal_test.go:141.Main (
00e126098d, #235) was then merged in as8c5e37faf7; it overlaps this PR only inARCHITECTURE.mdand merged cleanly. fork-ci covers the merged head.Codex round 3 fixes (
ded66cd934): owner-only PUT, tested inTestForkChatPinnedSkills(site owner gets 403, pins unchanged), and(none)after compaction, tested inTestPinnedSkillsMessage. fork-ci runs both (-run '(?i)chat|skill|mcp|plugin' ./coderdand./coderd/x/...). Negative controls, by construction: without the owner check the site owner's PUT returns 200 and the 403 assertion fails; without thecompactedcondition the lastsyncPinsafter the summary returns no message andrequire.True(t, ok)fails.