polarity_capture_turn
Capture an entire user/assistant turn to extract all durable observations—preferences, constraints, project context, relationships, decisions, emotional signals, working-style rules—in one call.
Instructions
Hand a whole user/assistant exchange to cosmos so it can extract every durable observation worth holding (preferences, constraints, project context, relationships, decisions, emotional signals, working-style rules). PREFER this over multiple polarity_observe calls when a turn contained more than one fact about the user. Pass the user's message in user_text, your reply in assistant_text. Cosmos returns the node ids it created.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_text | Yes | ||
| assistant_text | No | ||
| source | No | ||
| max_observations | No |
Implementation Reference
- src/tools/index.ts:101-115 (registration)Registration of the 'polarity_capture_turn' tool in the TOOLS array, defining its name, description, Zod inputSchema (user_text, assistant_text, source, max_observations), and handler that delegates to CosmosClient.captureTurn()
{ name: "polarity_capture_turn", description: "Hand a whole user/assistant exchange to cosmos so it can extract every durable observation worth holding (preferences, constraints, project context, relationships, decisions, emotional signals, working-style rules). PREFER this over multiple polarity_observe calls when a turn contained more than one fact about the user. Pass the user's message in `user_text`, your reply in `assistant_text`. Cosmos returns the node ids it created.", inputSchema: z .object({ user_text: z.string().min(1).max(16000), assistant_text: z.string().max(16000).optional(), source: z.string().max(64).optional(), max_observations: z.number().int().min(1).max(20).optional(), }) .strict(), handler: async (input, client) => client.captureTurn(input as Parameters<CosmosClient["captureTurn"]>[0]), }, - src/tools/index.ts:113-114 (handler)Handler function for polarity_capture_turn: passes the input to client.captureTurn() which sends a POST to /api/polarity/capture-turn
handler: async (input, client) => client.captureTurn(input as Parameters<CosmosClient["captureTurn"]>[0]), - src/tools/index.ts:105-112 (schema)Input schema for polarity_capture_turn: validates user_text (string 1-16000), optional assistant_text (max 16000), optional source (max 64 chars), optional max_observations (int 1-20)
inputSchema: z .object({ user_text: z.string().min(1).max(16000), assistant_text: z.string().max(16000).optional(), source: z.string().max(64).optional(), max_observations: z.number().int().min(1).max(20).optional(), }) .strict(), - src/client/cosmos.ts:102-113 (helper)CosmosClient.captureTurn() method: sends a POST request to /api/polarity/capture-turn with polarity_user_id and the input fields, returns a CaptureTurnResponse
captureTurn(input: { user_text: string; assistant_text?: string; source?: string; max_observations?: number; }) { return this.request<CaptureTurnResponse>({ method: "POST", path: "/api/polarity/capture-turn", body: { polarity_user_id: this.config.polarityUserId, ...input }, }); } - src/client/cosmos.ts:226-230 (helper)CaptureTurnResponse interface: defines the return type with 'created' (array of {node_id, kind, label}), 'extracted' (count), and 'skipped' (count)
export interface CaptureTurnResponse { created: Array<{ node_id: number; kind: string; label: string }>; extracted: number; skipped: number; }