Skip to content

7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.

TypeScript

test(google): cover uniqueItems and composition-keyword stripping

Tushar4921c01aa28f36
diff --git a/server/src/__tests__/providers/google-schema.test.ts b/server/src/__tests__/providers/google-schema.test.ts
index 3264624e..dd46b8c3 100644
--- a/server/src/__tests__/providers/google-schema.test.ts
+++ b/server/src/__tests__/providers/google-schema.test.ts
@@ -149,4 +149,63 @@ describe('sanitizeForGemini', () => {
required: ['command'],
});
});
+
+ it('strips uniqueItems (Gemini rejects arrays with uniqueItems with 400)', () => {
+ // Confirmed via live Google AI Studio call:
+ // "Invalid JSON payload received. Unknown name 'uniqueItems' at
+ // 'tools[0].function_declarations[0].parameters.properties[2].value':
+ // Cannot find field."
+ const input = {
+ type: 'object',
+ properties: {
+ files: {
+ type: 'array',
+ items: { type: 'string' },
+ uniqueItems: true,
+ minItems: 0,
+ maxItems: 10,
+ },
+ },
+ };
+ expect(sanitizeForGemini(input)).toEqual({
+ type: 'object',
+ properties: {
+ files: {
+ type: 'array',
+ items: { type: 'string' },
+ minItems: 0,
+ maxItems: 10,
+ },
+ },
+ });
+ });
+
+ it('strips composition / structural keywords absent from Google Schema proto', () => {
+ // not / allOf / oneOf / prefixItems / contains / propertyNames / multipleOf /
+ // dependencies / deprecated are all absent from Google's Schema proto
+ // (https://ai.google.dev/api/caching#Schema). Only anyOf is supported.
+ const input = {
+ type: 'object',
+ not: { type: 'null' },
+ allOf: [{ type: 'object' }],
+ oneOf: [{ type: 'string' }, { type: 'number' }],
+ dependencies: { a: ['b'] },
+ deprecated: true,
+ properties: {
+ tuple: { type: 'array', prefixItems: [{ type: 'string' }] },
+ bag: { type: 'array', contains: { type: 'string' }, minContains: 1, maxContains: 5 },
+ names: { type: 'object', propertyNames: { pattern: '^x_' } },
+ count: { type: 'number', multipleOf: 0.5 },
+ },
+ };
+ expect(sanitizeForGemini(input)).toEqual({
+ type: 'object',
+ properties: {
+ tuple: { type: 'array' },
+ bag: { type: 'array' },
+ names: { type: 'object' },
+ count: { type: 'number' },
+ },
+ });
+ });
});