CrewAI

Add Fuze protection to CrewAI tools through FuzeToolMixin for BaseTool, or batch-wrap existing tool instances.

Installation

bash
pip install fuze-ai crewai

Usage

python
from crewai import BaseTool
from fuze_ai.adapters.crewai import FuzeToolMixin

class SearchTool(FuzeToolMixin, BaseTool):
    name = "search"
    description = "Search the vector database"

    fuze_config = {
        "max_cost": 0.50,
        "max_retries": 3,
    }

    def _run(self, query: str) -> str:
        return vector_db.search(query)

Side-effects

python
class SendEmailTool(FuzeToolMixin, BaseTool):
    name = "send_email"
    description = "Send an email"

    fuze_config = {
        "side_effect": True,
    }

    def _run(self, to: str, body: str) -> str:
        return ses.send_email(to, body)

    def _compensate(self, result):
        ses.recall_email(result["message_id"])

Wrapping existing tools

python
from fuze_ai.adapters.crewai import fuze_crew_tools

tools = [SearchTool(), CalculatorTool(), EmailTool()]
guarded = fuze_crew_tools(tools, side_effects={"send_email": recall_email})

Full example

python
from crewai import Agent, Task, Crew

tools = fuze_crew_tools(
    [SearchTool(), EmailTool()],
    side_effects={"send_email": recall_email},
)

agent = Agent(
    role="Research Assistant",
    goal="Find and summarize information",
    tools=tools,
)

crew = Crew(agents=[agent], tasks=[Task(description="Research quarterly revenue", agent=agent)])
result = crew.kickoff()

Expected fuze-traces.jsonl excerpt:

jsonl
{"event":"step.end","tool":"search","cost":0.008,"duration_ms":420}
{"event":"step.end","tool":"send_email","cost":0.0,"side_effect":true,"compensable":true}