MCPcopy Create free account
hub / github.com/coder/coder / hasPersistedInstructionFiles

Function hasPersistedInstructionFiles

coderd/x/chatd/instruction.go:135–157  ·  view source on GitHub ↗

hasPersistedInstructionFiles reports whether messages include a persisted context-file part that should suppress another baseline instruction-file lookup. The workspace-agent skill-only sentinel is ignored so default instructions still load on fresh chats.

(
	messages []database.ChatMessage,
)

Source from the content-addressed store, hash-verified

133// instruction-file lookup. The workspace-agent skill-only sentinel is
134// ignored so default instructions still load on fresh chats.
135func hasPersistedInstructionFiles(
136 messages []database.ChatMessage,
137) bool {
138 for _, msg := range messages {
139 if !msg.Content.Valid ||
140 !bytes.Contains(msg.Content.RawMessage, []byte(`"context-file"`)) {
141 continue
142 }
143 var parts []codersdk.ChatMessagePart
144 if err := json.Unmarshal(msg.Content.RawMessage, &parts); err != nil {
145 continue
146 }
147 for _, part := range parts {
148 if part.Type != codersdk.ChatMessagePartTypeContextFile ||
149 !part.ContextFileAgentID.Valid ||
150 part.ContextFilePath == AgentChatContextSentinelPath {
151 continue
152 }
153 return true
154 }
155 }
156 return false
157}
158
159func mergeSkillMetas(
160 persisted []chattool.SkillMeta,

Callers 2

runChatMethod · 0.85

Calls 2

ContainsMethod · 0.45
UnmarshalMethod · 0.45

Tested by 1