fix: simplify tool schemas for Gemini compatibility

Replaces Type.Integer with Type.Number and simplifies the sessions_send tool schema to avoid anyOf/oneOf unions that cause 400 errors with Google Cloud Code Assist API.
This commit is contained in:
Keith the Silly Goose
2026-01-10 07:42:32 +13:00
committed by Peter Steinberger
parent f0a909f6dd
commit 423eef4624
4 changed files with 13 additions and 25 deletions

View File

@@ -18,7 +18,7 @@ import {
const SessionsHistoryToolSchema = Type.Object({ const SessionsHistoryToolSchema = Type.Object({
sessionKey: Type.String(), sessionKey: Type.String(),
limit: Type.Optional(Type.Integer({ minimum: 1 })), limit: Type.Optional(Type.Number({ minimum: 1 })),
includeTools: Type.Optional(Type.Boolean()), includeTools: Type.Optional(Type.Boolean()),
}); });

View File

@@ -46,9 +46,9 @@ type SessionListRow = {
const SessionsListToolSchema = Type.Object({ const SessionsListToolSchema = Type.Object({
kinds: Type.Optional(Type.Array(Type.String())), kinds: Type.Optional(Type.Array(Type.String())),
limit: Type.Optional(Type.Integer({ minimum: 1 })), limit: Type.Optional(Type.Number({ minimum: 1 })),
activeMinutes: Type.Optional(Type.Integer({ minimum: 1 })), activeMinutes: Type.Optional(Type.Number({ minimum: 1 })),
messageLimit: Type.Optional(Type.Integer({ minimum: 0 })), messageLimit: Type.Optional(Type.Number({ minimum: 0 })),
}); });
function resolveSandboxSessionToolsVisibility( function resolveSandboxSessionToolsVisibility(

View File

@@ -30,25 +30,13 @@ import {
resolvePingPongTurns, resolvePingPongTurns,
} from "./sessions-send-helpers.js"; } from "./sessions-send-helpers.js";
const SessionsSendToolSchema = Type.Union([ const SessionsSendToolSchema = Type.Object({
Type.Object( sessionKey: Type.Optional(Type.String()),
{ label: Type.Optional(Type.String()),
sessionKey: Type.String(), agentId: Type.Optional(Type.String()),
message: Type.String(), message: Type.String(),
timeoutSeconds: Type.Optional(Type.Integer({ minimum: 0 })), timeoutSeconds: Type.Optional(Type.Number({ minimum: 0 })),
}, });
{ additionalProperties: false },
),
Type.Object(
{
label: Type.String({ minLength: 1, maxLength: SESSION_LABEL_MAX_LENGTH }),
agentId: Type.Optional(Type.String({ minLength: 1, maxLength: 64 })),
message: Type.String(),
timeoutSeconds: Type.Optional(Type.Integer({ minimum: 0 })),
},
{ additionalProperties: false },
),
]);
export function createSessionsSendTool(opts?: { export function createSessionsSendTool(opts?: {
agentSessionKey?: string; agentSessionKey?: string;

View File

@@ -25,9 +25,9 @@ const SessionsSpawnToolSchema = Type.Object({
label: Type.Optional(Type.String()), label: Type.Optional(Type.String()),
agentId: Type.Optional(Type.String()), agentId: Type.Optional(Type.String()),
model: Type.Optional(Type.String()), model: Type.Optional(Type.String()),
runTimeoutSeconds: Type.Optional(Type.Integer({ minimum: 0 })), runTimeoutSeconds: Type.Optional(Type.Number({ minimum: 0 })),
// Back-compat alias. Prefer runTimeoutSeconds. // Back-compat alias. Prefer runTimeoutSeconds.
timeoutSeconds: Type.Optional(Type.Integer({ minimum: 0 })), timeoutSeconds: Type.Optional(Type.Number({ minimum: 0 })),
cleanup: Type.Optional( cleanup: Type.Optional(
Type.Union([Type.Literal("delete"), Type.Literal("keep")]), Type.Union([Type.Literal("delete"), Type.Literal("keep")]),
), ),