fix(skill): recognize empty catalog tombstones

This commit is contained in:
Tianyi Cui
2026-07-29 20:44:06 +08:00
parent 709d545e7c
commit cf390cc6fd
2 changed files with 7 additions and 2 deletions

View File

@@ -18,7 +18,7 @@ export const inject = ['agents', 'tools', 'skills']
const DEFAULT_CATALOG_DESCRIPTION_MAX_LENGTH = 500
const CATALOG_ENTRIES_START = '<available_skills>\n'
const CATALOG_ENTRIES_END = '\n</available_skills>'
const CATALOG_ENTRIES_END = '</available_skills>'
const PLUGIN_SOURCE = { kind: 'plugin', plugin: 'dsh-tool-skill' } as const
/** Model-facing skill catalog configuration. */
@@ -275,7 +275,9 @@ function catalogContentDigest(content: UserMessage['content']): string | undefin
const entriesStart = start + CATALOG_ENTRIES_START.length
const end = text.indexOf(CATALOG_ENTRIES_END, entriesStart)
if (end === -1) return undefined
return digestCatalogEntries(text.slice(entriesStart, end))
const renderedEntries = text.slice(entriesStart, end)
const entries = renderedEntries.endsWith('\n') ? renderedEntries.slice(0, -1) : renderedEntries
return digestCatalogEntries(entries)
}
function catalogDescription(value: string, maxLength: number): string {

View File

@@ -320,6 +320,9 @@ describe('dsh-tool-skill', () => {
expect(JSON.stringify(removal.data.content)).toContain('No skills are currently available')
expect(JSON.stringify(removal.data.content)).not.toContain('first-skill')
expect(JSON.stringify(removal.data.content)).not.toContain('second-skill')
await fireStep(ctx, agent, 1, 4)
expect(catalogMessages(session)).toHaveLength(3)
})
it('resumes from the latest valid visible catalog content', async () => {