Repository navigation
fix(ai): drop Gemini enums on non-string schemas - #196742
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Built-Gateway capture (secretless Docker, node:24.22.1). One |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThe PR drops enum constraints from explicitly non-string Gemini schemas while preserving their declared types and string enums. Example: A Gemini agent turn includes read.optional, whose canonical schema permits boolean true.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR: it fixes a current Gemini request-schema failure at the existing shared owner, preserves canonical input validation, and has no actionable findings; exact-head CI is green. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherTool finalization projects canonical parameter schemas through the shared Gemini cleaner before provider serialization; returned tool arguments are validated against the canonical execution schema. flowchart LR
A[Canonical tool schemas] --> B[Gemini schema cleaner]
B --> C[Gemini HTTP transport]
C --> D[Model tool arguments]
D --> E[Canonical input validation]
E --> F[Read tool result]
Technical reviewBest possible solution: Keep the fix in the shared Gemini projection owner while preserving canonical execution validation and unchanged string enums. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically emits the reported boolean/string-enum mismatch, corroborated by the reporter's wire capture and supplied base-failing Gateway trace; no target code was executed during this review. Is this the best way to solve the issue? The patch is the smallest complete repair: filter unsupported enum projections at the existing shared owner, retain primitive types, and update existing boolean, nested numeric, and consumer regressions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 53aed90ae4c7. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +4, Tests -2. Total +2 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 10, 2026, 11:32 AM ET / 16:32 UTC (Revision 2). |
|
Second built-Gateway run on the same images (main So on head the Gemini request is accepted, the model-generated boolean Updated regressions fail on the base source and pass on head ( Real Google behavior for the main shape: the Gemini API returns |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 543917c. Thanks @yixiaoer-520 for the report. |
fix(ai): drop non-string enums from Gemini tool schemas
The read tool declares optional as the boolean literal true. The Gemini schema cleaner turned that into {"type":"boolean","enum":["true"]}, but Google allows enum only on string types, so every Gemini and Vertex request carrying the read tool failed with HTTP 400 "enum: only allowed for STRING type". openclaw#104567 deliberately keeps the declared type so tool arguments still match local validation (openclaw#185581); changing the type to string would make Gemini send "true" and fail that check. The cleaner now keeps enums only when the declared type is string or missing, and drops the enum for other types while keeping the type. read.optional goes out as a plain boolean, and the original schema still accepts only true. Other providers' schemas are unchanged.
Evidence: a built Gateway on node:24.22.1 in secretless Docker with 14 tools including read, against a local stand-in that enforces Google's enum rule and returns the real 400 body, two runs each. On main the request failed with "...parameters.properties[optional].enum: only allowed for STRING type". With this change the request was accepted, and the stand-in's read call with optional true passed local validation and ran. The other 13 Gemini tool schemas, every string enum and the OpenAI-compatible request are byte-identical to main. Details: openclaw#196742.
Closes openclaw#196717. Thanks @yixiaoer-520 for the report.
Co-authored-by: Ayaan Zaidi <[email protected]>
Adapt retained normalizer coverage without importing the superseded tool-search fixture. Production change from 543917c. Independent local review omitted by explicit release-owner instruction; scoped regression and static checks passed. Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> (cherry picked from commit 4f5f8d62795ffe1b9981692f2f8d8058f6078178)
Adapt to the 2026.11.4 release owners and fixtures; preserve current safety and timeout contracts. Source inspected by release owner. Independent local review explicitly waived by Dallin; CI qualification remains pending. (cherry picked from commit 543917c) Co-authored-by: RomneyDa <[email protected]>
Fixes #196717. Thanks @yixiaoer-520 for the report and the wire capture.
Problem
Every Gemini or Vertex turn that exposes the built-in
readtool fails with HTTP 400. Thereadtool declaresoptionalas the boolean literaltrue, and the Gemini schema cleaner sends it as{"type": "boolean", "enum": ["true"]}. Google acceptsenumonly on string schemas with string entries (Schema.enumisrepeated string, "Possible values of the element of Type.STRING with enum format" ingoogle/ai/generativelanguage/v1beta/content.proto), so the whole request is rejected.Root cause
cleanSchemaForGeministringifiesconstandenumentries. #104567 (1338b0d) first stringified them and retyped the schema tostring; its final revision (8055932) deliberately kept the declared type "so tool argument generation and runtime validation still agree": a string-typedoptionalwould make Gemini send"true", which the canonicalType.Literal(true)validation (#185581) rejects. Keeping the type while emitting string entries leaves a non-string schema with an enum, which Google rejects. #182390 (5eab3f5) last touched this cleaner but only madetypescalar; it does not change enum handling.Fix
In the Gemini cleaner, keep
const/enum(stringified, as before) only when the declared type isstringor absent. For any other declared type, keep the type and drop the enum.read.optionalnow goes out as{"type": "boolean", "description": ...}: Gemini accepts it, the model still generates a real boolean, and canonical validation still accepts onlytrue. Numeric enums follow the same rule. Non-Gemini providers and string enums are unchanged.Evidence
Built Gateway (
pnpm build,openclaw gateway run) on secretless Docker, Node 24.22.1. Oneopenclaw agentturn through the Gateway per provider, with the default tool set (14 tools,readincluded). The Gemini provider (google-generative-ai) points at a local stand-in that applies Google's enum rule (enum only on STRING schemas with string entries) and answers violations with Google'sINVALID_ARGUMENT400 body; it records every request. Control provider: OpenAI-compatible on the same stand-in.3686da563c54(2/2 runs): Gemini request rejected,* GenerateContentRequest.tools[0].function_declarations[9].parameters.properties[optional].enum: only allowed for STRING type; the turn fails (LLM request rejected ... | 400, exit 1).aa23553561d7(2/2 runs): Gemini request accepted (200) and the turn completes. In run 2 the stand-in answers withread({"path":"missing-196717.txt","optional":true})(a real boolean); canonical validation accepts it and the realreadtool returnsOptional file not found: missing-196717.txt.read.optionalon the Gemini wire: main{"type":"boolean","enum":["true"],"description":...}, candidate{"type":"boolean","description":...}.readis unchanged; all 7 string enums (for exampleexec.host,github_publish.action) are unchanged; the OpenAI-compatible request's 14 tools are byte-identical to main (read.optionalstays{"type":"boolean","const":true,...}).clean-for-gemini,tool-search-runtime,agent-tools-parameter-schema,agent-tools.schema,agent-tools.prefix-stability,message-tool-schemapass. The updatedclean-for-geminiandtool-search-runtimecases fail on the base source (3 failures) and pass on head.Captures: run 1 #196742 (comment), run 2 with the tool-call round trip and the base-failing tests #196742 (comment)
Not covered: there is no live Google key in this loop, so acceptance is shown against the documented rule (
Schema.enumingoogle/ai/generativelanguage/v1beta/content.proto) and the same real Gemini error other clients report for this shape (anomalyco/opencode#28397), not a live Gemini call.