driftos_extract_facts
Extract structured facts from conversation branches to identify key information and maintain topic context in semantic routing systems.
Instructions
Trigger fact extraction for a branch. Use when you want to explicitly extract facts from the current conversation state.
Args:
branch_id (string): The branch ID to extract facts from
Returns: { "facts": [{ "key": string, "value": string }] }
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branch_id | Yes | Branch ID to extract facts from |
Implementation Reference
- src/tools/facts.ts:75-99 (handler)Handler function for the 'driftos_extract_facts' tool. It calls driftClient.extractFacts(branch_id), stringifies the result as JSON, and handles errors by returning an error message.async (params) => { try { const result = await driftClient.extractFacts(params.branch_id); return { content: [ { type: 'text' as const, text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { const message = error instanceof Error ? error.message : 'Unknown error'; return { content: [ { type: 'text' as const, text: `Error extracting facts: ${message}`, }, ], isError: true, }; } }
- src/tools/facts.ts:65-67 (schema)Input schema validation using Zod for the branch_id parameter.inputSchema: z.object({ branch_id: z.string().min(1).describe('Branch ID to extract facts from'), }).strict(),
- src/tools/facts.ts:54-100 (registration)Registration of the 'driftos_extract_facts' tool using server.registerTool, including schema, annotations, description, and inline handler.server.registerTool( 'driftos_extract_facts', { title: 'Extract Facts from Branch', description: `Trigger fact extraction for a branch. Use when you want to explicitly extract facts from the current conversation state. Args: - branch_id (string): The branch ID to extract facts from Returns: { "facts": [{ "key": string, "value": string }] }`, inputSchema: z.object({ branch_id: z.string().min(1).describe('Branch ID to extract facts from'), }).strict(), annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, }, async (params) => { try { const result = await driftClient.extractFacts(params.branch_id); return { content: [ { type: 'text' as const, text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { const message = error instanceof Error ? error.message : 'Unknown error'; return { content: [ { type: 'text' as const, text: `Error extracting facts: ${message}`, }, ], isError: true, }; } } );
- src/index.ts:20-20 (registration)Invocation of registerFactsTools(server) which registers the 'driftos_extract_facts' tool among others.registerFactsTools(server);