Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(brain): strip JSON-schema object-key constraints Gemini rejects (propertyNames et al.)
Ruben Lütkef25d408a95f1
diff --git a/jarvis/plugins/brain/gemini.py b/jarvis/plugins/brain/gemini.pyindex 543b24471a..2dec34a34f 100644--- a/jarvis/plugins/brain/gemini.py+++ b/jarvis/plugins/brain/gemini.py@@ -250,6 +250,22 @@ _GEMINI_FORBIDDEN_SCHEMA_KEYS: frozenset[str] = frozenset({"definitions", # draft-07 definitions block"examples", # plural — Gemini only accepts singular ``example``"const", # not in Gemini's subset+ # JSON-schema object-key constraints Gemini's Schema model (extra="forbid")+ # rejects. A connected MCP/plugin tool can ship these on a free-form object+ # parameter; left in, ONE such tool schema fails the WHOLE GenerateContent+ # request with a Pydantic "extra_forbidden" validation error, so the primary+ # brain (Gemini) dies and the turn falls through the whole provider chain+ # (live forensic 2026-07-23: functionDeclarations[105].parameters.properties.+ # anchor.propertyNames → 5 validation errors → gemini down → claude 401 →+ # openrouter 400 → openai 429 → anti-silence fallback). Dropping the+ # constraint keeps the tool callable; only the key-name restriction is lost.+ "propertyNames", # restricts allowed property names — not in Gemini's subset+ "patternProperties", # per-pattern property schemas — not in Gemini's subset+ "unevaluatedProperties",+ "minProperties", # object size bounds — not in Gemini's subset+ "maxProperties",+ "dependentRequired",+ "dependentSchemas",})diff --git a/tests/unit/brain/test_gemini_schema_sanitize.py b/tests/unit/brain/test_gemini_schema_sanitize.pynew file mode 100644index 0000000000..f169d408f7--- /dev/null+++ b/tests/unit/brain/test_gemini_schema_sanitize.py@@ -0,0 +1,75 @@+"""Gemini function-schema sanitizer: strips JSON-schema keywords the google-genai+Schema model (extra="forbid") rejects.++Regression guard for the live 2026-07-23 outage: a connected MCP/plugin tool+shipped a parameter carrying ``propertyNames`` (functionDeclarations[105].+parameters.properties.anchor.propertyNames). Left in, ONE such schema failed the+WHOLE GenerateContent request with a Pydantic "extra_forbidden" validation error,+so the primary brain (Gemini) died and the turn fell through the entire provider+chain (claude 401 → openrouter 400 → openai 429 → anti-silence fallback) — a+Drive question got no real answer for reasons unrelated to Drive.+"""++import json++from jarvis.plugins.brain.gemini import _sanitize_for_gemini+++def _flatten(schema: dict) -> str:+ return json.dumps(schema)+++def test_property_names_is_stripped_but_type_kept():+ bad = {+ "type": "object",+ "properties": {+ "anchor": {"type": "string", "propertyNames": {"type": "string"}},+ },+ }+ clean = _sanitize_for_gemini(bad)+ assert "propertyNames" not in _flatten(clean)+ # The parameter itself survives — only the unsupported constraint is gone.+ assert clean["properties"]["anchor"]["type"] == "string"+++def test_all_object_key_constraints_are_stripped():+ bad = {+ "type": "object",+ "properties": {+ "meta": {+ "type": "object",+ "patternProperties": {"^x": {"type": "string"}},+ "minProperties": 1,+ "maxProperties": 5,+ "unevaluatedProperties": False,+ "dependentRequired": {"a": ["b"]},+ "dependentSchemas": {"a": {"required": ["b"]}},+ },+ },+ }+ flat = _flatten(_sanitize_for_gemini(bad))+ for forbidden in (+ "patternProperties",+ "minProperties",+ "maxProperties",+ "unevaluatedProperties",+ "dependentRequired",+ "dependentSchemas",+ ):+ assert forbidden not in flat, forbidden+++def test_sanitizer_recurses_into_nested_and_lists():+ bad = {+ "type": "object",+ "properties": {+ "outer": {+ "type": "array",+ "items": {"type": "object", "propertyNames": {"type": "string"}},+ }+ },+ }+ clean = _sanitize_for_gemini(bad)+ assert "propertyNames" not in _flatten(clean)+ # Structure preserved.+ assert clean["properties"]["outer"]["items"]["type"] == "object"