Skip to content

fix(agents): strip Gemini conditional schema keywords - #69964

Closed
junshanxu wants to merge 3 commits into
openclaw:mainfrom
junshanxu:codex/gemini-strip-conditional-schema-keywords
Closed

junshanxu wants to merge 3 commits into
openclaw:mainfrom
junshanxu:codex/gemini-strip-conditional-schema-keywords

Conversation

@junshanxu

Copy link
Copy Markdown
Contributor

Summary

  • Strip JSON Schema conditional keywords if, then, and else from Gemini tool schemas.
  • Add a regression test that keeps regular properties while removing conditionals.

Closes #69768

Tests

  • node scripts/test-projects.mjs src/agents/schema/clean-for-gemini.test.ts
  • node scripts/run-oxlint.mjs --tsconfig tsconfig.oxlint.core.json src/agents/schema/clean-for-gemini.ts src/agents/schema/clean-for-gemini.test.ts
  • pnpm exec oxfmt --check src/agents/schema/clean-for-gemini.ts src/agents/schema/clean-for-gemini.test.ts
  • git diff --check -- src/agents/schema/clean-for-gemini.ts src/agents/schema/clean-for-gemini.test.ts

@greptile-apps

greptile-apps Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds "if", "then", and "else" to GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS so the existing keyword-stripping loop in cleanSchemaForGeminiWithDefs drops JSON Schema conditional blocks before sending tool schemas to Gemini. A regression test covers the fix and verifies that regular properties survive the strip.

Confidence Score: 5/5

Safe to merge — change is minimal, correct, and well-tested.

The only finding is a P2 style nit about the obfuscated "then" string in the test. The implementation itself is correct: three keywords are appended to an existing set and the loop already handles stripping.

No files require special attention.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/agents/schema/clean-for-gemini.test.ts
Line: 210-214

Comment:
**Obfuscated `"then"` string is harder to read and maintain**

The concatenation `["th", "en"].join("")` to avoid writing the literal string `"then"` is opaque. `if` and `else` (also JS reserved words) are assigned directly on lines 211 and 215, so the inconsistency stands out. If a linter rule is firing on `schema.then`, using bracket notation `schema["then"]` achieves the same workaround while remaining readable.

```suggestion
    schema["then"] = { required: ["timeoutMs"] };
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(agents): strip Gemini conditional sc..." | Re-trigger Greptile

Comment on lines +210 to +214
const thenKeyword = ["th", "en"].join("");
schema.if = {
properties: { mode: { const: "manual" } },
};
schema[thenKeyword] = { required: ["timeoutMs"] };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Obfuscated "then" string is harder to read and maintain

The concatenation ["th", "en"].join("") to avoid writing the literal string "then" is opaque. if and else (also JS reserved words) are assigned directly on lines 211 and 215, so the inconsistency stands out. If a linter rule is firing on schema.then, using bracket notation schema["then"] achieves the same workaround while remaining readable.

Suggested change
const thenKeyword = ["th", "en"].join("");
schema.if = {
properties: { mode: { const: "manual" } },
};
schema[thenKeyword] = { required: ["timeoutMs"] };
schema["then"] = { required: ["timeoutMs"] };
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/schema/clean-for-gemini.test.ts
Line: 210-214

Comment:
**Obfuscated `"then"` string is harder to read and maintain**

The concatenation `["th", "en"].join("")` to avoid writing the literal string `"then"` is opaque. `if` and `else` (also JS reserved words) are assigned directly on lines 211 and 215, so the inconsistency stands out. If a linter rule is firing on `schema.then`, using bracket notation `schema["then"]` achieves the same workaround while remaining readable.

```suggestion
    schema["then"] = { required: ["timeoutMs"] };
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Apr 22, 2026
@prtags

prtags Bot commented Apr 23, 2026

Copy link
Copy Markdown

Related work from PRtags group worthy-mite-sck9

Title: agents: Gemini conditional schema keyword stripping

Number Title
#69964* fix(agents): strip Gemini conditional schema keywords
#70497 fix(agents): strip Gemini conditional schema keywords

* This PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gemini-2.5-flash rejects cron tool payloads with HTTP 400 no-body since ~2026-04-15

1 participant