Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🫛 test: Separate an Authoring Run From a Skills-Off Run (#16128)
lia-by-librechat[bot]d281c31d542f
diff --git a/e2e/setup/fake-model.js b/e2e/setup/fake-model.jsindex 0545b42ce9..69f02b71d0 100644--- a/e2e/setup/fake-model.js+++ b/e2e/setup/fake-model.js@@ -83,6 +83,8 @@ const HANDOFF_TOOL_PREFIX = 'lc_transfer_to_';const CREATE_FILE_AUTHORING_FINAL_TEXT = 'E2E file authoring complete';const EDIT_FILE_AUTHORING_FINAL_TEXT = 'E2E file edit complete';const SKILL_ASSERTION_FINAL_TEXT = 'E2E skill assertion passed';+/** Summary for a run with no invocable skill yet, but the tool to invoke one it authors. */+const SKILL_ASSERTION_AUTHORING_ONLY_SUMMARY = 'authoring-only';const MANUAL_SKILL_ASSERTION_FINAL_TEXT = 'E2E manual skill assertion passed';const SKILL_TOOL_ASSERTION_FINAL_TEXT = 'E2E skill tool assertion passed';const PROVIDER_FILE_ASSERTION_FINAL_TEXT = 'E2E provider file assertion passed';@@ -237,22 +239,31 @@ function getMarkerValue(text, marker) {);}-function collectToolNames(agents) {- const names = new Set();- const add = (name) => {- if (typeof name === 'string' && name) {- names.add(name);+/**+ * Every tool name the run advertises, mapped to the definition the model sees+ * for it. `toolDefinitions` is the array handed to the provider, so it wins+ * over a same-named entry in `tools`; registry-only names keep whatever the+ * earlier sources carried, which may be nothing. Names alone drive most+ * assertions, but the `skill` tool ships two descriptions for one name, so the+ * definition has to survive collection.+ */+function collectToolDefinitions(agents) {+ const definitions = new Map();+ const add = (name, definition) => {+ if (typeof name !== 'string' || !name) {+ return;}+ definitions.set(name, definition ?? definitions.get(name));};for (const agent of agents ?? []) {if (!agent) {continue;}for (const tool of agent.tools ?? []) {- add(tool?.name);+ add(tool?.name, tool);}for (const def of agent.toolDefinitions ?? []) {- add(def?.name);+ add(def?.name, def);}if (agent.toolRegistry && typeof agent.toolRegistry.keys === 'function') {for (const name of agent.toolRegistry.keys()) {@@ -260,7 +271,11 @@ function collectToolNames(agents) {}}}- return names;+ return definitions;+}++function collectToolNames(agents) {+ return new Set(collectToolDefinitions(agents).keys());}async function getStreamAgentView({ graph, messages, options, runManager }) {@@ -282,10 +297,12 @@ async function getStreamAgentView({ graph, messages, options, runManager }) {systemRunnable && typeof systemRunnable.invoke === 'function'? await systemRunnable.invoke(messages): messages;+ const toolDefinitions = collectToolDefinitions(agentContext ? [agentContext] : []);return {agentId,messages: promptMessages,- toolNames: collectToolNames(agentContext ? [agentContext] : []),+ toolDefinitions,+ toolNames: new Set(toolDefinitions.keys()),};}@@ -913,7 +930,22 @@ function expectedSkillBodyMarker(skillName) {return `# ${skillName}`;}-function skillAssertionResponses({ messages, assertion, toolNames }) {+/**+ * The `skill` tool's authoring-only wording, from `AUTHORED_SKILL_CONSTRAINTS`+ * in `packages/api/src/agents/tools.ts`. A run that may write+ * `skills/{skillName}/SKILL.md` gets that variant instead of the SDK's+ * catalog-only text, which is what makes the two cases below separable from+ * the prompt alone.+ */+const AUTHORED_SKILL_GUIDANCE = 'a skill you created in this conversation';++function isAuthoringSkillTool(definition) {+ return typeof definition?.description === 'string'+ ? definition.description.includes(AUTHORED_SKILL_GUIDANCE)+ : false;+}++function skillAssertionResponses({ messages, assertion, toolNames, toolDefinitions }) {const failures = [];if (assertion.error) {failures.push(assertion.error);@@ -921,10 +953,23 @@ function skillAssertionResponses({ messages, assertion, toolNames }) {const promptText = collectPromptText(messages).join('\n');const skillPrimeMessages = collectSkillPrimeMessages(messages);- if (assertion.required.length > 0 && !toolNames.has(SKILL_TOOL_NAME)) {+ const skillToolAdvertised = toolNames.has(SKILL_TOOL_NAME);+ /**+ * An empty catalog no longer implies an absent `skill` tool: a run that can+ * author skills keeps the tool bound so the model can invoke one it writes+ * mid-run, and it gets the authoring variant's description to say so. Both+ * states still have to be told apart, so the pass text names which one+ * happened — `none` for no tool at all, `authoring-only` for a tool with+ * nothing yet to invoke — and neither string contains the other, so a spec+ * asserting one cannot pass on the other.+ */+ const authoringSkillTool =+ skillToolAdvertised && isAuthoringSkillTool(toolDefinitions?.get(SKILL_TOOL_NAME));++ if (assertion.required.length > 0 && !skillToolAdvertised) {failures.push(`${SKILL_TOOL_NAME} tool was not advertised`);}- if (assertion.required.length === 0 && toolNames.has(SKILL_TOOL_NAME)) {+ if (assertion.required.length === 0 && skillToolAdvertised && !authoringSkillTool) {failures.push(`${SKILL_TOOL_NAME} tool was unexpectedly advertised`);}for (const name of assertion.required) {@@ -960,13 +1005,18 @@ function skillAssertionResponses({ messages, assertion, toolNames }) {}return {responses: [- `${SKILL_ASSERTION_FINAL_TEXT}: ${- assertion.required.length > 0 ? assertion.required.join(', ') : 'none'- }`,+ `${SKILL_ASSERTION_FINAL_TEXT}: ${resolveSkillAssertionSummary(assertion, authoringSkillTool)}`,],};}+function resolveSkillAssertionSummary(assertion, authoringSkillTool) {+ if (assertion.required.length > 0) {+ return assertion.required.join(', ');+ }+ return authoringSkillTool ? SKILL_ASSERTION_AUTHORING_ONLY_SUMMARY : 'none';+}+function manualSkillAssertionResponses({ messages, skillName }) {const taggedPrime = collectSkillPrimeMessages(messages).find((message) => message.name === skillName && message.trigger === 'manual',@@ -2882,6 +2932,7 @@ function resolveResponses({ graph, messages, text, toolNames }) {messages: agentView.messages,assertion: parseSkillAssertion(text, agentView.agentId),toolNames: agentView.toolNames,+ toolDefinitions: agentView.toolDefinitions,});},};diff --git a/e2e/specs/mock/agent-skills.spec.ts b/e2e/specs/mock/agent-skills.spec.tsindex 0f888b3bae..2f9aa47a80 100644--- a/e2e/specs/mock/agent-skills.spec.ts+++ b/e2e/specs/mock/agent-skills.spec.ts@@ -13,6 +13,8 @@ import { fetchJson, getAccessToken, requestJson, sendMessage } from './helpers';const DEPLOYMENT_SKILL_NAME = 'e2e-deployment-skill';const SKILL_ASSERTION_MARKER = 'E2E_ASSERT_SKILLS:';const SKILL_ASSERTION_FINAL_TEXT = 'E2E skill assertion passed';+const SKILL_ASSERTION_AUTHORING_ONLY_TEXT = `${SKILL_ASSERTION_FINAL_TEXT}: authoring-only`;+const SKILL_ASSERTION_NO_SKILLS_TEXT = `${SKILL_ASSERTION_FINAL_TEXT}: none`;const MANUAL_SKILL_ASSERTION_MARKER = 'E2E_ASSERT_MANUAL_SKILL:';const MANUAL_SKILL_ASSERTION_FINAL_TEXT = 'E2E manual skill assertion passed';const SKILL_TOOL_INVOCATION_MARKER = 'E2E_INVOKE_SKILL:';@@ -448,7 +450,10 @@ test.describe('Agent Builder skills', () => {/** Emptying the allowlist stays in Selected: the mode is explicit now, so* removing the last skill no longer infers Off. Only `skills` is written,* and an explicit Selected with nothing selected resolves to no skills at- * runtime, which the picker and the run below both confirm. */+ * runtime, which the picker and the run below both confirm. Skills stay+ * enabled, so that run can still author one: it keeps the `skill` tool in+ * its authoring variant with nothing in the catalog, which is what+ * separates this from the Off agent below. */const emptiedResponsePromise = waitForAgentMutation(page, 'PATCH', createdAgentId);await form.getByRole('button', { name: 'Save', exact: true }).click();const emptiedResponse = await emptiedResponsePromise;@@ -477,13 +482,13 @@ test.describe('Agent Builder skills', () => {await expectSkillAbsentFromPicker(page, disabledPickerSearch, inlineSkillName);await closeSkillPicker(page, disabledPickerSearch);- const disabledRuntimeResponse = await sendMessage(+ const emptiedRuntimeResponse = await sendMessage(page,`${SKILL_ASSERTION_MARKER}!${DEPLOYMENT_SKILL_NAME},!${inlineSkillName}`,);- expect(disabledRuntimeResponse.ok()).toBeTruthy();+ expect(emptiedRuntimeResponse.ok()).toBeTruthy();await expect(- page.getByTestId('messages-view').getByText(`${SKILL_ASSERTION_FINAL_TEXT}: none`),+ page.getByTestId('messages-view').getByText(SKILL_ASSERTION_AUTHORING_ONLY_TEXT),).toBeVisible({ timeout: 30000 });} finally {await settleCleanup([@@ -634,8 +639,10 @@ test.describe('Agent Builder skills', () => {].join('\n'),);expect(disabledRuntimeResponse.ok()).toBeTruthy();+ /** Off turns authoring off with invocation, so this run gets no `skill`+ * tool at all — unlike the emptied-allowlist run above. */await expect(- page.getByTestId('messages-view').getByText(`${SKILL_ASSERTION_FINAL_TEXT}: none`),+ page.getByTestId('messages-view').getByText(SKILL_ASSERTION_NO_SKILLS_TEXT),).toBeVisible({ timeout: 30000 });} finally {await settleCleanup([diff --git a/packages/api/src/agents/tools.spec.ts b/packages/api/src/agents/tools.spec.tsindex 3764d1045c..0455c7cb0f 100644--- a/packages/api/src/agents/tools.spec.ts+++ b/packages/api/src/agents/tools.spec.ts@@ -67,6 +67,8 @@ CONSTRAINTS:enableToolOutputReferences === true ? 'bash {{tool<idx>turn<turn>}}' : 'bash',}));+import fs from 'fs';+import path from 'path';import { CODE_EXECUTION_TOOLS } from '@librechat/agents';import type { LCTool, LCToolRegistry } from '@librechat/agents';import { CODE_WORKSPACE_OPERATIONS, Constants } from 'librechat-data-provider';@@ -645,6 +647,41 @@ describe('installed @librechat/agents skill tool canary', () => {});});+describe('e2e skill assertion harness agreement', () => {+ /**+ * `e2e/setup/fake-model.js` tells an authoring run apart from a skills-off run+ * by grepping the advertised `skill` description for one sentence. Both runs+ * can reach the model with nothing in the catalog, and only that sentence+ * separates them, so the harness reports `authoring-only` for one and `none`+ * for the other. Reword the description without this test and the harness+ * silently calls every authoring run skills-off, which reads as an+ * `agent-skills.spec.ts` failure with no mention of the rewording.+ *+ * The literal is read from the harness rather than repeated here: a copy+ * would keep passing after the harness changed.+ */+ const guidance = (() => {+ const harness = fs.readFileSync(+ path.resolve(__dirname, '../../../../e2e/setup/fake-model.js'),+ 'utf8',+ );+ const match = /const AUTHORED_SKILL_GUIDANCE = '([^']+)';/.exec(harness);+ if (!match) {+ throw new Error('AUTHORED_SKILL_GUIDANCE was not found in e2e/setup/fake-model.js');+ }+ return match[1];+ })();++ it('ships the sentence the harness greps for, only on the authoring variant', () => {+ const { SkillToolDefinition } = jest.requireActual('@librechat/agents') as {+ SkillToolDefinition: { description: string };+ };++ expect(buildAuthoringSkillToolDescription(SkillToolDefinition.description)).toContain(guidance);+ expect(SkillToolDefinition.description).not.toContain(guidance);+ });+});+describe('registerCodeExecutionTools', () => {it('advertises selected named actions to the model', () => {const result = registerCodeExecutionTools({