agentbay_knowledge_sync
Batch sync knowledge entries from your local agent memory to AgentBay with deduplication by source and sourceKey. Full mode deprecates entries deleted locally.
Instructions
Batch sync knowledge entries from your local memory to AgentBay. Uses source+sourceKey for dedup. Mode "full" also deprecates entries deleted locally.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project ID | |
| source | Yes | Your agent identifier (e.g. "openclaw", "claude-code", "cursor") | |
| entries | Yes | Knowledge entries to sync (max 100) | |
| mode | No | "upsert" (default) creates/updates. "full" also deprecates missing entries. |
Implementation Reference
- src/index.ts:780-807 (registration)Tool registration via server.tool() with name 'agentbay_knowledge_sync', description, Zod schema for inputs, and async handler function.
server.tool( 'agentbay_knowledge_sync', 'Batch sync knowledge entries from your local memory to AgentBay. Uses source+sourceKey for dedup. Mode "full" also deprecates entries deleted locally.', { projectId: z.string().describe('Project ID'), source: z.string().describe('Your agent identifier (e.g. "openclaw", "claude-code", "cursor")'), entries: z.array(z.object({ sourceKey: z.string().describe('Unique ID from your side'), type: z.enum(['PATTERN', 'PITFALL', 'ARCHITECTURE', 'DEPENDENCY', 'TEST_INSIGHT', 'PERFORMANCE', 'DECISION', 'CONTEXT']), title: z.string().describe('Short title'), content: z.string().describe('Full content'), tags: z.array(z.string()).optional(), filePaths: z.array(z.string()).optional(), confidence: z.number().min(0).max(1).optional(), })).describe('Knowledge entries to sync (max 100)'), mode: z.enum(['upsert', 'full']).optional().describe('"upsert" (default) creates/updates. "full" also deprecates missing entries.'), }, async ({ projectId, source, entries, mode }) => { const data = await apiPost(`/api/v1/projects/${projectId}/knowledge/sync`, { source, entries, mode: mode || 'upsert' }); if (data.error) return { content: [{ type: 'text' as const, text: `Error: ${data.error}` }] }; let text = `Sync complete (source: ${source}, mode: ${data.mode}):\n`; text += `- Created: ${data.created}\n- Updated: ${data.updated}\n- Unchanged: ${data.unchanged}`; if (data.deprecated > 0) text += `\n- Deprecated: ${data.deprecated}`; text += `\n- Total: ${data.total}`; if (data.errors?.length) text += `\n\nErrors:\n${data.errors.map((e: string) => `- ${e}`).join('\n')}`; return { content: [{ type: 'text' as const, text }] }; } ); - src/index.ts:783-796 (schema)Zod schema defining the input parameters: projectId (string), source (string), entries (array of objects with sourceKey, type, title, content, optional tags/filePaths/confidence), and optional mode (upsert/full).
{ projectId: z.string().describe('Project ID'), source: z.string().describe('Your agent identifier (e.g. "openclaw", "claude-code", "cursor")'), entries: z.array(z.object({ sourceKey: z.string().describe('Unique ID from your side'), type: z.enum(['PATTERN', 'PITFALL', 'ARCHITECTURE', 'DEPENDENCY', 'TEST_INSIGHT', 'PERFORMANCE', 'DECISION', 'CONTEXT']), title: z.string().describe('Short title'), content: z.string().describe('Full content'), tags: z.array(z.string()).optional(), filePaths: z.array(z.string()).optional(), confidence: z.number().min(0).max(1).optional(), })).describe('Knowledge entries to sync (max 100)'), mode: z.enum(['upsert', 'full']).optional().describe('"upsert" (default) creates/updates. "full" also deprecates missing entries.'), }, - src/index.ts:797-807 (handler)The async handler function that calls apiPost to /api/v1/projects/{projectId}/knowledge/sync, then formats a response showing created/updated/unchanged/deprecated counts and any errors.
async ({ projectId, source, entries, mode }) => { const data = await apiPost(`/api/v1/projects/${projectId}/knowledge/sync`, { source, entries, mode: mode || 'upsert' }); if (data.error) return { content: [{ type: 'text' as const, text: `Error: ${data.error}` }] }; let text = `Sync complete (source: ${source}, mode: ${data.mode}):\n`; text += `- Created: ${data.created}\n- Updated: ${data.updated}\n- Unchanged: ${data.unchanged}`; if (data.deprecated > 0) text += `\n- Deprecated: ${data.deprecated}`; text += `\n- Total: ${data.total}`; if (data.errors?.length) text += `\n\nErrors:\n${data.errors.map((e: string) => `- ${e}`).join('\n')}`; return { content: [{ type: 'text' as const, text }] }; } );