Skip to content

Commit 676405c

Browse files
fix: do not serialize input schema in tool definitions (#617)
This change updates the manifest method of the Gram Functions TS framework to avoid JSON-serializing the input schema for tool definitions. This was a mistake since the server is expecting a literal object for the schema.
1 parent 789b304 commit 676405c

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

.changeset/neat-jars-film.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@gram-ai/functions": patch
3+
---
4+
5+
Updated the `manifest()` method of the Gram Functions TS framework to avoid
6+
JSON-serializing the input schema for tool definitions. This was a mistake since
7+
the server is expecting a literal object for the schema.

ts-framework/functions/src/framework.test.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,17 +284,28 @@ test("generates a manifest", () => {
284284
tools: [
285285
{
286286
name: "echo",
287-
inputSchema: expect.stringContaining("message"),
287+
inputSchema: expect.objectContaining({
288+
type: "object",
289+
properties: { message: { type: "string" } },
290+
required: ["message"],
291+
}),
288292
},
289293
{
290294
name: "add",
291295
description: "Add two numbers",
292-
inputSchema: expect.stringContaining(`"required":["a","b"]`),
296+
inputSchema: expect.objectContaining({
297+
type: "object",
298+
properties: { a: { type: "number" }, b: { type: "number" } },
299+
required: ["a", "b"],
300+
}),
293301
},
294302
{
295303
name: "shout",
296304
description: "Shouts the input",
297-
inputSchema: expect.any(String),
305+
inputSchema: expect.objectContaining({
306+
type: "object",
307+
properties: {},
308+
}),
298309
variables: {
299310
MESSAGE: { description: "The message to shout" },
300311
},

ts-framework/functions/src/framework.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export type Manifest = {
4949
tools: Array<{
5050
name: string;
5151
description?: string;
52-
inputSchema: string;
52+
inputSchema: unknown;
5353
variables?: Record<string, VarDef>;
5454
}>;
5555
};
@@ -223,11 +223,11 @@ export class Gram<
223223
const result: {
224224
name: string;
225225
description?: string;
226-
inputSchema: string;
226+
inputSchema: unknown;
227227
variables?: Record<string, VarDef>;
228228
} = {
229229
name: tool.name,
230-
inputSchema: JSON.stringify(inputSchema),
230+
inputSchema: inputSchema,
231231
};
232232
if (tool.description != null) {
233233
result.description = tool.description;

0 commit comments

Comments
 (0)