updateLastInjectedContext persists the injected context parts (AGENTS.md files and skills) on the chat row so they are directly queryable without scanning messages. This is best-effort — a failure here is logged but does not block the turn.
(ctx context.Context, chatID uuid.UUID, parts []codersdk.ChatMessagePart)
| 9128 | // best-effort — a failure here is logged but does not block |
| 9129 | // the turn. |
| 9130 | func (p *Server) updateLastInjectedContext(ctx context.Context, chatID uuid.UUID, parts []codersdk.ChatMessagePart) { |
| 9131 | param := pqtype.NullRawMessage{Valid: false} |
| 9132 | if parts != nil { |
| 9133 | raw, err := json.Marshal(parts) |
| 9134 | if err != nil { |
| 9135 | p.logger.Warn(ctx, "failed to marshal injected context", |
| 9136 | slog.F("chat_id", chatID), |
| 9137 | slog.Error(err), |
| 9138 | ) |
| 9139 | return |
| 9140 | } |
| 9141 | param = pqtype.NullRawMessage{RawMessage: raw, Valid: true} |
| 9142 | } |
| 9143 | if _, err := p.db.UpdateChatLastInjectedContext(ctx, database.UpdateChatLastInjectedContextParams{ |
| 9144 | ID: chatID, |
| 9145 | LastInjectedContext: param, |
| 9146 | }); err != nil { |
| 9147 | p.logger.Warn(ctx, "failed to update injected context", |
| 9148 | slog.F("chat_id", chatID), |
| 9149 | slog.Error(err), |
| 9150 | ) |
| 9151 | } |
| 9152 | } |
| 9153 | |
| 9154 | // resolveUserCompactionThreshold looks up the user's per-model |
| 9155 | // compaction threshold override. Returns the override value and |
no test coverage detected