Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(resume): validate enabled agents

yh cd7ce93bc9e5a
diff --git a/core/controller.py b/core/controller.py
index f5d3717e2..d4124bc72 100644
--- a/core/controller.py
+++ b/core/controller.py
@@ -614,6 +614,11 @@ class Controller:
if not agent or not session_id:
raise ValueError("Agent and session ID are required to resume.")
+ if getattr(self, "agent_service", None):
+ available_agents = set(self.agent_service.agents.keys())
+ if agent not in available_agents:
+ raise ValueError(f"Agent '{agent}' is not enabled.")
+
# Decide whether to reuse current thread or start a new one for clarity.
reuse_thread = True
if host_message_ts and thread_id and thread_id == host_message_ts:
diff --git a/modules/im/slack.py b/modules/im/slack.py
index faefbd84b..b99edf75d 100644
--- a/modules/im/slack.py
+++ b/modules/im/slack.py
@@ -1404,9 +1404,13 @@ class SlackBot(BaseIMClient):
"""Open a modal to let users select or input a session to resume."""
self._ensure_clients()
- # Build agent options: always include common backends + any with stored sessions
+ # Build agent options limited to enabled backends when available
common_agents = ["claude", "codex", "opencode"]
- agent_keys = set(common_agents) | set(sessions_by_agent.keys())
+ registered_backends = None
+ if getattr(self, "_controller", None) and getattr(self._controller, "agent_service", None):
+ registered_backends = list(self._controller.agent_service.agents.keys())
+ allowed_agents = set(registered_backends) if registered_backends else set(common_agents)
+ agent_keys = allowed_agents
agent_options = []
for agent in sorted(agent_keys):
agent_options.append(
@@ -1420,6 +1424,8 @@ class SlackBot(BaseIMClient):
total_session_options = 0
max_session_options = 100
for agent, mapping in sessions_by_agent.items():
+ if agent not in allowed_agents:
+ continue
if not mapping:
continue
options = []
diff --git a/tests/test_resume_session.py b/tests/test_resume_session.py
index 62b4354b8..c89c9b807 100644
--- a/tests/test_resume_session.py
+++ b/tests/test_resume_session.py
@@ -11,13 +11,10 @@ class _StubSettingsManager:
def __init__(self):
self.set_calls = []
self.mark_calls = []
+ self.routing_calls = []
- def set_agent_session_mapping(
- self, settings_key, agent_name, thread_id, session_id
- ):
- self.set_calls.append(
- (settings_key, agent_name, thread_id, session_id)
- )
+ def set_agent_session_mapping(self, settings_key, agent_name, thread_id, session_id):
+ self.set_calls.append((settings_key, agent_name, thread_id, session_id))
def mark_thread_active(self, user_id, channel_id, thread_ts):
self.mark_calls.append((user_id, channel_id, thread_ts))
@@ -25,6 +22,12 @@ class _StubSettingsManager:
def list_all_agent_sessions(self, user_id):
return {}
+ def get_channel_routing(self, settings_key):
+ return None
+
+ def set_channel_routing(self, settings_key, routing):
+ self.routing_calls.append((settings_key, routing))
+
class _StubIMClient:
def __init__(self):
@@ -32,16 +35,12 @@ class _StubIMClient:
self.resume_calls = []
async def send_message(self, context, text):
- ts = f"T{len(self.messages)+1}"
+ ts = f"T{len(self.messages) + 1}"
self.messages.append((context.channel_id, context.thread_id, text, ts))
return ts
- async def open_resume_session_modal(
- self, trigger_id, sessions_by_agent, channel_id, thread_id, host_message_ts
- ):
- self.resume_calls.append(
- (trigger_id, sessions_by_agent, channel_id, thread_id, host_message_ts)
- )
+ async def open_resume_session_modal(self, trigger_id, sessions_by_agent, channel_id, thread_id, host_message_ts):
+ self.resume_calls.append((trigger_id, sessions_by_agent, channel_id, thread_id, host_message_ts))
class _StubConfig:
@@ -144,20 +143,12 @@ class ResumeSessionTests(unittest.IsolatedAsyncioTestCase):
"callback_id": "resume_session_modal",
"state": {
"values": {
- "agent_block": {
- "agent_select": {"selected_option": {"value": "codex"}}
- },
+ "agent_block": {"agent_select": {"selected_option": {"value": "codex"}}},
"manual_block": {"manual_input": {"value": "manual_sess"}},
- "session_block": {
- "session_select": {
- "selected_option": {"value": "claude|sess_drop"}
- }
- },
+ "session_block": {"session_select": {"selected_option": {"value": "claude|sess_drop"}}},
}
},
- "private_metadata": (
- '{"channel_id":"C1","thread_id":"TH1","host_message_ts":"TS1"}'
- ),
+ "private_metadata": ('{"channel_id":"C1","thread_id":"TH1","host_message_ts":"TS1"}'),
},
}