# OGhidra Configuration File # This file contains environment variables for configuring the Ollama-GhidraMCP Bridge # COPY THIS FILE TO .env AND EDIT THE VALUES # ===== NECESSARY CONFIGURATIONS ===== # Active LLM Provider ('ollama', 'external', or 'custom_api') LLM_PROVIDER=external # Generic External API Configuration (Google, OpenAI, etc.) EXTERNAL_PROVIDER=google EXTERNAL_API_KEY=YOUR_API_KEY_HERE EXTERNAL_MODEL=your-model-name EXTERNAL_EMBEDDING_MODEL=gemini-embedding-001 EXTERNAL_TIMEOUT=120 EXTERNAL_TEMPERATURE=0.7 EXTERNAL_MAX_TOKENS=8192 # Ollama Configuration OLLAMA_BASE_URL=http://localhost:11434/ OLLAMA_MODEL=your-model-name OLLAMA_EMBEDDING_MODEL=nomic-embed-text OLLAMA_TIMEOUT=300 OLLAMA_USERNAME=foo OLLAMA_PASSWORD=bar # ═══════════════════════════════════════════════════════════════════════════════ # CUSTOM API CONFIGURATION (OpenAI-compatible APIs) # ═══════════════════════════════════════════════════════════════════════════════ # Set LLM_PROVIDER=custom_api to use this configuration # # TOKEN LIMITS - Adjust based on YOUR model: # - Different models have different output limits (e.g., 4K, 8K, 16K, 32K, 64K, 128K) # - Start with 4096. Increase if responses are truncated. # - Check your model's documentation for specific limits # CUSTOM_API_URL=https://api.example.com/v1/chat/completions CUSTOM_API_KEY=your-api-key-here CUSTOM_API_MODEL=your-model-name CUSTOM_API_EMBEDDING_MODEL=your-embedding-model CUSTOM_API_TIMEOUT=300 CUSTOM_API_TEMPERATURE=0.7 CUSTOM_API_MAX_TOKENS=4096 CUSTOM_API_VERIFY_SSL=false CUSTOM_API_SYSTEM_PROMPT= CUSTOM_API_REQUEST_DELAY=0.0 CUSTOM_API_MAX_RETRIES=3 # Global throttling / concurrency control (helps prevent 429 bursts) # - Concurrency=1 prevents overlapping requests during agentic loops. # - Global min interval spaces request starts (in seconds). CUSTOM_API_MAX_CONCURRENCY=1 CUSTOM_API_GLOBAL_MIN_INTERVAL=0.0 # Respect provider Retry-After header on 429/503 CUSTOM_API_RESPECT_RETRY_AFTER=true CUSTOM_API_RETRY_AFTER_MAX_SECONDS=60 # Adaptive throttling (auto-increase on 429/503 retries, slowly relax on success) CUSTOM_API_ADAPTIVE_THROTTLE_ENABLED=true CUSTOM_API_ADAPTIVE_MAX_INTERVAL=10.0 CUSTOM_API_ADAPTIVE_INCREASE_FACTOR=1.5 CUSTOM_API_ADAPTIVE_DECREASE_FACTOR=0.9 CUSTOM_API_ADAPTIVE_SUCCESS_STREAK_THRESHOLD=10 CUSTOM_API_ADAPTIVE_JITTER_SECONDS=0.25 # ===== OPTIONAL CONFIGURATIONS ===== # Review Agent's level of approval #REVIEW_THOROUGHNESS=basic # Quick pass/fail REVIEW_THOROUGHNESS=standard # Balanced (default) #REVIEW_THOROUGHNESS=thorough # Comprehensive # LLM Logging Configuration # Enable comprehensive logging of all LLM interactions (prompts, responses, timing, tokens) LLM_LOGGING_ENABLED=true LLM_LOG_FILE=logs/llm_interactions.log LLM_LOG_PROMPTS=true LLM_LOG_RESPONSES=true LLM_LOG_TOKENS=true LLM_LOG_TIMING=true LLM_LOG_FORMAT=json # Options for LLM_LOG_FORMAT: # - json: Structured JSON format (recommended for parsing and analysis) # - text: Human-readable text format # To disable specific logging components while keeping LLM_LOGGING_ENABLED=true: # - LLM_LOG_PROMPTS=false (don't log prompts) # - LLM_LOG_RESPONSES=false (don't log responses) # - LLM_LOG_TOKENS=false (don't log token counts) # - LLM_LOG_TIMING=false (don't log timing information) # GhidraMCP Configuration GHIDRA_BASE_URL=http://localhost:8080/ GHIDRA_TIMEOUT=30 GHIDRA_MOCK_MODE=false MAX_EXECUTION_STEPS=5 # Increased from 10 to 20 # ===== AGENTIC CYCLES (Outer Loop) ===== MAX_AGENTIC_CYCLES=2 # Investigation cycles AGENTIC_LOOP_ENABLED=true # Enable adaptive re-planning # Delay between ollama calls (some servers auto reject too many requests especially cloud hosting) OLLAMA_REQUEST_DELAY=2.0 # ===== CONTEXT MANAGEMENT ===== # These settings control how much data the AI can process per request. # All char limits scale proportionally to CONTEXT_BUDGET (chars ≈ tokens × 4). # Adjust CONTEXT_BUDGET based on your model's context window size. # # SCALING GUIDE (based on CONTEXT_BUDGET): # ┌─────────────────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐ # │ Variable │ 25K │ 50K │ 100K │ 200K │ 500K │ 1M │ # ├─────────────────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤ # │ CURRENT_LOOP_MAX │ 500 │ 1000 │ 2000 │ 4000 │ 10000 │ 20000 │ # │ PREV_LOOP_MAX │ 100 │ 200 │ 400 │ 800 │ 2000 │ 4000 │ # │ OLDER_LOOP_MAX │ 25 │ 50 │ 100 │ 200 │ 500 │ 1000 │ # │ MAX_DETAILED_STEPS │ 5 │ 8 │ 10 │ 15 │ 20 │ 25 │ # └─────────────────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┘ # Formula: CURRENT_LOOP ≈ CONTEXT_BUDGET × 0.02 (2% of budget) # Maximum context budget in tokens (adjust to your LLM's context window limit) # Examples: 8000 for smaller models, 100000 for large context models, 200000+ for frontier models CONTEXT_BUDGET=100000 # Fraction of context budget allocated for execution results (0.1-0.8) CONTEXT_BUDGET_EXECUTION=0.4 # Enable LLM-based summarization for large results ENABLE_RESULT_SUMMARIZATION=true # Enable result caching with get_cached_result() references RESULT_CACHE_ENABLED=true # Enable tiered context compression (recent=detailed, older=summarized) TIERED_CONTEXT_ENABLED=true # Tiered context char limits (based on how old the loop is): # - Current loop: full details up to this limit CURRENT_LOOP_MAX_CHARS=2000 # - Previous loop (1 cycle ago): bullet-point summaries PREV_LOOP_MAX_CHARS=400 # - Older loops (2+ cycles ago): one-line references only OLDER_LOOP_MAX_CHARS=100 # Sliding window: number of recent steps kept in full detail # Older steps are compressed to one-liners with cache hints MAX_DETAILED_STEPS=10 # Hybrid Context Management TOP_N_PER_CATEGORY=10 ENABLE_CORRELATION_HINTS=true MIN_CORRELATION_MENTIONS=2 ENABLE_CYCLE_CONCLUSIONS=true # ===== INTERACTIVE EXECUTION GATE ===== # pause execution at critical moments EXECUTION_GATE_ENABLED=true GATE_ON_ARTIFACT=true # Pause when critical artifact found (crypto keys, credentials, etc.) GATE_ON_REPETITION=true # Pause on N identical tool calls (doom-loop detection) # Note: Investigation tools (xrefs, decompile, list_*) are exempt # from repetition detection to allow thorough analysis GATE_REPETITION_THRESHOLD=3 # How many identical calls before triggering GATE_ON_HIGH_RISK_TOOL=false # Pause before destructive tools (rename) GATE_AUTO_RESUME_TIMEOUT=0 # 0 = wait forever, >0 = auto-resume after N seconds # ===== SESSION COMPACTION ===== # Smart context pruning to prevent overflow (empty responses from context saturation) COMPACTION_ENABLED=true COMPACTION_THRESHOLD=0.75 # Trigger at 75% context usage COMPACTION_AUTO=true # Auto-compact between agentic cycles