Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | """Tests for the CrewAI provider.""" |
| 2 | |
| 3 | import pytest |
| 4 | from pydantic import BaseModel |
| 5 | |
| 6 | from composio.client.types import Tool |
| 7 | |
| 8 | CrewAIProvider = pytest.importorskip("composio_crewai").CrewAIProvider |
| 9 | |
| 10 | |
| 11 | def test_wrap_tool_dereferences_internal_refs() -> None: |
| 12 | """Referenced input properties must keep their type in the args schema.""" |
| 13 | tool = Tool.model_construct( |
| 14 | slug="TEST_REF", |
| 15 | description="test", |
| 16 | input_parameters={ |
| 17 | "type": "object", |
| 18 | "properties": {"message": {"$ref": "#/$defs/Message"}}, |
| 19 | "required": ["message"], |
| 20 | "$defs": { |
| 21 | "Message": { |
| 22 | "type": "object", |
| 23 | "properties": {"subject": {"type": "string"}}, |
| 24 | "required": ["subject"], |
| 25 | } |
| 26 | }, |
| 27 | }, |
| 28 | ) |
| 29 | |
| 30 | wrapped = CrewAIProvider().wrap_tool(tool, lambda slug, arguments: {}) |
| 31 | assert wrapped.args_schema is not None |
| 32 | message_type = wrapped.args_schema.model_fields["message"].annotation |
| 33 | |
| 34 | assert isinstance(message_type, type) |
| 35 | assert issubclass(message_type, BaseModel) |
| 36 | assert message_type.model_fields["subject"].annotation is str |