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, 09:45 UTC
feat(openai-agents): add strict-mode support to the Python provider (#4721)
`OpenAIAgentsProvider` had no constructor and hardcoded `strict_json_schema=False`, unlike the TS `OpenAIAgentsProvider`'s `{ strict }` option and this package's own `OpenAIResponsesProvider`'s `strict` param — the docs explicitly called this out as a known Python-only gap. Fixes #4719 ## Changes - Wires the existing `to_strict_json_schema`/`omit_null_tool_arguments` utilities (already used by `OpenAIResponsesProvider`) into `OpenAIAgentsProvider.wrap_tool`: when `strict=True` and the tool's schema can be expressed as strict structured outputs, register it with the normalized schema and `strict_json_schema=True`, stripping null arguments the tool's own schema doesn't accept before execution. - A schema strict mode can't express (e.g. an object with arbitrary keys) falls back to the existing non-strict path unchanged — no behavior change for the default (`strict=False`) case. - New tests in `providers/openai_agents/tests/test_provider.py`: a supported-schema case (optional properties become required-nullable, mirroring the TS test), an unsupported-schema fallback case, a null-argument-omission execution case (driven via `asyncio.run` against the real `on_invoke_tool` callback), and a default-stays-non-strict case. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Refactor/Chore - [ ] Documentation - [ ] Breaking change ## How Has This Been Tested? `uv run pytest providers/openai_agents/tests/test_provider.py tests/test_type_inference_openai_agents.py` — 15 passed, no regressions. `ruff check`/`ruff format --check` (project-pinned `config/ruff.toml`): clean. `mypy --config-file config/mypy.ini providers/openai_agents/`: same 2 pre-existing, unrelated errors as unmodified `next` (confirmed via `git stash`), none on the changed file. ## Checklist - [x] I have read the Code of Conduct and this PR adheres to it - [x] I have read and understand every line of this diff, including any LLM-generated code - [x] Any third-party docs links or promotional content follow the third-party links policy — n/a, no docs links added - [x] I ran linters/tests locally and they passed - [ ] I updated documentation as needed — n/a, the docs page already documents this as a known gap and needs no change beyond removing that caveat, which I'll leave to a maintainer's discretion - [x] I added tests or explain why not applicable - [ ] I added a changeset if this change affects published packages — **not applicable**: this repo's changesets are TS-only (`.changeset/config.json` only references `@composio/*` npm packages); Python releases go out via separate `chore(release): prepare Python X.Y.Z` commits, confirmed by checking that PR #4675's own Python-side change got no changeset entry either. --------- Co-authored-by: jkomyno <alberto@composio.dev>