Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

Remove the Switch Console link from in-room command replies

raullopez-sandbox720df1e2d59e
diff --git a/core/switch_core/bridges/agent/commands.py b/core/switch_core/bridges/agent/commands.py
index 84d44fa67..f8ccdab1e 100644
--- a/core/switch_core/bridges/agent/commands.py
+++ b/core/switch_core/bridges/agent/commands.py
@@ -618,7 +618,6 @@ async def _decide_control_command(
if level == "unsupported":
return say(texts.unsupported)
- deeplink: str | None = None
role: str | None = None
if level == "session_dependent":
async with client.session_factory() as session:
@@ -649,18 +648,12 @@ async def _decide_control_command(
return say(texts.no_live_session)
if not caps.get(command):
return say(texts.no_session)
- deeplink = runtime.deeplink_url if runtime else None
args = event.args
if command in ("reset", "compact"):
args = role or ""
- # Mirror the runtime "working" surface: link back to the session in
- # Switch Console when we know its deeplink.
- body = (
- f"{texts.ack} ([Open in Switch Console]({deeplink}))" if deeplink else texts.ack
- )
- decision = say(body)
+ decision = say(texts.ack)
return ControlDecision(
queued=CommandPayload(
command=command,
@@ -1842,17 +1835,10 @@ def _format_status_lines(
agents: list[Agent],
statuses: dict[str, AgentStatus],
runtime_states: dict[str, str],
- deeplinks: dict[str, str],
) -> str:
"""Render the !status summary: one line per agent (sorted by the name it is
shown under) with its presence emoji + label, runtime state (if any),
- agent_type, and a Switch Console deeplink to its session
- when one is known.
-
- The deeplink is shown only for an agent whose session is LIVE in this room:
- the stored link is per (agent, room) and survives a room switch, so once the
- session moves away it would point at a session no longer here. Gating on
- LIVE keeps the link from going stale when an agent hops rooms."""
+ and agent_type."""
lines = ["**Agent status in this room:**"]
for agent in sorted(agents, key=lambda a: (a.display_name or a.name).lower()):
status = statuses.get(agent.id, AgentStatus.NO_SESSION)
@@ -1862,11 +1848,7 @@ def _format_status_lines(
head = f"{emoji} **{name}** — {label}"
if runtime is not None:
head += f" · {runtime}"
- parts = [head, agent.agent_type]
- deeplink = deeplinks.get(agent.id)
- if deeplink and status == AgentStatus.LIVE:
- parts.append(f"[Open in Switch Console]({deeplink})")
- lines.append("- " + " · ".join(parts))
+ lines.append(f"- {head} · {agent.agent_type}")
return "\n".join(lines)
@@ -1900,15 +1882,12 @@ async def _cmd_status(
)
runtime_rows = await AgentRuntimeStateStore().get_by_room(session, meta.room_id)
runtime_states = {row.agent_id: row.state for row in runtime_rows}
- deeplinks = {
- row.agent_id: row.deeplink_url for row in runtime_rows if row.deeplink_url
- }
await _reply(
client,
room,
event,
- _format_status_lines(agents, statuses, runtime_states, deeplinks),
+ _format_status_lines(agents, statuses, runtime_states),
)
diff --git a/core/switch_core/bridges/collaboration/session/renderers/neutral.py b/core/switch_core/bridges/collaboration/session/renderers/neutral.py
index 73a0792c9..02c496a5b 100644
--- a/core/switch_core/bridges/collaboration/session/renderers/neutral.py
+++ b/core/switch_core/bridges/collaboration/session/renderers/neutral.py
@@ -14,8 +14,7 @@ Four renderings live here:
activity presentation of its own.
- `turn_status` — the compact one a platform edits in place while a turn runs:
where the turn got to, how long it has been going, what it is doing now, how
- the tool calls went, and one link to the Console. One message, edited, never
- a second one.
+ the tool calls went. One message, edited, never a second one.
- `activity_log` — the calls behind that status and what the agent said while
making them, one to a line. Not part of the status and not posted beside it:
what a platform draws where it has somewhere to put a list, which on Discord
diff --git a/core/switch_core/bridges/collaboration/session/renderers/slack.py b/core/switch_core/bridges/collaboration/session/renderers/slack.py
index a3ef37ce1..d82508bf1 100644
--- a/core/switch_core/bridges/collaboration/session/renderers/slack.py
+++ b/core/switch_core/bridges/collaboration/session/renderers/slack.py
@@ -130,9 +130,6 @@ _MAX_ACTIVITY_LINES = 12
# limit, and a card is read at a glance.
_MAX_PLAN_TASKS = 50
# What a section spends on the turn, the remaining row being the session card.
-# Fixed rather than widened when there is no session url to put in that card:
-# the url can arrive after the stream has opened, and a boundary that moved with
-# it would re-cut every page already drawn.
_MAX_SECTION_ITEMS = _MAX_PLAN_TASKS - 1
_MAX_PLAN_TITLE = 150
_MAX_PLAN_TASK_TITLE = 200
@@ -1765,10 +1762,6 @@ def _fit_details(blocks: list[dict[str, Any]], limit: int) -> None:
which is why running out of retreat here is an exception rather than a
smaller cut: it would mean cards arriving from somewhere this was not
written to bound.
-
- So is the session card, whose detail is a link rather than prose. Cutting
- its label would leave a link reading "Open in Cons…", and cutting two of
- them buys back nothing worth having.
"""
if _weigh(blocks) <= limit:
return
diff --git a/core/tests/switch_core/bridges/agent/test_commands_status.py b/core/tests/switch_core/bridges/agent/test_commands_status.py
index d261f96f8..efc81d1b6 100644
--- a/core/tests/switch_core/bridges/agent/test_commands_status.py
+++ b/core/tests/switch_core/bridges/agent/test_commands_status.py
@@ -47,7 +47,7 @@ class TestFormatStatusLines:
]
statuses = {"w": AgentStatus.NO_SESSION, "m": AgentStatus.LIVE}
- out = _format_status_lines(agents, statuses, {}, {})
+ out = _format_status_lines(agents, statuses, {})
lines = out.splitlines()
assert lines[0] == "**Agent status in this room:**"
@@ -69,7 +69,7 @@ class TestFormatStatusLines:
"d": AgentStatus.AWAITING_MANUAL_POLL,
}
- out = _format_status_lines(agents, statuses, {}, {})
+ out = _format_status_lines(agents, statuses, {})
assert "🟢 **a** — live" in out
assert "🔴 **b** — disconnected" in out
@@ -78,76 +78,44 @@ class TestFormatStatusLines:
def test_no_capabilities_omits_the_segment(self) -> None:
agents = [_agent("a", "a", "always_on")]
- out = _format_status_lines(agents, {"a": AgentStatus.LIVE}, {}, {})
+ out = _format_status_lines(agents, {"a": AgentStatus.LIVE}, {})
# No trailing " · " capability segment when the agent has neither cap.
assert out.endswith("🟢 **a** — live · always_on")
def test_runtime_state_appended_after_presence(self) -> None:
agents = [_agent("a", "alice", "session_addressable")]
- out = _format_status_lines(
- agents, {"a": AgentStatus.LIVE}, {"a": "working"}, {}
- )
+ out = _format_status_lines(agents, {"a": AgentStatus.LIVE}, {"a": "working"})
assert out.endswith("🟢 **alice** — live · ⚙️ working · session_addressable")
def test_awaiting_input_runtime_state_rendered(self) -> None:
agents = [_agent("a", "alice", "session_addressable")]
out = _format_status_lines(
- agents, {"a": AgentStatus.LIVE}, {"a": "awaiting-input"}, {}
+ agents, {"a": AgentStatus.LIVE}, {"a": "awaiting-input"}
)
assert "✋ awaiting input" in out
def test_idle_runtime_state_is_omitted(self) -> None:
# idle carries no extra signal over the presence status.
agents = [_agent("a", "alice", "session_addressable")]
- out = _format_status_lines(agents, {"a": AgentStatus.LIVE}, {"a": "idle"}, {})
+ out = _format_status_lines(agents, {"a": AgentStatus.LIVE}, {"a": "idle"})
assert out.endswith("🟢 **alice** — live · session_addressable")
- def test_switchdash_deeplink_appended_when_present(self) -> None:
- agents = [_agent("a", "alice", "session_addressable")]
- out = _format_status_lines(
- agents,
- {"a": AgentStatus.LIVE},
- {},
- {"a": "switchdash://session?server=s&agent=a&room=r"},
- )
- assert out.endswith(
- "· [Open in Switch Console](switchdash://session?server=s&agent=a&room=r)"
- )
-
- def test_no_deeplink_segment_when_absent(self) -> None:
- agents = [_agent("a", "alice", "session_addressable")]
- out = _format_status_lines(agents, {"a": AgentStatus.LIVE}, {}, {})
- assert "Switch Console" not in out
-
- def test_deeplink_hidden_when_session_not_live_here(self) -> None:
- # A stored link survives a room switch; don't surface it where the
- # agent's session is no longer live (it would point at a session that
- # has moved on).
- agents = [_agent("a", "alice", "session_addressable")]
- out = _format_status_lines(
- agents,
- {"a": AgentStatus.NO_SESSION},
- {},
- {"a": "switchdash://session?server=s&agent=a&room=r"},
- )
- assert "Switch Console" not in out
-
class TestFormatStatusLinesDisplayNames:
def test_display_name_precedes_the_identifier_in_backticks(self) -> None:
agents = [_agent("a", "switchdev", "always_on", display_name="Switch Dev")]
- out = _format_status_lines(agents, {"a": AgentStatus.LIVE}, {}, {})
+ out = _format_status_lines(agents, {"a": AgentStatus.LIVE}, {})
assert "**Switch Dev (`switchdev`)** — live" in out
def test_no_display_name_renders_the_identifier_once(self) -> None:
agents = [_agent("a", "switchdev", "always_on")]
- out = _format_status_lines(agents, {"a": AgentStatus.LIVE}, {}, {})
+ out = _format_status_lines(agents, {"a": AgentStatus.LIVE}, {})
assert "**switchdev** — live" in out
assert "(`switchdev`)" not in out
def test_a_display_name_cannot_ping_the_channel(self) -> None:
agents = [_agent("a", "switchdev", "always_on", display_name="@everyone")]
- out = _format_status_lines(agents, {"a": AgentStatus.LIVE}, {}, {})
+ out = _format_status_lines(agents, {"a": AgentStatus.LIVE}, {})
assert _MENTION.search(out) is None
assert "switchdev" in out
@@ -160,7 +128,7 @@ class TestFormatStatusLinesDisplayNames:
display_name="[click here](https://example.invalid)",
)
]
- out = _format_status_lines(agents, {"a": AgentStatus.LIVE}, {}, {})
+ out = _format_status_lines(agents, {"a": AgentStatus.LIVE}, {})
assert "](https://example.invalid)" not in out
def test_order_follows_the_displayed_label(self) -> None:
@@ -171,7 +139,7 @@ class TestFormatStatusLinesDisplayNames:
_agent("a", "alpha", "always_on", display_name="Zeta Bot"),
]
statuses = {"z": AgentStatus.LIVE, "a": AgentStatus.LIVE}
- lines = _format_status_lines(agents, statuses, {}, {}).splitlines()
+ lines = _format_status_lines(agents, statuses, {}).splitlines()
assert "Alpha Bot" in lines[1]
assert "Zeta Bot" in lines[2]
@@ -181,7 +149,7 @@ class TestFormatStatusLinesDisplayNames:
_agent("b", "zeta", "always_on", display_name="Bravo Bot"),
]
statuses = {"w": AgentStatus.LIVE, "b": AgentStatus.LIVE}
- lines = _format_status_lines(agents, statuses, {}, {}).splitlines()
+ lines = _format_status_lines(agents, statuses, {}).splitlines()
assert "Bravo Bot" in lines[1]
assert "worker" in lines[2]