MCPcopy Index your code
hub / github.com/coder/coder / updateChildLastInjectedContext

Function updateChildLastInjectedContext

coderd/x/chatd/subagent.go:1209–1237  ·  view source on GitHub ↗
(
	ctx context.Context,
	logger slog.Logger,
	store database.Store,
	chatID uuid.UUID,
	parts []codersdk.ChatMessagePart,
)

Source from the content-addressed store, hash-verified

1207}
1208
1209func updateChildLastInjectedContext(
1210 ctx context.Context,
1211 logger slog.Logger,
1212 store database.Store,
1213 chatID uuid.UUID,
1214 parts []codersdk.ChatMessagePart,
1215) error {
1216 parts = FilterContextPartsToLatestAgent(parts)
1217 param, err := BuildLastInjectedContext(parts)
1218 if err != nil {
1219 logger.Warn(ctx, "failed to marshal inherited injected context",
1220 slog.F("chat_id", chatID),
1221 slog.Error(err),
1222 )
1223 return xerrors.Errorf("marshal inherited injected context: %w", err)
1224 }
1225 if _, err := store.UpdateChatLastInjectedContext(ctx, database.UpdateChatLastInjectedContextParams{
1226 ID: chatID,
1227 LastInjectedContext: param,
1228 }); err != nil {
1229 logger.Warn(ctx, "failed to update inherited injected context",
1230 slog.F("chat_id", chatID),
1231 slog.Error(err),
1232 )
1233 return xerrors.Errorf("update inherited injected context: %w", err)
1234 }
1235
1236 return nil
1237}
1238
1239func (p *Server) sendSubagentMessage(
1240 ctx context.Context,

Callers 1

Calls 5

BuildLastInjectedContextFunction · 0.85
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected