> ## Documentation Index
> Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Strict Tools Mode

> Fail-fast dependency checking for templates

## Overview

Strict tools mode provides fail-fast dependency checking before running templates. When enabled, the template will not execute if any required tool, package, or environment variable is missing.

## Python API

### DependencyChecker

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonai.templates import DependencyChecker, StrictModeError
from praisonai.templates import TemplateLoader

# Load a template
loader = TemplateLoader()
template = loader.load("my-template")

# Create dependency checker
checker = DependencyChecker()

# Check all dependencies (non-strict - returns status)
result = checker.check_template_dependencies(template)
print(f"All satisfied: {result['all_satisfied']}")

# Enforce strict mode (raises exception if missing)
try:
    checker.enforce_strict_mode(template)
    print("✓ All dependencies satisfied")
except StrictModeError as e:
    print(f"Missing dependencies:\n{e}")
    print(f"Missing items: {e.missing_items}")
```

### Checking Individual Dependencies

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonai.templates import DependencyChecker

checker = DependencyChecker()

# Check tool availability
tool_status = checker.check_tool("internet_search")
print(f"Available: {tool_status['available']}")
print(f"Source: {tool_status['source']}")  # builtin, praisonai-tools, custom

# Check package availability
pkg_status = checker.check_package("pandas")
print(f"Available: {pkg_status['available']}")
print(f"Install hint: {pkg_status['install_hint']}")

# Check environment variable
env_status = checker.check_env_var("OPENAI_API_KEY")
print(f"Available: {env_status['available']}")
print(f"Masked value: {env_status['masked_value']}")  # sk-****1234
```

### Getting Install Hints

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonai.templates import DependencyChecker, TemplateLoader

loader = TemplateLoader()
template = loader.load("video-analyzer")

checker = DependencyChecker()
hints = checker.get_install_hints(template)

for hint in hints:
    print(f"• {hint}")
# Output:
# • Tool 'youtube_tool': pip install praisonai-tools[video]
# • Package 'opencv-python': pip install opencv-python
# • Environment variable 'YOUTUBE_API_KEY': export YOUTUBE_API_KEY=<value>
```

## StrictModeError

When strict mode fails, `StrictModeError` is raised with:

| Attribute       | Type | Description                                |
| --------------- | ---- | ------------------------------------------ |
| `message`       | str  | Human-readable error message               |
| `missing_items` | dict | Dict with 'tools', 'packages', 'env' lists |

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
try:
    checker.enforce_strict_mode(template)
except StrictModeError as e:
    if e.missing_items["tools"]:
        print(f"Missing tools: {e.missing_items['tools']}")
    if e.missing_items["packages"]:
        print(f"Missing packages: {e.missing_items['packages']}")
    if e.missing_items["env"]:
        print(f"Missing env vars: {e.missing_items['env']}")
```

## Custom Tool Directories

The checker can search custom directories for tools:

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
checker = DependencyChecker(
    custom_tool_dirs=["~/.praisonai/tools", "./my-tools"]
)

# Tools in custom dirs will be found
result = checker.check_tool("my_custom_tool")
```
