Skip to content

The agent that grows with you

refactor(desktop): gate the HUD bridge sentence on tool availability, not note text

kshitijk4poor09581cacaa8d
diff --git a/agent/prompt_builder.py b/agent/prompt_builder.py
index 07c6490c5a7..4dec6655283 100644
--- a/agent/prompt_builder.py
+++ b/agent/prompt_builder.py
@@ -631,7 +631,8 @@ def hud_surface_note(valid_tool_names: "set[str] | None" = None,
(True, "This is a prior, not a rule: when the request names its own target, follow the request."),
)
note = " ".join(text for ok, text in gated if ok)
- bridged = [name for name in ("read_window_below", "computer_use") if name in deferred and name in note]
+ named = ("read_window_below", "computer_use") if "computer_use" in names else ("read_window_below",)
+ bridged = [name for name in named if name in deferred]
if bridged:
note += f" Call {' and '.join(bridged)} through the tool_call bridge (deferred behind tool search)."
return note + "]"
diff --git a/tests/tui_gateway/test_hud_surface_note.py b/tests/tui_gateway/test_hud_surface_note.py
index 60c5d9fb1ca..fd51f3130a8 100644
--- a/tests/tui_gateway/test_hud_surface_note.py
+++ b/tests/tui_gateway/test_hud_surface_note.py
@@ -61,10 +61,12 @@ class TestNoteContents:
def test_deferred_tools_count_and_are_routed_through_the_bridge(self):
"""Tool search defers the desktop tools by default; the note must still fire and name the bridge."""
note = hud_surface_note({"tool_call"}, {"read_window_below", "computer_use"})
+ bridge_clause = note[note.index("Call "):]
assert "read_window_below identifies that app" in note
- assert "Call read_window_below and computer_use through the tool_call bridge" in note
- assert hud_surface_note({"read_window_below"}, {"computer_use"}).count("tool_call") == 1
+ assert "read_window_below" in bridge_clause and "computer_use" in bridge_clause
+ mixed = hud_surface_note({"read_window_below"}, {"computer_use"})
+ assert "read_window_below" not in mixed[mixed.index("Call "):] # a direct tool is never sent to the bridge
class TestTurnRouting: