refactor(tools): consolidate task-override lookup into one helper
The raw-key-first-then-collapsed override lookup was hand-rolled in three places with subtly different spellings: terminal_tool's command setup, and both file_tools._registered_task_cwd_override and _get_file_ops. Since that exact raw-vs-collapsed invariant is what the session-cwd fix depends on, keeping three copies invites the drift that caused the original bug. Add terminal_tool.resolve_task_overrides(task_id) as the single source and route all three sites through it. Behaviour is unchanged (verified byte-equivalent across raw/collapsed/isolation/None/subagent inputs).
This commit is contained in:
+4
-14
@@ -123,15 +123,9 @@ def _registered_task_cwd_override(task_id: str = "default") -> str | None:
|
||||
read that raw override before falling back to the collapsed container key.
|
||||
"""
|
||||
try:
|
||||
from tools.terminal_tool import _resolve_container_task_id, _task_env_overrides
|
||||
from tools.terminal_tool import resolve_task_overrides
|
||||
|
||||
raw_task_id = task_id or "default"
|
||||
container_key = _resolve_container_task_id(raw_task_id)
|
||||
overrides = (
|
||||
_task_env_overrides.get(raw_task_id)
|
||||
or _task_env_overrides.get(container_key)
|
||||
or {}
|
||||
)
|
||||
overrides = resolve_task_overrides(task_id)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
@@ -693,15 +687,11 @@ def _get_file_ops(task_id: str = "default") -> ShellFileOperations:
|
||||
terminal_env = None
|
||||
|
||||
if terminal_env is None:
|
||||
from tools.terminal_tool import _task_env_overrides
|
||||
from tools.terminal_tool import resolve_task_overrides
|
||||
|
||||
config = _get_env_config()
|
||||
env_type = config["env_type"]
|
||||
overrides = (
|
||||
_task_env_overrides.get(raw_task_id)
|
||||
or _task_env_overrides.get(task_id)
|
||||
or {}
|
||||
)
|
||||
overrides = resolve_task_overrides(raw_task_id)
|
||||
|
||||
if env_type == "docker":
|
||||
image = overrides.get("docker_image") or config["docker_image"]
|
||||
|
||||
Reference in New Issue
Block a user