Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(skill-management): fall back to name selector when agentDocumentId fails to resolve (#20726)

Arvin Xu849e747633c3
diff --git a/apps/server/src/services/skillManagement/SkillManagementDocumentService.test.ts b/apps/server/src/services/skillManagement/SkillManagementDocumentService.test.ts
index 19572a92a2a..c04b6736c6c 100644
--- a/apps/server/src/services/skillManagement/SkillManagementDocumentService.test.ts
+++ b/apps/server/src/services/skillManagement/SkillManagementDocumentService.test.ts
@@ -586,6 +586,53 @@ describe('SkillManagementDocumentService', () => {
);
});
+ it('falls back to the name selector when a mistyped agent document id is also given (T-507)', async () => {
+ const { service } = createService();
+ const created = await service.createSkill({
+ agentId: 'agent-1',
+ bodyMarkdown: skillBody(),
+ description: 'Name fallback lookup',
+ name: 'dual-gate-review',
+ title: 'Dual Gate Review',
+ });
+
+ // Reproduces the SATO incident: the model passes both selectors but copies
+ // one id character wrong; the stable name selector must still resolve.
+ await expect(
+ service.getSkill({
+ agentDocumentId: '30b88ca8-5c56-4e09-96b9-4610e39c0add',
+ agentId: 'agent-1',
+ includeContent: true,
+ name: 'dual-gate-review',
+ }),
+ ).resolves.toEqual(
+ expect.objectContaining({
+ bundle: created.bundle,
+ index: created.index,
+ name: 'dual-gate-review',
+ }),
+ );
+ });
+
+ it('stays not-found when the mistyped id has no name selector to fall back on', async () => {
+ const { service } = createService();
+ await service.createSkill({
+ agentId: 'agent-1',
+ bodyMarkdown: skillBody(),
+ description: 'Id only lookup',
+ name: 'id-only-skill',
+ title: 'Id Only Skill',
+ });
+
+ await expect(
+ service.getSkill({
+ agentDocumentId: '30b88ca8-5c56-4e09-96b9-4610e39c0add',
+ agentId: 'agent-1',
+ name: undefined,
+ }),
+ ).resolves.toBeUndefined();
+ });
+
it('renames bundle identity and synchronizes index frontmatter content', async () => {
const { agentDocumentModel, documentService, service } = createService();
const created = await service.createSkill({
diff --git a/apps/server/src/services/skillManagement/SkillManagementDocumentService.ts b/apps/server/src/services/skillManagement/SkillManagementDocumentService.ts
index 9495e165af0..174a79e0869 100644
--- a/apps/server/src/services/skillManagement/SkillManagementDocumentService.ts
+++ b/apps/server/src/services/skillManagement/SkillManagementDocumentService.ts
@@ -458,16 +458,19 @@ export class SkillManagementDocumentService {
): Promise<SkillAgentDocument | undefined> {
if (target.agentDocumentId) {
const doc = await this.agentDocumentModel.findById(target.agentDocumentId);
- if (!doc) return undefined;
- if (doc.agentId !== agentId) return undefined;
- if (doc.fileType === SKILL_BUNDLE_FILE_TYPE) return doc;
+ if (doc && doc.agentId === agentId) {
+ if (doc.fileType === SKILL_BUNDLE_FILE_TYPE) return doc;
- if (doc.fileType === SKILL_INDEX_FILE_TYPE && doc.parentId) {
- const bundle = await this.agentDocumentModel.findByDocumentId(agentId, doc.parentId);
- if (bundle?.fileType === SKILL_BUNDLE_FILE_TYPE) return bundle;
+ if (doc.fileType === SKILL_INDEX_FILE_TYPE && doc.parentId) {
+ const bundle = await this.agentDocumentModel.findByDocumentId(agentId, doc.parentId);
+ if (bundle?.fileType === SKILL_BUNDLE_FILE_TYPE) return bundle;
+ }
}
- return undefined;
+ // Fall through to the name selector when the agent document id does not
+ // resolve to a bundle under this agent. LLM tool calls commonly pass both
+ // selectors, and one mistyped id character must not hard-fail the read
+ // when the stable skill name is also provided (T-507).
}
if (!target.name) return undefined;