|
| 1 | +// Asserts that every top-level input property of every memory tool carries a |
| 2 | +// non-empty description in tools/list (#5416). Clients and models see only the |
| 3 | +// property name when a description is missing, so a new tool or parameter that |
| 4 | +// omits one fails here rather than shipping undocumented. Driven through an SDK |
| 5 | +// Client over an in-memory transport, so it checks what a client receives. |
| 6 | +import { describe, it, expect, beforeEach, afterEach } from "vitest"; |
| 7 | +import { connect, makeTempGraph } from "./helpers.js"; |
| 8 | +import type { Connection } from "./helpers.js"; |
| 9 | + |
| 10 | +describe("tool input property descriptions", () => { |
| 11 | + let connection: Connection; |
| 12 | + let cleanup: () => Promise<void>; |
| 13 | + |
| 14 | + beforeEach(async () => { |
| 15 | + const graph = await makeTempGraph(); |
| 16 | + cleanup = graph.cleanup; |
| 17 | + connection = await connect(graph.filePath); |
| 18 | + }); |
| 19 | + |
| 20 | + afterEach(async () => { |
| 21 | + await connection.close(); |
| 22 | + await cleanup(); |
| 23 | + }); |
| 24 | + |
| 25 | + it("describes every top-level input property of every tool (#5416)", async () => { |
| 26 | + const { tools } = await connection.client.listTools(); |
| 27 | + expect(tools.length).toBeGreaterThan(0); |
| 28 | + |
| 29 | + const undescribed: string[] = []; |
| 30 | + for (const tool of tools) { |
| 31 | + for (const [name, schema] of Object.entries( |
| 32 | + tool.inputSchema.properties ?? {}, |
| 33 | + )) { |
| 34 | + const description: unknown = |
| 35 | + typeof schema === "object" && schema !== null |
| 36 | + ? (schema as { description?: unknown }).description |
| 37 | + : undefined; |
| 38 | + if (typeof description !== "string" || description.trim() === "") { |
| 39 | + undescribed.push(`${tool.name}.${name}`); |
| 40 | + } |
| 41 | + } |
| 42 | + } |
| 43 | + expect(undescribed).toEqual([]); |
| 44 | + }); |
| 45 | + |
| 46 | + it("describes the four top-level array parameters named in #5416", async () => { |
| 47 | + const { tools } = await connection.client.listTools(); |
| 48 | + const descriptionOf = (tool: string, property: string): unknown => { |
| 49 | + const schema = tools.find((t) => t.name === tool)?.inputSchema |
| 50 | + .properties?.[property]; |
| 51 | + return typeof schema === "object" && schema !== null |
| 52 | + ? (schema as { description?: unknown }).description |
| 53 | + : undefined; |
| 54 | + }; |
| 55 | + expect(descriptionOf("create_entities", "entities")).toBe( |
| 56 | + "An array of entities to create", |
| 57 | + ); |
| 58 | + expect(descriptionOf("create_relations", "relations")).toBe( |
| 59 | + "An array of relations to create", |
| 60 | + ); |
| 61 | + expect(descriptionOf("add_observations", "observations")).toBe( |
| 62 | + "An array of entities and the observations to add to each", |
| 63 | + ); |
| 64 | + expect(descriptionOf("delete_observations", "deletions")).toBe( |
| 65 | + "An array of entities and the observations to delete from each", |
| 66 | + ); |
| 67 | + }); |
| 68 | +}); |
0 commit comments