fix: simplify session tool schemas for Gemini compatibility (#599) (thanks @mcinteerj)
This commit is contained in:
@@ -47,6 +47,7 @@
|
|||||||
- Discord: stop provider when gateway reconnects are exhausted and surface errors. (#514) — thanks @joshp123
|
- Discord: stop provider when gateway reconnects are exhausted and surface errors. (#514) — thanks @joshp123
|
||||||
- Agents: strip empty assistant text blocks from session history to avoid Claude API 400s. (#210)
|
- Agents: strip empty assistant text blocks from session history to avoid Claude API 400s. (#210)
|
||||||
- Agents: scrub unsupported JSON Schema keywords from tool schemas for Cloud Code Assist API compatibility. (#567) — thanks @erikpr1994
|
- Agents: scrub unsupported JSON Schema keywords from tool schemas for Cloud Code Assist API compatibility. (#567) — thanks @erikpr1994
|
||||||
|
- Agents: simplify session tool schemas for Gemini compatibility. (#599) — thanks @mcinteerj
|
||||||
- Auto-reply: preserve block reply ordering with timeout fallback for streaming. (#503) — thanks @joshp123
|
- Auto-reply: preserve block reply ordering with timeout fallback for streaming. (#503) — thanks @joshp123
|
||||||
- Auto-reply: block reply ordering fix (duplicate PR superseded by #503). (#483) — thanks @AbhisekBasu1
|
- Auto-reply: block reply ordering fix (duplicate PR superseded by #503). (#483) — thanks @AbhisekBasu1
|
||||||
- Auto-reply: avoid splitting outbound chunks inside parentheses. (#499) — thanks @philipp-spiess
|
- Auto-reply: avoid splitting outbound chunks inside parentheses. (#499) — thanks @philipp-spiess
|
||||||
|
|||||||
@@ -23,6 +23,43 @@ vi.mock("../config/config.js", async (importOriginal) => {
|
|||||||
import { createClawdbotTools } from "./clawdbot-tools.js";
|
import { createClawdbotTools } from "./clawdbot-tools.js";
|
||||||
|
|
||||||
describe("sessions tools", () => {
|
describe("sessions tools", () => {
|
||||||
|
it("uses number (not integer) in tool schemas for Gemini compatibility", () => {
|
||||||
|
const tools = createClawdbotTools();
|
||||||
|
const byName = (name: string) => {
|
||||||
|
const tool = tools.find((candidate) => candidate.name === name);
|
||||||
|
expect(tool).toBeDefined();
|
||||||
|
if (!tool) throw new Error(`missing ${name} tool`);
|
||||||
|
return tool;
|
||||||
|
};
|
||||||
|
|
||||||
|
const schemaProp = (toolName: string, prop: string) => {
|
||||||
|
const tool = byName(toolName);
|
||||||
|
const schema = tool.parameters as {
|
||||||
|
anyOf?: unknown;
|
||||||
|
oneOf?: unknown;
|
||||||
|
properties?: Record<string, unknown>;
|
||||||
|
};
|
||||||
|
expect(schema.anyOf).toBeUndefined();
|
||||||
|
expect(schema.oneOf).toBeUndefined();
|
||||||
|
|
||||||
|
const properties = schema.properties ?? {};
|
||||||
|
const value = properties[prop] as { type?: unknown } | undefined;
|
||||||
|
expect(value).toBeDefined();
|
||||||
|
if (!value) throw new Error(`missing ${toolName} schema prop: ${prop}`);
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(schemaProp("sessions_history", "limit").type).toBe("number");
|
||||||
|
expect(schemaProp("sessions_list", "limit").type).toBe("number");
|
||||||
|
expect(schemaProp("sessions_list", "activeMinutes").type).toBe("number");
|
||||||
|
expect(schemaProp("sessions_list", "messageLimit").type).toBe("number");
|
||||||
|
expect(schemaProp("sessions_send", "timeoutSeconds").type).toBe("number");
|
||||||
|
expect(schemaProp("sessions_spawn", "runTimeoutSeconds").type).toBe(
|
||||||
|
"number",
|
||||||
|
);
|
||||||
|
expect(schemaProp("sessions_spawn", "timeoutSeconds").type).toBe("number");
|
||||||
|
});
|
||||||
|
|
||||||
it("sessions_list filters kinds and includes messages", async () => {
|
it("sessions_list filters kinds and includes messages", async () => {
|
||||||
callGatewayMock.mockReset();
|
callGatewayMock.mockReset();
|
||||||
callGatewayMock.mockImplementation(async (opts: unknown) => {
|
callGatewayMock.mockImplementation(async (opts: unknown) => {
|
||||||
|
|||||||
@@ -32,8 +32,10 @@ import {
|
|||||||
|
|
||||||
const SessionsSendToolSchema = Type.Object({
|
const SessionsSendToolSchema = Type.Object({
|
||||||
sessionKey: Type.Optional(Type.String()),
|
sessionKey: Type.Optional(Type.String()),
|
||||||
label: Type.Optional(Type.String()),
|
label: Type.Optional(
|
||||||
agentId: Type.Optional(Type.String()),
|
Type.String({ minLength: 1, maxLength: SESSION_LABEL_MAX_LENGTH }),
|
||||||
|
),
|
||||||
|
agentId: Type.Optional(Type.String({ minLength: 1, maxLength: 64 })),
|
||||||
message: Type.String(),
|
message: Type.String(),
|
||||||
timeoutSeconds: Type.Optional(Type.Number({ minimum: 0 })),
|
timeoutSeconds: Type.Optional(Type.Number({ minimum: 0 })),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user