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 examples/const/readOnly/writeOnly stripping

Tushar495ba759db4345
diff --git a/server/src/__tests__/providers/google-schema.test.ts b/server/src/__tests__/providers/google-schema.test.ts
index b4b536c2..3264624e 100644
--- a/server/src/__tests__/providers/google-schema.test.ts
+++ b/server/src/__tests__/providers/google-schema.test.ts
@@ -119,4 +119,34 @@ describe('sanitizeForGemini', () => {
expect(sanitizeForGemini(42)).toBe(42);
expect(sanitizeForGemini(true)).toBe(true);
});
+
+ it('strips examples / const / readOnly / writeOnly (Gemini rejects all with 400)', () => {
+ // These fields are emitted by Zod, Pydantic, and most JSON-Schema generators
+ // (used by opencode, Continue, Cline tool definitions) but rejected by Google's
+ // Gemini and Gemma 4 IT generateContent endpoint with "Invalid JSON payload
+ // received. Unknown name 'X' at tools[0].function_declarations[0].parameters".
+ const input = {
+ type: 'object',
+ properties: {
+ command: {
+ type: 'string',
+ description: 'Shell command to execute',
+ examples: ['ls -la', 'pwd'],
+ readOnly: false,
+ },
+ mode: { type: 'string', const: 'sync' },
+ secret: { type: 'string', writeOnly: true },
+ },
+ required: ['command'],
+ };
+ expect(sanitizeForGemini(input)).toEqual({
+ type: 'object',
+ properties: {
+ command: { type: 'string', description: 'Shell command to execute' },
+ mode: { type: 'string' },
+ secret: { type: 'string' },
+ },
+ required: ['command'],
+ });
+ });
});