Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(cron): flatten schedule schema for Gemini tool compatibility#221

Open
bohuslav-broza wants to merge 1 commit intovirattt:mainvirattt/dexter:mainfrom
bohuslav-broza:fix/gemini-cron-schemabohuslav-broza/dexter:fix/gemini-cron-schemaCopy head branch name to clipboard
Open

fix(cron): flatten schedule schema for Gemini tool compatibility#221
bohuslav-broza wants to merge 1 commit intovirattt:mainvirattt/dexter:mainfrom
bohuslav-broza:fix/gemini-cron-schemabohuslav-broza/dexter:fix/gemini-cron-schemaCopy head branch name to clipboard

Conversation

@bohuslav-broza
Copy link
Copy Markdown

@bohuslav-broza bohuslav-broza commented Apr 3, 2026

Summary

Gemini API (v1beta) currently does not support oneOf or const keywords in tool function declarations. Using z.discriminatedUnion in the cron tool's schema generates a JSON schema with these keywords, causing a 400 Bad Request (Invalid JSON payload) during initialization when using Gemini models.

Changes

  • Refactored scheduleSchema in src/tools/cron/cron-tool.ts from a discriminated union to a flat object with optional fields.
  • Updated descriptions for the now-optional fields (at, everyMs, expr) to indicate their requirement based on the selected kind.

Impact

  • Fixes launch-blocking 400 errors for users with Gemini models.
  • Maintains full functionality for existing scheduling logic (the cast to CronSchedule remains safe as the flat object is a superset of the possible union members).

Error Reference

⏺ Error: [Google API] [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-flash-latest:generateContent: [400 Bad Request] Invalid JSON payload received. Unknown name "const" at 'tools[0].function_declarations[10].parameters.properties[3].value.one_of...'

Gemini API (v1beta) does not support 'oneOf' or 'const' in function declarations. Replacing the discriminatedUnion with a flat object with optional fields ensures the generated JSON schema is compatible with Google's API while maintaining existing logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.