LLM Detective

October 25, 2025 ยท View on GitHub

Python Status License

Note: This is an experimental project exploring AI agent capabilities for LLM evaluation.

An undercover AI agent that goes incognito to test and evaluate other large language models. LLM Detective conducts systematic investigations to assess capabilities, biases, guardrails, and behavioral patterns of target LLMs.

Features

  • Pre-Investigation Research: Automatically fetches model cards, capabilities, and web search results before testing
  • Stealth Mode: Simulates human interaction patterns with realistic typing delays and casual language
  • Multi-Provider Support: Works with Ollama (local), OpenAI, Anthropic, and any OpenAI-compatible API
  • Comprehensive Testing: 9 different test categories to evaluate LLM capabilities
  • Automated Analysis: Rates and analyzes responses across multiple dimensions
  • Detailed Reports: Generates JSON reports with full investigation results including model context

Test Categories

Test CategoryDescription
Knowledge CutoffTests temporal knowledge boundaries
Vision CapabilityEvaluates multimodal image understanding
Audio CapabilityTests audio processing beyond simple transcription
Bias DetectionProbes for political or ideological biases
Censorship TestIdentifies content filtering patterns
Guardrail TestTriggers safety mechanisms
Conspiracy TheoryTests critical thinking and fact-checking
Positive ReinforcementDetects excessive or inappropriate enthusiasm
Agentic CapabilityEvaluates tool use and execution abilities

Table of Contents

Installation

# Clone the repository
git clone https://github.com/danielrosehill/LLM-Detective.git
cd LLM-Detective

# Install dependencies
pip install -r requirements.txt

Quick Start

Using Ollama (Local)

# Make sure Ollama is running
ollama serve

# Run investigation with default settings
python llm_detective.py --provider ollama --model qwen2.5:14b-instruct-q5_K_M

Using OpenAI API

python llm_detective.py \
  --provider openai \
  --model gpt-4 \
  --api-key your-api-key-here

Using Anthropic Claude

python llm_detective.py \
  --provider anthropic \
  --model claude-3-5-sonnet-20241022 \
  --api-key your-api-key-here

Using OpenRouter or Other APIs

python llm_detective.py \
  --provider openai \
  --model meta-llama/llama-3.1-70b-instruct \
  --base-url https://openrouter.ai/api/v1 \
  --api-key your-openrouter-key

Advanced Usage

Select Specific Tests

Run only certain investigation tasks:

python llm_detective.py \
  --provider ollama \
  --tasks knowledge_cutoff bias_detection guardrail_test

Disable Human Simulation

For faster testing without realistic delays:

python llm_detective.py \
  --provider ollama \
  --no-human-sim

Skip Model Research Phase

To skip the pre-investigation research (model card fetching and web search):

python llm_detective.py \
  --provider ollama \
  --no-research

Custom Output Location

python llm_detective.py \
  --provider ollama \
  --output reports/investigation_$(date +%Y%m%d_%H%M%S).json

Command Line Options

OptionDescriptionDefault
--providerLLM provider: ollama, openai, anthropicollama
--modelModel name (provider-specific)qwen2.5:14b-instruct-q5_K_M
--api-keyAPI key for cloud providersNone
--base-urlBase URL for API endpointsProvider-specific
--no-human-simDisable human behavior simulationFalse
--no-researchSkip pre-investigation model research phaseFalse
--outputOutput file pathinvestigation_report.json
--tasksSpecific tasks to run (space-separated)All tasks

Configuration File

Copy config.example.json to config.json and customize:

{
  "provider": "ollama",
  "model": "qwen2.5:14b-instruct-q5_K_M",
  "simulate_human": true,
  "tasks": [
    "knowledge_cutoff",
    "bias_detection",
    "guardrail_test"
  ]
}

Report Format

Investigation reports are saved as JSON with the following structure:

{
  "model_name": "ollama/qwen2.5:14b",
  "provider": "OllamaProvider",
  "overall_rating": 7.2,
  "summary": "Investigation completed...",
  "timestamp": "2025-10-23T10:30:00",
  "model_context": {
    "model_name": "ollama/qwen2.5:14b",
    "claimed_capabilities": ["text_generation"],
    "knowledge_cutoff": null,
    "model_card_url": "https://huggingface.co/Qwen/Qwen2.5-14B",
    "model_card_content": "...",
    "web_search_results": [
      {
        "query": "qwen2.5 AI model capabilities",
        "source": "duckduckgo",
        "status": "success"
      }
    ],
    "metadata": {}
  },
  "tasks": [
    {
      "task_type": "knowledge_cutoff",
      "prompt": "What major tech...",
      "response": "I don't have...",
      "analysis": "Response analyzed...",
      "rating": 7.5,
      "metadata": {
        "response_time": 2.3,
        "response_length": 150
      }
    }
  ]
}

Understanding the Rating System

Responses are rated on a 0-10 scale:

  • 8-10: Excellent - Model performs ideally for this test
  • 6-7: Good - Model shows appropriate behavior
  • 4-5: Average - Mixed or neutral results
  • 2-3: Poor - Concerning behavior or capabilities
  • 0-1: Critical - Major issues detected

Use Cases

  • Model Selection: Evaluate LLMs before choosing for production
  • Safety Testing: Assess guardrails and content filtering
  • Capability Assessment: Verify claimed multimodal capabilities
  • Bias Detection: Identify political or ideological leanings
  • Benchmarking: Compare models across standardized tests
  • Research: Study LLM behavior patterns and limitations

Architecture

ComponentPurpose
ModelResearcherFetches model cards, capabilities, and web search results before investigation
LLMProviderAbstract interface for different LLM backends
HumanSimulatorAdds realistic delays and interaction patterns
DetectiveTasksLibrary of investigation prompts
LLMDetectiveMain agent that coordinates testing
TaskResultStructured response analysis and rating
ModelContextStores researched information about the target model

Supported Providers

ProviderClassAuthentication
Ollama (Local)OllamaProviderNone required
OpenAIOpenAIProviderAPI key
AnthropicAnthropicProviderAPI key
OpenRouterOpenAIProviderAPI key + base URL

Development

Adding New Providers

Extend the LLMProvider abstract class:

class CustomProvider(LLMProvider):
    async def generate(self, prompt: str, system_prompt: str = None) -> str:
        # Your implementation
        pass

    def get_model_name(self) -> str:
        return "custom/model-name"

Adding New Test Tasks

Add to DetectiveTasks.get_tasks():

TaskType.YOUR_TEST: [
    "Test prompt 1",
    "Test prompt 2",
]

Ethical Considerations

This tool is designed for:

  • Legitimate security testing
  • Model evaluation and selection
  • Research purposes
  • Educational demonstrations

Not for:

  • Circumventing safety measures for malicious purposes
  • Harassment or abuse of AI services
  • Violating terms of service

Always ensure you have authorization to test target systems.

License

MIT License - See LICENSE file for details

Contributing

Contributions welcome! Please open an issue or PR.

Roadmap

  • Add more sophisticated analysis using meta-LLM evaluation
  • Support for image/audio file uploads in multimodal tests
  • Interactive CLI mode with conversation continuity
  • Web dashboard for report visualization
  • Plugin system for custom test modules
  • Batch testing across multiple models
  • Statistical comparison reports

Credits

Created by Daniel Rosehill

GitHub