feat(run_agent): inject workspace guidance into system prompt

Wires build_workspace_guidance() into AIAgent._build_system_prompt()
alongside the existing memory/session_search/skills hooks. Guidance is
assembled dynamically from self.valid_tool_names and appended to the
tool_guidance section.

Closes the 0/6 workspace_search discoverability gap measured in the
2026-04-20 A/B dogfood.
This commit is contained in:
alt-glitch
2026-04-20 01:55:15 +05:30
parent 3c850b8ffc
commit b201b1f38f
2 changed files with 36 additions and 0 deletions
+4
View File
@@ -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))
+32
View File
@@ -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