Skip to content

Commit 1b4604c

Browse files
Brian KrafftCopilot
andcommitted
fix(5.9): route internal calls through agent._method() for MRO safety
- tools.py: _get_available_tools fallback calls agent._load_all_tools() - visual.py: _visual_analysis_callback calls agent._enhance_result_with_visual_context() - workspace.py: _check_workspace_artifacts calls agent._get_workspace_path/scan - Update test _FakeAgent classes with delegate methods - Found by GPT-5.4 /collab review - 1,683 passed, 127 skipped Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f3870b4 commit 1b4604c

6 files changed

Lines changed: 27 additions & 9 deletions

File tree

openspace/agents/grounding/tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async def _get_available_tools(agent, task_description: Optional[str]) -> List:
6060
)
6161
except Exception as e:
6262
logger.warning(f"Auto-search tools failed, falling back to full list: {e}")
63-
tools = await _load_all_tools(agent, grounding_client)
63+
tools = await agent._load_all_tools(grounding_client)
6464

6565
# Append retrieve_skill tool when skill registry is available
6666
if agent._skill_registry and agent._skill_registry.list_skills():

openspace/agents/grounding/visual.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async def _visual_analysis_callback(
7878
return result
7979

8080
# 7. Perform visual analysis
81-
return await _enhance_result_with_visual_context(agent, result, tool_name)
81+
return await agent._enhance_result_with_visual_context(result, tool_name)
8282

8383

8484
async def _enhance_result_with_visual_context(

openspace/agents/grounding/workspace.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ async def _check_workspace_artifacts(agent, context: Dict[str, Any]) -> Dict[str
8888
workspace_info: Dict[str, Any] = {"has_files": False, "files": [], "file_details": {}, "recent_files": []}
8989

9090
try:
91-
# Get workspace path — call module-level function directly
92-
workspace_path = _get_workspace_path(context)
91+
# Get workspace path — route through agent for MRO preservation
92+
workspace_path = agent._get_workspace_path(context)
9393

94-
# Scan workspace files — call module-level function directly
95-
scan_result = _scan_workspace_files(workspace_path, recent_threshold=600)
94+
# Scan workspace files — route through agent for MRO preservation
95+
scan_result = agent._scan_workspace_files(workspace_path, recent_threshold=600)
9696

9797
if scan_result["files"]:
9898
workspace_info["has_files"] = True

tests/test_grounding_tools.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ def __init__(self):
2929
def has_skill_context(self) -> bool:
3030
return self._skill_context is not None
3131

32+
async def _load_all_tools(self, grounding_client):
33+
"""Delegate for MRO — calls module function."""
34+
from openspace.agents.grounding.tools import _load_all_tools
35+
return await _load_all_tools(self, grounding_client)
36+
3237

3338
# ── _get_available_tools ───────────────────────────────────────────
3439

tests/test_grounding_visual.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ def __init__(self):
4545
self._visual_analysis_timeout = 5.0
4646
self._current_instruction = "test instruction"
4747

48+
async def _enhance_result_with_visual_context(self, result, tool_name):
49+
"""Delegate for MRO — calls module function."""
50+
from openspace.agents.grounding.visual import _enhance_result_with_visual_context
51+
return await _enhance_result_with_visual_context(self, result, tool_name)
52+
4853

4954
# ── _select_key_screenshots (pure function) ────────────────────────
5055

tests/test_grounding_workspace.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,17 @@ def test_files_sorted_alphabetically(self):
117117

118118

119119
class _FakeAgent:
120-
"""Minimal stand-in — workspace module calls module-level functions directly,
121-
so agent is only used as first parameter for _check_workspace_artifacts."""
122-
pass
120+
"""Minimal stand-in — workspace module now routes through agent._method()."""
121+
122+
@staticmethod
123+
def _get_workspace_path(context):
124+
from openspace.agents.grounding.workspace import _get_workspace_path
125+
return _get_workspace_path(context)
126+
127+
@staticmethod
128+
def _scan_workspace_files(workspace_path, recent_threshold=600):
129+
from openspace.agents.grounding.workspace import _scan_workspace_files
130+
return _scan_workspace_files(workspace_path, recent_threshold)
123131

124132

125133
class TestCheckWorkspaceArtifacts:

0 commit comments

Comments
 (0)