Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Restore ownership on saved skill retry

Fei2411478693c7fff2
diff --git a/ds-bot/src/host/learning.js b/ds-bot/src/host/learning.js
index b5b433a5..f1662d28 100644
--- a/ds-bot/src/host/learning.js
+++ b/ds-bot/src/host/learning.js
@@ -351,6 +351,8 @@ export function install(rt) {
if (current === undefined || current.description !== proposal.description || current.content !== proposal.content) {
throw new Error(`${proposal.name} changed since this was proposed`)
}
+ store.learned[bot.id] = [...new Set([...(store.learned[bot.id] ?? []), current.name])]
+ await persist()
} else {
if (current !== undefined) throw new Error(`A skill named ${proposal.name} exists now`)
const item = await rt.capabilitySave({ name: proposal.name, kind: 'skill', description: proposal.description, content: proposal.content }, { botId: bot.id, ui: false })
diff --git a/ds-bot/test/learning.test.js b/ds-bot/test/learning.test.js
index 5e042524..27a9347e 100644
--- a/ds-bot/test/learning.test.js
+++ b/ds-bot/test/learning.test.js
@@ -268,6 +268,44 @@ test('a failed create attachment can be retried without resaving or losing the p
assert.ok(runtime.teamState().bots.b2.capabilities.includes('release-checks'))
})
+test('a recreated approved skill is learned when its saved proposal is retried', async t => {
+ const runtime = await startRuntime({ replies: [createReply] })
+ t.after(() => runtime.stop())
+ await finishTurn(runtime.ctx)
+ await until(() => Object.keys(runtime.learningState().proposals ?? {}).length === 1)
+ const proposal = Object.values(runtime.learningState().proposals)[0]
+ const endpoint = runtime.rt.capabilityEndpoint
+ let fail = true
+ runtime.rt.capabilityEndpoint = async (name, body, ...args) => {
+ if (name === 'bot-capability' && fail) {
+ fail = false
+ throw new Error('temporary attachment failure')
+ }
+ return endpoint(name, body, ...args)
+ }
+
+ const first = await runtime.call('learning-answer', { id: proposal.id, approve: true })
+ assert.equal(first.ok, false)
+ assert.equal(runtime.learningState().proposals[proposal.id].saved, true)
+ assert.deepEqual(runtime.learningState().learned.b2, ['release-checks'])
+
+ const deleted = await runtime.call('capability-delete', { name: 'release-checks' })
+ assert.equal(deleted.ok, true)
+ assert.deepEqual(runtime.learningState().learned.b2, [])
+ await runtime.call('capability-save', {
+ name: 'release-checks',
+ kind: 'skill',
+ description: 'Use when checking a release.',
+ content: 'Run the release checks.',
+ })
+
+ const retry = await runtime.call('learning-answer', { id: proposal.id, approve: true })
+ assert.equal(retry.value.applied, true)
+ assert.equal(runtime.learningState().proposals[proposal.id], undefined)
+ assert.deepEqual(runtime.learningState().learned.b2, ['release-checks'])
+ assert.ok(runtime.teamState().bots.b2.capabilities.includes('release-checks'))
+})
+
test('a failed create retry refuses a skill edited after it was saved', async t => {
const runtime = await startRuntime({ replies: [createReply] })
t.after(() => runtime.stop())