From 0695c104d5323939b57a603fbd269de7cd799b65 Mon Sep 17 00:00:00 2001 From: "developerz-ai[bot]" <286432749+developerz-ai[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 03:17:40 +0000 Subject: [PATCH] refactor: remove dead get_context_window and its core facade exports get_context_window (core/agent_models.py) had no caller anywhere in the repo; it was only re-exported from the core facade. Delete the helper, drop the core.__init__ import and __all__ entry, and reword the two comments that pointed at it (the MODEL_CONTEXT_WINDOWS comment and the ContextWindowsConfig docstring). MODEL_CONTEXT_WINDOWS and MODEL_CONTEXT_WINDOWS_STANDARD are retained: they are still exported and tested. CHANGELOG Unreleased records the removal of the public name. Dz-Task-Id: tsk_930a71a5c4d33b3f04b6f3e58161aa0c --- CHANGELOG.md | 4 +++ README.md | 2 +- src/claude_task_master/core/__init__.py | 2 -- src/claude_task_master/core/agent_models.py | 35 ++------------------- src/claude_task_master/core/config.py | 2 +- 5 files changed, 9 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdc347f..9ae08cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Removed + +- **Removed the dead public helper `get_context_window` from `claude_task_master.core`.** Defined in `core/agent_models.py`, re-exported through the `core` package facade and referenced by a docstring clause in `core/config.py`, it had no caller anywhere in the codebase, and its return value set no compaction threshold and no SDK context window — a model-to-window mapping nothing consumed. The data behind it is retained: `MODEL_CONTEXT_WINDOWS`, `MODEL_CONTEXT_WINDOWS_STANDARD`, `DEFAULT_COMPACT_THRESHOLD_PERCENT` and `ContextWindowsConfig` are unchanged; only the unreachable accessor and the text naming it are deleted. + ### Fixed - **The committed `requirements.txt` pinned `claude-agent-sdk==0.2.168` while the authoritative `uv.lock` resolved 0.2.150.** The artifact is a `uv pip compile` output regenerated in v0.1.90, and that compile floated the SDK 18 versions past the one this project developed against: `requirements.txt:41` carried `claude-agent-sdk==0.2.168`, while `uv.lock:277-279` resolves `claude-agent-sdk` to **0.2.150** and `pyproject.toml:29` declares `claude-agent-sdk>=0.2.150,<0.3`. The two disagreed about which SDK a downstream install would get. Nothing in CI reads the artifact — CI installs the project with `uv pip install -e ".[all]"` (`.github/workflows/ci.yml:42`) rather than from the lock — and the repo-setup handler reaches a target project's `requirements.txt` only in a narrow case: `uv pip install -r requirements.txt` (`src/claude_task_master/mcp/tool_handlers_setup.py:212-225`) runs for a project that has a `requirements.txt` but neither a `pyproject.toml` nor a `uv.lock` — a setup.py-style project — and only with `uv` on PATH; a project with a `pyproject.toml` is installed with `uv sync` (:179) or `pip install -e .[dev]` (:261) instead, and that same narrow class without `uv` on PATH gets `pip install -r requirements.txt` (:289-302). This repository has both a `pyproject.toml` and a `uv.lock`, so pointing the handler at it takes the `uv sync` path and never reads the artifact: no automated consumer here ever saw the stale pin. The artifact now pins `claude-agent-sdk==0.2.150`, matching the lock. `pyproject.toml` and `uv.lock` are untouched: this is a correction **down** to the already-resolved version, not an SDK upgrade. `tests/test_sdk_pin_consistency.py` guards the pair — it compares the committed files only (never the installed SDK) and asserts that the artifact's single `==` pin equals the lock's resolution and that both satisfy the declared range. diff --git a/README.md b/README.md index c2424d7..6c4e553 100644 --- a/README.md +++ b/README.md @@ -343,7 +343,7 @@ This creates `.claude-task-master/config.json`. The smartest tier (`opus`) defau } ``` -> **Note:** `context_windows` and `CLAUDETM_CONTEXT_*` are **currently inert metadata** retained for compatibility. Values can still be loaded from configuration, emitted by profiles, and read by the context-window helper, but they do not drive runtime auto-compaction, prevent context overflow, or grant a larger context window. Actual context limits and compaction behavior depend on Claude Code/SDK and the provider, not these settings. +> **Note:** `context_windows` and `CLAUDETM_CONTEXT_*` are **currently inert metadata** retained for compatibility. Values can still be loaded from configuration and emitted by profiles, but they do not drive runtime auto-compaction, prevent context overflow, or grant a larger context window. Actual context limits and compaction behavior depend on Claude Code/SDK and the provider, not these settings. > > Existing configurations such as the following remain accepted, but changing these values for an account tier or gateway has no runtime compaction effect: > ```json diff --git a/src/claude_task_master/core/__init__.py b/src/claude_task_master/core/__init__.py index ee8757f..67efd10 100644 --- a/src/claude_task_master/core/__init__.py +++ b/src/claude_task_master/core/__init__.py @@ -24,7 +24,6 @@ MODEL_CONTEXT_WINDOWS_STANDARD, ModelType, TaskComplexity, - get_context_window, get_tools_for_phase, parse_task_complexity, ) @@ -219,7 +218,6 @@ "MODEL_CONTEXT_WINDOWS", "MODEL_CONTEXT_WINDOWS_STANDARD", "DEFAULT_COMPACT_THRESHOLD_PERCENT", - "get_context_window", # Rate limit classes "RateLimitConfig", # State exceptions diff --git a/src/claude_task_master/core/agent_models.py b/src/claude_task_master/core/agent_models.py index 3f1fde9..c098da2 100644 --- a/src/claude_task_master/core/agent_models.py +++ b/src/claude_task_master/core/agent_models.py @@ -103,10 +103,9 @@ def get_model_name_for_complexity(cls, complexity: TaskComplexity) -> ModelType: # Constants # ============================================================================= -# Retained context-window metadata defaults (tokens) for get_context_window. -# The helper can read config.json "context_windows" overrides, but has no runtime -# compaction caller. These values do not set compaction thresholds or select a -# larger SDK window; they are retained for compatibility. +# Retained context-window metadata defaults (tokens), inert at runtime. These +# values do not set compaction thresholds or select a larger SDK window; they +# are retained for compatibility. MODEL_CONTEXT_WINDOWS = { ModelType.OPUS: 1_000_000, ModelType.FABLE: 1_000_000, @@ -183,34 +182,6 @@ def get_fallback_chain(model: ModelType) -> list[ModelType]: return chain -def get_context_window( - model: ModelType, - config: ClaudeTaskMasterConfig | None = None, -) -> int: - """Read retained context-window metadata, using config when supplied. - - This compatibility helper has no runtime compaction caller. Its return value - does not set a compaction threshold or select the SDK's context window. - - Args: - model: The model type. - config: Optional config object. If None, uses hardcoded defaults. - - Returns: - Context-window metadata in tokens, not a runtime capacity guarantee. - """ - if config is not None: - context_map = { - ModelType.OPUS: config.context_windows.opus, - ModelType.FABLE: config.context_windows.fable, - ModelType.SONNET: config.context_windows.sonnet, - ModelType.HAIKU: config.context_windows.haiku, - ModelType.SONNET_1M: config.context_windows.sonnet_1m, - } - return context_map.get(model, MODEL_CONTEXT_WINDOWS[model]) - return MODEL_CONTEXT_WINDOWS[model] - - # Legacy compact-threshold constant, retained for compatibility and unused at runtime. DEFAULT_COMPACT_THRESHOLD_PERCENT = 0.85 diff --git a/src/claude_task_master/core/config.py b/src/claude_task_master/core/config.py index a6fbfe4..982ae71 100644 --- a/src/claude_task_master/core/config.py +++ b/src/claude_task_master/core/config.py @@ -120,7 +120,7 @@ class ContextWindowsConfig(BaseModel): """Retained context-window metadata per model (in tokens). Values remain loadable from configuration and ``CLAUDETM_CONTEXT_*`` environment - variables, including those emitted by profiles, and readable by ``get_context_window``. + variables, including those emitted by profiles. They are currently inert for runtime compaction and window selection: changing them does not set a compaction threshold, prevent context overflow, or grant a larger SDK context window. Defaults and keys are retained for compatibility.