From b6948f0454c1455d4ff82598d5d08d3721440848 Mon Sep 17 00:00:00 2001 From: kimi Date: Mon, 23 Mar 2026 21:34:41 -0400 Subject: [PATCH] feat: make perception_cache confidence threshold configurable Move hardcoded 0.85 threshold from perception_cache.py to config.py as perception_confidence_threshold setting with default 0.85. Fixes #1259 --- src/config.py | 4 ++++ src/timmy/sovereignty/perception_cache.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config.py b/src/config.py index 4de9ad46..8da3d2b5 100644 --- a/src/config.py +++ b/src/config.py @@ -455,6 +455,10 @@ class Settings(BaseSettings): # Background meditation interval in seconds (0 = disabled). scripture_meditation_interval: int = 0 + # ── Perception Cache ─────────────────────────────────────────────── + # Minimum confidence threshold for template matching in perception cache. + perception_confidence_threshold: float = 0.85 + def _compute_repo_root(self) -> str: """Auto-detect repo root if not set.""" if self.repo_root: diff --git a/src/timmy/sovereignty/perception_cache.py b/src/timmy/sovereignty/perception_cache.py index fe0df9b9..4d4de63b 100644 --- a/src/timmy/sovereignty/perception_cache.py +++ b/src/timmy/sovereignty/perception_cache.py @@ -8,6 +8,8 @@ from typing import Any import cv2 import numpy as np +from config import settings + @dataclass class Template: @@ -43,7 +45,7 @@ class PerceptionCache: best_match_confidence = max_val best_match_name = template.name - if best_match_confidence > 0.85: # TODO: Make this configurable per template + if best_match_confidence > settings.perception_confidence_threshold: return CacheResult( confidence=best_match_confidence, state={"template_name": best_match_name} )