@devries-cameron20 / composio Mirror · read-only / commits / 6f134ff97
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 11:00 UTC

fix(gemini): run optional and constrained arguments through AFC again (#4691)

This PR: - fixes two regressions from https://github.com/ComposioHQ/composio/pull/4316 in `composio_gemini` automatic function calling (AFC) - builds the validation model with defaults (`skip_default=False`): with `skip_default=True`, every optional argument was required, so `fn(query="is:unread")` raised `ValidationError: max_results Field required` and the tool never ran - hands AFC plain annotations (`_afc_annotation`): google-genai converts arguments with `isinstance` on each annotation, which raised `TypeError` on the `Annotated[...]`, `Dict[str, Any]` and `typing.Any` annotations #4316 introduced - affected: enums, `pattern`, `minimum`/`maximum`, `anyOf`, `const`, free-form objects, arrays of objects - declarations match the ones before #4316, except a free-form property without a `type`, now declared without one so any value converts; a typeless `const`/`enum` is declared with its values' type; the source schema is still enforced by `args_schema` - serializes AFC's pydantic models with `exclude_unset=True, by_alias=True`, so omitted nested optional fields are no longer sent as `null` - replaces the `Dict[str, Any]` assertion from #4081 with `dict` and adds AFC regression tests that go through `google.genai._extra_utils.invoke_function_from_dict_args` ## Verification - all 11 new or updated tests fail on `next` and pass with the fix; `tests/test_gemini_provider.py`: 61 passed - declared `properties` pinned per AFC case in `test_afc_declares_the_argument_schema`; 17 schema shapes checked through `FunctionDeclaration.from_callable` against pre-#4316 output, and every shape now invokes except a bare `array` and a `oneOf` of objects, which already failed before #4316 - full Python suite: 2058 passed; 5 LangChain tests fail only because `composio_langchain` isn't installed in the overlay env - ruff (repo config), `ruff format --check`, mypy on the touched files: clean - no live Gemini call: no Gemini/Google API key was available in `.envrc`

Alberto Schiabel committed Sep 30, 2026 at 10:32 UTC 6f134ff97e4cfa8eb50fc9f6fdc9d26bede1dac0

No changes.