Skip to content

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

feat(agents): create_room says whether the calling agent is in the room

raullopez-sandboxfbdf2a61afe6
diff --git a/console/packages/plugins/src/switch-skill/SKILL.md b/console/packages/plugins/src/switch-skill/SKILL.md
index 60cf7fa71..ec3483088 100644
--- a/console/packages/plugins/src/switch-skill/SKILL.md
+++ b/console/packages/plugins/src/switch-skill/SKILL.md
@@ -521,8 +521,9 @@ carrying a display name addresses no one.
(`"channel_public"`, `"channel_private"`, `"direct"`), `user_names`,
`instructions`, `group_name`, `aliases`, `reference_ids`, `package_ids`,
`linked_rooms`, `join_event_listeners` (the subset of `agent_names` that
- should receive `room_join` events — off by default). Returns
- `{id, name, transport_room_id, failed_attachments}`.
+ should receive `room_join` events — off by default). You are not a member
+ unless your own name is in `agent_names`. Returns
+ `{id, name, transport_room_id, caller_is_member, failed_attachments}`.
- **`update_room`** — change an existing room, including its `aliases` map.
- **`invite_agent_to_room`** — add an existing agent to an existing room by
name. Humans and agents can do the same from inside a room with the
diff --git a/core/switch_core/bridges/agent/operations/definitions.py b/core/switch_core/bridges/agent/operations/definitions.py
index 2bc9a6806..2a7b1cc02 100644
--- a/core/switch_core/bridges/agent/operations/definitions.py
+++ b/core/switch_core/bridges/agent/operations/definitions.py
@@ -917,8 +917,9 @@ async def create_room(
name: Display name for the room.
description: Free-text description shown to participants.
agent_names: Names of agents to add to the room at creation. The
- calling agent is not added automatically — include its name here
- if it should join. Names must already exist in the registry.
+ calling agent is not a member unless listed here — include your
+ own name if you should join (`caller_is_member` in the result
+ says whether you did). Names must already exist in the registry.
user_names: Optional list of people to add, each named by their
username on the room's messaging app, or by the e-mail address of
their account there (not on Discord, which never shares e-mail
@@ -977,7 +978,8 @@ async def create_room(
with an agent's real name, a room role, or another alias.
Returns:
- `{"id", "name", "matrix_room_id", "failed_attachments": [...]}`.
+ `{"id", "name", "matrix_room_id", "caller_is_member",
+ "failed_attachments": [...]}`.
`failed_attachments` is empty on full success; otherwise it lists
`{kind, id, error}` for each attachment that could not be applied
after the room was created (race-time failures only; predictable
@@ -1010,12 +1012,17 @@ async def create_room(
aliases=aliases,
from_room_id=await connected_room(),
)
+ async with protocol.session_factory() as session:
+ caller_is_member = agent_id in await protocol.room_store.get_agent_ids(
+ session, result.room.id
+ )
return {
"id": result.room.id,
"name": result.room.name,
"transport_room_id": result.room.transport_room_id,
# Deprecated alias, carried for the connector compatibility window.
"matrix_room_id": result.room.transport_room_id,
+ "caller_is_member": caller_is_member,
"failed_attachments": result.failed_attachments,
}
diff --git a/core/switch_core/official_templates/switch-buddy/AGENT.md b/core/switch_core/official_templates/switch-buddy/AGENT.md
index 67368ac35..6cbcd3f58 100644
--- a/core/switch_core/official_templates/switch-buddy/AGENT.md
+++ b/core/switch_core/official_templates/switch-buddy/AGENT.md
@@ -99,8 +99,9 @@ you can, once they say yes:
owner's agents, and any other agent that takes instructions from you.
When you create a room, put your own name in its `agent_names` along with the others:
`create_room` does not add you, and you can only change a room you are in (invite
- agents, add people, update or archive it) later. The one exception is a direct room,
- which holds exactly one agent.
+ agents, add people, update or archive it) later; `caller_is_member` in its result
+ says whether you are in. The one exception is a direct room, which holds exactly one
+ agent.
- **Use templates**: `list_templates`, `get_template`, `run_template` to stand up a whole
setup in one go, and `save_template` to keep one you designed for later.
- **Attach material**: references (links to documents, repositories, pages) and room