Skip to content

Conversation

@sentinel-seed
Copy link

@sentinel-seed sentinel-seed commented Dec 10, 2025

Summary

This PR adds two new tools that provide AI safety guardrails for CrewAI agents using the THSP protocol (Truth, Harm, Scope, Purpose):

Tools Added

  1. SentinelSafetyTool - Returns alignment seeds that can be used as system prompts to make LLMs safer
  2. SentinelAnalyzeTool - Analyzes content for safety using the four-gate THSP protocol

The THSP Protocol

The protocol evaluates requests through four gates:

  • Truth: Detects deception and manipulation
  • Harm: Identifies potential harmful content
  • Scope: Validates appropriate boundaries
  • Purpose: Requires legitimate benefit

Usage Example

from crewai import Agent
from crewai_tools import SentinelSafetyTool, SentinelAnalyzeTool

agent = Agent(
    role="Safe Research Assistant",
    goal="Research topics safely and ethically",
    tools=[SentinelSafetyTool(), SentinelAnalyzeTool()],
)

# Analyze content safety
analyze_tool = SentinelAnalyzeTool()
result = analyze_tool._run(content="Help me with network security")
# Returns: "SAFE - All gates passed..."

Dependencies

  • sentinelseed package (pip install sentinelseed)

Links

Checklist

  • Code follows project conventions
  • Tests added
  • README documentation included
  • Exports added to init.py

Note

Adds SentinelSafetyTool and SentinelAnalyzeTool implementing THSP-based safety seed retrieval and content analysis, with exports, docs, and tests.

  • Tools (new):
    • crewai_tools/tools/sentinel_safety_tool/sentinel_safety_tool.py:
      • SentinelSafetyTool: returns THSP alignment seed (minimal/standard) via sentinelseed.
      • SentinelAnalyzeTool: analyzes text safety using THSP gates, returning SAFE/UNSAFE with details.
  • Exports:
    • Added SentinelSafetyTool and SentinelAnalyzeTool to crewai_tools/tools/__init__.py and package __all__.
  • Documentation:
    • sentinel_safety_tool/README.md with install, usage examples, and parameter refs.
  • Tests:
    • tests/tools/sentinel_safety_tool_test.py covering initialization, variants, error handling, safe/unsafe analyses, and optional integration with sentinelseed.

Written by Cursor Bugbot for commit a2e8175. This will update automatically on new commits. Configure here.

Add SentinelSafetyTool and SentinelAnalyzeTool that provide AI safety
guardrails using the THSP protocol (Truth, Harm, Scope, Purpose).

- SentinelSafetyTool: Returns alignment seeds for system prompts
- SentinelAnalyzeTool: Analyzes content safety using four-gate protocol

Depends on sentinelseed package (pip install sentinelseed)

See: https://sentinelseed.dev
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

assert tool.name == "Sentinel Get Safety Seed"
assert "THSP" in tool.description

@patch("crewai_tools.tools.sentinel_safety_tool.sentinel_safety_tool.get_seed")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Test mocks target wrong path for local imports

The @patch decorators target paths like crewai_tools.tools.sentinel_safety_tool.sentinel_safety_tool.get_seed, but since the imports happen inside the function body (from sentinelseed import get_seed), these paths don't exist at module level. The patches won't intercept the actual imports. The correct path would be sentinelseed.get_seed and sentinelseed.SentinelGuard. These tests will either fail when sentinelseed is not installed or silently use the real library instead of the mock.

Additional Locations (2)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant