🏇 feat: Register SDK-Backed Agents for Native Chat (#18114)
Some checks are pending
Docker Dev Images Build / publish (push) Waiting to run
Sync Helm Chart Tags / Ignore non-main push (push) Waiting to run
Sync Helm Chart Tags / Sync chart tags (push) Waiting to run

* feat: register SDK-backed agents through agent management

* fix: gate SDK binding writes and preserve native lifecycle
This commit is contained in:
Danny Avila 2026-11-13 13:02:53 -05:00 • committed by GitHub
parent fb3b299de6
commit fad2c51da4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 775 additions and 3 deletions

View file

@ -53,6 +53,8 @@ const {
applyInstructionsPromptUnset,
instructionsContentForScan,
authorizeAgentRestore,
applySdkAgentBindingWrite,
getSdkAgentWriteErrorStatus,
} = require('@librechat/api');
const {
Time,
@ -765,6 +767,12 @@ const createAgentHandler = async (req, res) => {
normalizeToolResourceFiles(req.body?.tool_resources);
const validatedData = agentCreateSchema.parse(req.body);
const { tools = [], ...agentData } = removeNullishValues(validatedData);
applySdkAgentBindingWrite(
agentData,
validatedData.sdk_runtime,
req.config?.endpoints?.agents,
req.user?.role,
);
if (
(!isCodeInterpreterCapabilityEnabled(req) || !tools.includes(Tools.execute_code)) &&
@ -1109,6 +1117,12 @@ const updateAgentHandler = async (req, res) => {
...rest
} = validatedData;
let updateData = removeNullishValues(rest);
applySdkAgentBindingWrite(
updateData,
validatedData.sdk_runtime,
req.config?.endpoints?.agents,
req.user?.role,
);
if (codeEnvironmentIdField !== undefined) {
updateData.code_environment_id = codeEnvironmentIdField;
}
@ -1519,6 +1533,12 @@ const duplicateAgentHandler = async (req, res) => {
id: newAgentId,
author: userId,
});
applySdkAgentBindingWrite(
newAgentData,
newAgentData.sdk_runtime,
req.config?.endpoints?.agents,
req.user?.role,
);
if (!validateAgentCodeEnvironmentAllowlist(req, res, newAgentData.code_environment_ids)) {
return;
}
@ -1746,7 +1766,7 @@ const duplicateAgentHandler = async (req, res) => {
if (error?.statusCode === 409) {
return res.status(409).json({ error: error.message });
}
res.status(500).json({ error: error.message });
res.status(getSdkAgentWriteErrorStatus(error)).json({ error: error.message });
}
};
@ -2096,6 +2116,12 @@ const revertAgentVersionHandler = async (req, res) => {
if (!revertVersion) {
return res.status(404).json({ error: `Version ${version_index} not found` });
}
applySdkAgentBindingWrite(
revertVersion,
revertVersion.sdk_runtime,
req.config?.endpoints?.agents,
req.user?.role,
);
if (!validateAgentCodeEnvironmentAllowlist(req, res, revertVersion.code_environment_ids)) {
return;
}
@ -2260,7 +2286,7 @@ const revertAgentVersionHandler = async (req, res) => {
if (error?.statusCode === 409) {
return res.status(409).json({ error: error.message });
}
res.status(500).json({ error: error.message });
res.status(getSdkAgentWriteErrorStatus(error)).json({ error: error.message });
}
};
/**