BUG-734 Fix OAuth tool deserialization crash and type mismatch#891
Open
aix-ahmet wants to merge 3 commits intodevelopmentfrom
Open
BUG-734 Fix OAuth tool deserialization crash and type mismatch#891aix-ahmet wants to merge 3 commits intodevelopmentfrom
aix-ahmet wants to merge 3 commits intodevelopmentfrom
Conversation
- Add try/except around from_dict() in SearchResourceMixin to skip undeserializable OAuth tools instead of crashing the entire search - Wrap from_dict() in GetResourceMixin with a clear ResourceError for better diagnostics when deserialization fails - Fix Tool.as_tool() to emit type="tool" instead of inheriting "model" from the parent class, which caused agent API validation errors - Expand ToolDict type literal to include all valid tool types (sql, script, tool, integration) - Add error handling in Integration.connect() for failed connections Made-with: Cursor
ActionMixin was missing the @DataClass decorator, so its actions_available field was not included in __dataclass_fields__ of subclasses. This caused from_dict() to silently ignore actionsAvailable from API responses, leaving tool.actions empty and tool.run(action=...) broken.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AttributeError: 'str' object has no attribute 'items') that blocked all SDK usage for OAuth/Composio-backed integrations (Gmail, Slack, Jira, Google Drive)as_tool()type mismatch whereToolinstances emittedtype: "model"instead oftype: "tool", causing agent creation API validation errorsIntegration.connect()for failed connections (e.g., name collisions)Changes
aixplain/v2/resource.pyfrom_dict()inSearchResourceMixinwith try/except to skip undeserializable items instead of crashing; wrapfrom_dict()inGetResourceMixinwith a clearResourceErroraixplain/v2/tool.pytypeto"tool"inTool.as_tool()aixplain/v2/mixins.pyToolDicttype literal to includesql,script,tool,integrationaixplain/v2/integration.pyconnect()and raiseValueErroron failureJira
BUG-734
Test plan
Tool.search(query="Gmail")no longer crashes when OAuth tools appear in resultsIntegration.get(composio_id)returns a clearResourceErrorinstead of crypticAttributeErrorTool.as_tool()returnstype: "tool"for OAuth tool instancesAgent(..., tools=[tool]).save()Made with Cursor