LibreChat/api/server/services/Endpoints/agents/linkedInstructions.js
Atef Bellaaj 3c90cde7d8
🔗 feat: use LibreChat prompt groups as agent instructions (#16686)
* 🔗 feat(agents): use LibreChat prompt groups as agent instructions

Agents can link a prompt group revision or Production as their instructions. The link resolves at the start of each turn through a cached resolver. The cache clears on promote and delete. Editors without VIEW on the group see a restricted placeholder.

* fix: remove duplicate logger import from agent initialization tests

* fix: honor prompt management capabilities for linked agent instructions

* test: seed prompt manager capabilities in authorization fixtures

* fix: clear acknowledged linked prompt edits before version restore

* test: adapt merged chain coverage to prompt-aware payload helper

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-04 21:27:26 -04:00

25 lines
1 KiB
JavaScript

const { logger } = require('@librechat/data-schemas');
const { CacheKeys } = require('librechat-data-provider');
const { createPromptService, createLinkedInstructionsResolver } = require('@librechat/api');
const { grantPermission } = require('~/server/services/PermissionService');
const { getLogStores } = require('~/cache');
const db = require('~/models');
/**
* Shared resolver for an agent's `instructionsPrompt` link. Resolve and cache
* logic lives in `@librechat/api` (`createLinkedInstructionsResolver`); this
* module wires in the LibreChat prompt service and the
* `AGENT_LINKED_INSTRUCTIONS` cache namespace (`~/cache/getLogStores.js`).
*/
const linkedInstructionsResolver = createLinkedInstructionsResolver({
promptService: createPromptService({ db, grantPermission }),
cache: getLogStores(CacheKeys.AGENT_LINKED_INSTRUCTIONS),
logger,
});
/** @returns {import('@librechat/api').ResolveLinkedInstructions} */
function getLinkedInstructionsResolver() {
return linkedInstructionsResolver;
}
module.exports = { getLinkedInstructionsResolver };