Experience-Driven Black-Box Cost Control for Coding Agents
Python agentic-aiagentic-codingai-codingai-coding-assistantanthropicartificial-intelligenceclaude-codecodexcoding-agentcoding-agentscost-optimizationcost-reductiondeveloper-toolsgithub-copilotllmopen-sourceopenaiproductivitytoken-optimization
Compare Codex project paths case-insensitively on Windows
juguangmin910b906c588d
diff --git a/tests/test_live_hooks.py b/tests/test_live_hooks.pyindex c0b8a73..5bf6993 100644--- a/tests/test_live_hooks.py+++ b/tests/test_live_hooks.py@@ -1358,6 +1358,16 @@ def test_codex_trust_is_read_from_the_users_config(tmp_path, repo):assert denylist.codex_project_trusted(repo, env) is False[email protected](os.name != "nt", reason="Windows paths are case-insensitive")+def test_codex_trust_matches_the_lowercased_path_codex_writes_on_windows(tmp_path, repo):+ home = tmp_path / "codex-home"+ home.mkdir()+ env = {"CODEX_HOME": str(home)}+ (home / "config.toml").write_text(f"[projects.'{str(repo).lower()}']\n"+ 'trust_level = "trusted"\n')+ assert denylist.codex_project_trusted(repo, env) is True++def test_copilot_trust_is_read_from_its_config(tmp_path, repo):home = tmp_path / "copilot-home"home.mkdir()diff --git a/tokeneconomizer/plugin/denylist.py b/tokeneconomizer/plugin/denylist.pyindex ad2b62c..93cca69 100644--- a/tokeneconomizer/plugin/denylist.py+++ b/tokeneconomizer/plugin/denylist.py@@ -503,12 +503,12 @@ def codex_project_trusted(repo_root, env=None):text = open(os.path.join(codex_home(env), "config.toml"), encoding="utf-8").read()except OSError:return None- want = {os.path.abspath(repo_root), os.path.realpath(repo_root)}+ want = {os.path.normcase(p) for p in (os.path.abspath(repo_root), os.path.realpath(repo_root))}current = Nonefor line in text.splitlines():m = re.match(r'^\s*\[projects\.(?:"([^"]+)"|\'([^\']+)\')\]\s*$', line)if m:- current = m.group(1) or m.group(2)+ current = os.path.normcase(m.group(1) or m.group(2))continueif _ANY_HEADER_RE.match(line):current = None