diff --git a/run_agent.py b/run_agent.py index 9b92e62f7f..4217877ebf 100644 --- a/run_agent.py +++ b/run_agent.py @@ -83,6 +83,7 @@ from agent.prompt_builder import ( DEFAULT_AGENT_IDENTITY, PLATFORM_HINTS, MEMORY_GUIDANCE, SESSION_SEARCH_GUIDANCE, SKILLS_GUIDANCE, build_nous_subscription_prompt, + build_workspace_guidance, ) from agent.model_metadata import ( fetch_model_metadata, @@ -3733,6 +3734,9 @@ class AIAgent: tool_guidance.append(SESSION_SEARCH_GUIDANCE) if "skill_manage" in self.valid_tool_names: tool_guidance.append(SKILLS_GUIDANCE) + workspace_block = build_workspace_guidance(set(self.valid_tool_names)) + if workspace_block: + tool_guidance.append(workspace_block) if tool_guidance: prompt_parts.append(" ".join(tool_guidance)) diff --git a/tests/agent/test_prompt_builder.py b/tests/agent/test_prompt_builder.py index eff5a8e216..76a358c94b 100644 --- a/tests/agent/test_prompt_builder.py +++ b/tests/agent/test_prompt_builder.py @@ -1122,3 +1122,35 @@ class TestWorkspaceGuidance: out = build_workspace_guidance({"workspace_search"}) assert isinstance(out, str) assert len(out.strip()) > 0 + + def test_wiring_into_system_prompt(self): + """End-to-end: the assembler output reaches the system prompt when + workspace_search is in valid_tool_names. + + Uses the same tool_guidance collection pattern as _build_system_prompt + in run_agent.py so we verify the contract without booting AIAgent. + """ + from agent.prompt_builder import ( + MEMORY_GUIDANCE, + build_workspace_guidance, + ) + valid_tool_names = {"memory", "workspace_search", "workspace_retrieve"} + tool_guidance = [] + if "memory" in valid_tool_names: + tool_guidance.append(MEMORY_GUIDANCE) + ws = build_workspace_guidance(valid_tool_names) + if ws: + tool_guidance.append(ws) + combined = " ".join(tool_guidance) + assert WORKSPACE_SEARCH_GUIDANCE_CORE in combined + assert WORKSPACE_RETRIEVE_GUIDANCE in combined + assert MEMORY_GUIDANCE in combined + + def test_wiring_skips_when_workspace_unavailable(self): + valid_tool_names = {"memory"} + tool_guidance = [] + ws = build_workspace_guidance(valid_tool_names) + if ws: + tool_guidance.append(ws) + combined = " ".join(tool_guidance) + assert WORKSPACE_SEARCH_GUIDANCE_CORE not in combined