mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-08-10 08:21:54 +00:00
feat: add app metadata to platform action tools
Platform policy matching needs an explicit integration slug on every `CrewAIPlatformActionTool` at runtime. The builder now propagates each API app key and tests cover the resulting tool metadata. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -17,6 +17,7 @@ from crewai_tools.tools.crewai_platform_tools.misc import (
|
|||||||
|
|
||||||
|
|
||||||
class CrewAIPlatformActionTool(BaseTool):
|
class CrewAIPlatformActionTool(BaseTool):
|
||||||
|
app: str = Field(description="The integration slug for this action")
|
||||||
action_name: str = Field(default="", description="The name of the action")
|
action_name: str = Field(default="", description="The name of the action")
|
||||||
action_schema: dict[str, Any] = Field(
|
action_schema: dict[str, Any] = Field(
|
||||||
default_factory=dict, description="The schema of the action"
|
default_factory=dict, description="The schema of the action"
|
||||||
@@ -25,6 +26,7 @@ class CrewAIPlatformActionTool(BaseTool):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
description: str,
|
description: str,
|
||||||
|
app: str,
|
||||||
action_name: str,
|
action_name: str,
|
||||||
action_schema: dict[str, Any],
|
action_schema: dict[str, Any],
|
||||||
):
|
):
|
||||||
@@ -46,7 +48,9 @@ class CrewAIPlatformActionTool(BaseTool):
|
|||||||
name=action_name.lower().replace(" ", "_"),
|
name=action_name.lower().replace(" ", "_"),
|
||||||
description=description,
|
description=description,
|
||||||
args_schema=args_schema,
|
args_schema=args_schema,
|
||||||
|
app=app,
|
||||||
)
|
)
|
||||||
|
self.app = app
|
||||||
self.action_name = action_name
|
self.action_name = action_name
|
||||||
self.action_schema = action_schema
|
self.action_schema = action_schema
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ class CrewaiPlatformToolBuilder:
|
|||||||
|
|
||||||
tool = CrewAIPlatformActionTool(
|
tool = CrewAIPlatformActionTool(
|
||||||
description=description,
|
description=description,
|
||||||
|
app=function_details["app"],
|
||||||
action_name=action_name,
|
action_name=action_name,
|
||||||
action_schema=action_schema,
|
action_schema=action_schema,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class TestCrewAIPlatformActionToolVerify:
|
|||||||
def create_test_tool(self):
|
def create_test_tool(self):
|
||||||
return CrewAIPlatformActionTool(
|
return CrewAIPlatformActionTool(
|
||||||
description="Test action tool",
|
description="Test action tool",
|
||||||
|
app="test_app",
|
||||||
action_name="test_action",
|
action_name="test_action",
|
||||||
action_schema=self.action_schema
|
action_schema=self.action_schema
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -171,6 +171,10 @@ class TestCrewaiPlatformToolBuilder(unittest.TestCase):
|
|||||||
tool_names = [tool.action_name for tool in tools]
|
tool_names = [tool.action_name for tool in tools]
|
||||||
assert "create_issue" in tool_names
|
assert "create_issue" in tool_names
|
||||||
assert "send_message" in tool_names
|
assert "send_message" in tool_names
|
||||||
|
assert {tool.action_name: tool.app for tool in tools} == {
|
||||||
|
"create_issue": "github",
|
||||||
|
"send_message": "slack",
|
||||||
|
}
|
||||||
|
|
||||||
github_tool = next((t for t in tools if t.action_name == "create_issue"), None)
|
github_tool = next((t for t in tools if t.action_name == "create_issue"), None)
|
||||||
slack_tool = next((t for t in tools if t.action_name == "send_message"), None)
|
slack_tool = next((t for t in tools if t.action_name == "send_message"), None)
|
||||||
|
|||||||
@@ -1698,6 +1698,7 @@ class TestPlatformActionTool:
|
|||||||
|
|
||||||
return mod.CrewAIPlatformActionTool(
|
return mod.CrewAIPlatformActionTool(
|
||||||
description="Send a Slack message",
|
description="Send a Slack message",
|
||||||
|
app="slack",
|
||||||
action_name="slackbot_send_message",
|
action_name="slackbot_send_message",
|
||||||
action_schema={
|
action_schema={
|
||||||
"function": {
|
"function": {
|
||||||
|
|||||||
Reference in New Issue
Block a user