Skip to content

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

fix: make a chat reset fresh and show room controls as system lines

raullopez-sandbox0f567f684a6d
diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/stop-rows.ts b/console/apps/switch-console-desktop/src/renderer/features/chats/stop-rows.ts
index 93cfd31b2..46b6fb56d 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/chats/stop-rows.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/stop-rows.ts
@@ -1,10 +1,11 @@
import type { ChatMessage } from '@shared/core/chats/chats';
/**
- * A Stop is posted as `!interrupt @agent` and the agent acknowledges it in a
- * thread rooted at the command. The turn's own "Stopped" row already says it
- * stopped, so the command and that acknowledgement are not shown. Any other
- * answer (it could not be stopped) is shown with its command.
+ * A Stop is posted as `!interrupt @agent`, shown as a system line ("Stop
+ * requested for …"), and the agent acknowledges it in a thread rooted at it.
+ * The turn's own "Stopped" row already says it stopped, so the command and
+ * that acknowledgement are not shown. Any other answer (it could not be
+ * stopped) is shown with its command.
*/
/** The agent's in-room answer to an interrupt it carried out (core's `_INTERRUPT.ack`). */
@@ -18,22 +19,23 @@ export function isInterruptAck(message: Pick<ChatMessage, 'body' | 'sender'>): b
/**
* The agent's in-room answer to a Retry it passed on (core's `_RETRY.ack`). A
- * Retry is posted as `!retry @agent <message id>`; the turn it runs again shows
- * under the message, so the command and this answer are left out too.
+ * Retry is posted as `!retry @agent <message id>` ("Retry requested for …");
+ * the turn it runs again shows under the message, so the command and this
+ * answer are left out too.
*/
export const RETRY_ACK_MESSAGE = 'Trying that message again.';
/** Each command left out with its acknowledgement, and that acknowledgement. */
const HIDDEN_COMMANDS: [RegExp, string][] = [
- [/^!interrupt(\s|$)/, INTERRUPT_ACK_MESSAGE],
- [/^!retry(\s|$)/, RETRY_ACK_MESSAGE],
+ [/^Stop requested for /, INTERRUPT_ACK_MESSAGE],
+ [/^Retry requested for /, RETRY_ACK_MESSAGE],
];
/** Ids of the Stop and Retry commands and their acknowledgements to leave out of the transcript. */
export function hiddenStopRows(messages: readonly Row[]): Set<string> {
const hidden = new Set<string>();
for (const command of messages) {
- if (command.sender.kind !== 'human') continue;
+ if (command.sender.kind !== 'system') continue;
const ack = HIDDEN_COMMANDS.find(([pattern]) => pattern.test(command.body.trim()))?.[1];
if (ack === undefined) continue;
const answers = messages.filter(
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chat-activity.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chat-activity.test.ts
index 142898c3c..3418ddb9c 100644
--- a/console/apps/switch-console-desktop/src/renderer/tests/chat-activity.test.ts
+++ b/console/apps/switch-console-desktop/src/renderer/tests/chat-activity.test.ts
@@ -250,7 +250,12 @@ describe('placeTurns', () => {
body: 'I finished without replying. The turn failed: model',
sentAt: at(2),
},
- { ...said('retry', null), body: '!retry @helper q1', sentAt: at(3) },
+ {
+ ...said('retry', null),
+ body: 'Retry requested for helper by me',
+ sender: { kind: 'system', agentId: null, clientId: 'me' },
+ sentAt: at(3),
+ },
{
...said('ack', 'helper'),
body: 'Trying that message again.',
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chat-stop-rows.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chat-stop-rows.test.ts
index 773695355..dee4b386a 100644
--- a/console/apps/switch-console-desktop/src/renderer/tests/chat-stop-rows.test.ts
+++ b/console/apps/switch-console-desktop/src/renderer/tests/chat-stop-rows.test.ts
@@ -4,6 +4,7 @@ import type { ChatMessage } from '@shared/core/chats/chats';
const human = { kind: 'human' } as ChatMessage['sender'];
const agent = { kind: 'agent' } as ChatMessage['sender'];
+const system = { kind: 'system' } as ChatMessage['sender'];
const row = (
messageId: string,
body: string,
@@ -20,7 +21,7 @@ describe('hiddenStopRows', () => {
it('hides a Stop command and its acknowledgement', () => {
const messages = [
row('$ask', 'fix the build'),
- row('$stop', '!interrupt @coder'),
+ row('$stop', 'Stop requested for coder by ana', system),
row('$ack', 'Interrupted my current turn. ([Open in Switch Console](x))', agent, '$stop'),
row('$next', 'try again'),
];
@@ -28,12 +29,14 @@ describe('hiddenStopRows', () => {
});
it('hides a Stop still waiting for its answer', () => {
- expect(hiddenStopRows([row('$stop', '!interrupt @coder')])).toEqual(new Set(['$stop']));
+ expect(hiddenStopRows([row('$stop', 'Stop requested for coder by ana', system)])).toEqual(
+ new Set(['$stop'])
+ );
});
it('shows a Stop the agent could not carry out, with its answer', () => {
const messages = [
- row('$stop', '!interrupt @coder'),
+ row('$stop', 'Stop requested for coder by ana', system),
row('$no', "I can't be interrupted — this isn't supported for me.", agent, '$stop'),
];
expect(hiddenStopRows(messages).size).toBe(0);
@@ -41,9 +44,10 @@ describe('hiddenStopRows', () => {
it('leaves other commands and messages alone', () => {
const messages = [
- row('$reset', '!reset @coder'),
+ row('$reset', 'Context reset requested for coder by ana', system),
row('$ack', 'Resetting my session.', agent, '$reset'),
row('$talk', '!interrupting cow'),
+ row('$typed', 'Stop requested for coder'),
row('$quote', 'Interrupted my current turn.'),
];
expect(hiddenStopRows(messages).size).toBe(0);
@@ -51,7 +55,7 @@ describe('hiddenStopRows', () => {
it('hides a Retry and its acknowledgement: the turn it runs again shows under the message', () => {
const messages = [
row('$ask', 'plan a picnic'),
- row('$retry', '!retry @coder $ask'),
+ row('$retry', 'Retry requested for coder by ana', system),
row('$ack', 'Trying that message again.', agent, '$retry'),
];
expect(hiddenStopRows(messages)).toEqual(new Set(['$retry', '$ack']));
@@ -59,7 +63,7 @@ describe('hiddenStopRows', () => {
it('shows a Retry the agent could not carry out, with its answer', () => {
const messages = [
- row('$retry', '!retry @coder $ask'),
+ row('$retry', 'Retry requested for coder by ana', system),
row(
'$no',
"I couldn't try that again: my current session never worked on that message.",
diff --git a/console/packages/agent-providers/src/host/agent-host.test.ts b/console/packages/agent-providers/src/host/agent-host.test.ts
index ac6a4079e..e69e3e8ce 100644
--- a/console/packages/agent-providers/src/host/agent-host.test.ts
+++ b/console/packages/agent-providers/src/host/agent-host.test.ts
@@ -1923,7 +1923,7 @@ it('restarts a session’s host before handing it a reset, when its agent’s se
}
expect(order.slice(0, 2)).toEqual([`restart ${granted.sessionRoot} true`, 'command']);
expect(hosts.to(unchanged.sessionRoot)).toEqual([
- { type: 'command', command: reset(unchanged.sessionId), requesterName: null },
+ { type: 'command', command: reset(unchanged.sessionId), requesterName: null, direct: false },
]);
expect(vi.mocked(ensureSharedProcess).mock.calls.map(([input]) => input.root)).toEqual([
granted.sessionRoot,
@@ -2085,7 +2085,7 @@ it('hands a relayed command to the session it names, and only if it runs here',
// This agent's, but with nothing running it: dropped and said, not started.
await streams[0]!.onSessionCommand!(command(idle.sessionId));
expect(hosts.to(own.sessionRoot)).toEqual([
- { type: 'command', command: command(own.sessionId), requesterName: null },
+ { type: 'command', command: command(own.sessionId), requesterName: null, direct: false },
]);
expect(hosts.to(other.sessionRoot)).toEqual([]);
expect(hosts.to(idle.sessionRoot)).toEqual([]);
@@ -2136,7 +2136,7 @@ it('starts the host of a session a failure took down, to hand it a retry', async
faulted.sessionRoot,
]);
expect(hosts.to(faulted.sessionRoot)).toEqual([
- { type: 'command', command: retry, requesterName: null },
+ { type: 'command', command: retry, requesterName: null, direct: false },
]);
} finally {
abort.abort();
@@ -2283,13 +2283,19 @@ it('hands a room control to the session working in its room, when Switch names o
);
try {
await eventually(() => streams.length === 1);
- await streams[0]!.onSessionCommand!({ sessionId: null, roomId: 'room-a', commandId: 'c1' });
+ await streams[0]!.onSessionCommand!({
+ sessionId: null,
+ roomId: 'room-a',
+ commandId: 'c1',
+ direct: true,
+ });
await streams[0]!.onSessionCommand!({ sessionId: null, roomId: 'room-z', commandId: 'c2' });
expect(hosts.to(placed.sessionRoot)).toEqual([
{
type: 'command',
command: { sessionId: placed.sessionId, commandId: 'c1' },
requesterName: null,
+ direct: true,
},
]);
expect(
diff --git a/console/packages/agent-providers/src/host/agent-host.ts b/console/packages/agent-providers/src/host/agent-host.ts
index 8bc238474..6163d6bbf 100644
--- a/console/packages/agent-providers/src/host/agent-host.ts
+++ b/console/packages/agent-providers/src/host/agent-host.ts
@@ -1339,7 +1339,7 @@ export async function runAgentHost(
// A room control (!reset, !interrupt) typed in one of the agent's rooms,
// which only Switch sees. Handed to the session's host like any other.
onSessionCommand: async (relayed) => {
- const { requesterName, roomId, ...rest } = relayed;
+ const { requesterName, direct, roomId, ...rest } = relayed;
const sessionId =
rest.sessionId ?? (typeof roomId === 'string' ? placements.sessionIn(roomId) : null);
if (!sessionId) {
@@ -1376,6 +1376,7 @@ export async function runAgentHost(
type: 'command',
command,
requesterName: typeof requesterName === 'string' ? requesterName : null,
+ direct: direct === true,
},
`command ${command.commandId}`,
restarted || relaunched ? HOST_START_MS : 0
diff --git a/console/packages/agent-providers/src/host/room-control-followup.ts b/console/packages/agent-providers/src/host/room-control-followup.ts
index 5a6b87d0f..3a74ba6ae 100644
--- a/console/packages/agent-providers/src/host/room-control-followup.ts
+++ b/console/packages/agent-providers/src/host/room-control-followup.ts
@@ -13,13 +13,14 @@ export function roomControlFollowup(input: {
}): string {
const done = input.action === 'reset' ? 'has been reset' : 'has been compacted';
const thread = input.threadId ? ` in thread ${JSON.stringify(input.threadId)}` : '';
+ const mention = input.requesterName
+ ? ` (mention ${JSON.stringify(input.requesterName)} only if list_participants lists them)`
+ : '';
return [
`The requested ${input.action} completed successfully.`,
`Connect to Switch room ${JSON.stringify(input.roomId)} (reuse its connection if already connected) and read_context before responding.`,
- `If you held a role in that room before the ${input.action}, re-assume it and follow its instructions; if it is unavailable, report that clearly instead of claiming it was restored.`,
- input.requesterName
- ? `Then send a short targeted message to ${JSON.stringify(input.requesterName)}${thread} saying your session ${done} and whether you are ready to continue.`
- : `Then send a short message in the room${thread} saying your session ${done} and whether you are ready to continue.`,
+ `If you held a role in that room before the ${input.action}, re-assume it and follow its instructions; if it is unavailable, report that clearly instead of claiming it was restored. If you held no role, say nothing about roles.`,
+ `Then post_message a short note in the room${thread}${mention} saying your session ${done} and whether you are ready to continue. Do not use send_targeted_message for it.`,
].join(' ');
}
diff --git a/console/packages/agent-providers/src/host/session-channel.ts b/console/packages/agent-providers/src/host/session-channel.ts
index 9cbb1c498..68d4677ea 100644
--- a/console/packages/agent-providers/src/host/session-channel.ts
+++ b/console/packages/agent-providers/src/host/session-channel.ts
@@ -48,6 +48,8 @@ export const sessionRequestSchema = z.discriminatedUnion('type', [
command: z.unknown(),
/** Who asked, as the room names them; null for a command from Console. */
requesterName: z.string().nullable(),
+ /** The command came from a direct chat; absent from a parent older than the field. */
+ direct: z.boolean().optional(),
}),
/** A room message the agent was addressed with, as the controller routed it. */
z.object({
diff --git a/console/packages/agent-providers/src/host/shared-host.test.ts b/console/packages/agent-providers/src/host/shared-host.test.ts
index 3b562f384..4518f146a 100644
--- a/console/packages/agent-providers/src/host/shared-host.test.ts
+++ b/console/packages/agent-providers/src/host/shared-host.test.ts
@@ -1031,7 +1031,11 @@ it('tells the session to rejoin its room once a reset asked for there has applie
expect(host.turns[0]!.text).toContain('The requested reset completed successfully.');
expect(host.turns[0]!.text).toContain('Connect to Switch room "room"');
expect(host.turns[0]!.text).toContain('in thread "thread"');
- expect(host.turns[0]!.text).toContain('targeted message to "louisa"');
+ expect(host.turns[0]!.text).toContain(
+ 'post_message a short note in the room in thread "thread"'
+ );
+ expect(host.turns[0]!.text).toContain('mention "louisa" only if list_participants lists them');
+ expect(host.turns[0]!.text).toContain('Do not use send_targeted_message');
expect(host.turns[0]!.text).toContain('your session has been reset');
// Asked again (a relay retried), the follow-up is not sent twice.
await host.parent.ask({ type: 'command', command: reset, requesterName: 'louisa' });
@@ -1042,6 +1046,36 @@ it('tells the session to rejoin its room once a reset asked for there has applie
}
}, 20000);
+it('owes no follow-up for a reset asked for in a direct chat', async () => {
+ const host = await start({ resettable: true });
+ try {
+ const reset: Command = {
+ ...relayed('current', 'room-reset', { type: 'session.reset' }),
+ origin: {
+ actorId: '@person:test',
+ surface: 'console',
+ roomId: 'room',
+ threadId: 'thread',
+ messageId: 'message-9',
+ },
+ };
+ const answer = await host.parent.ask({
+ type: 'command',
+ command: reset,
+ requesterName: 'louisa',
+ direct: true,
+ });
+ expect(answer).toMatchObject({
+ ok: true,
+ value: { commandId: 'room-reset', status: 'applied' },
+ });
+ await new Promise((resolve) => setTimeout(resolve, 300));
+ expect(host.turns).toHaveLength(0);
+ } finally {
+ expect(await host.stop()).toBeNull();
+ }
+}, 20000);
+
it('tells the room at once when it refuses a compaction asked for there mid-turn', async () => {
const host = await start({ rooms: true });
const asks = () =>
diff --git a/console/packages/agent-providers/src/host/shared-host.ts b/console/packages/agent-providers/src/host/shared-host.ts
index b89aa431f..bd7254e95 100644
--- a/console/packages/agent-providers/src/host/shared-host.ts
+++ b/console/packages/agent-providers/src/host/shared-host.ts
@@ -582,7 +582,13 @@ export async function runSharedHost(
type Followup = Extract<(typeof state.journal.records)[number], { type: 'followup' }>;
const followups = (): Followup[] =>
state.journal.records.filter((record): record is Followup => record.type === 'followup');
- const followupFor = (command: Command, requesterName: string | null): Followup | null => {
+ const followupFor = (
+ command: Command,
+ requesterName: string | null,
+ direct: boolean
+ ): Followup | null => {
+ // A direct chat's reset is meant to forget the conversation; its placement survives, so nothing is owed.
+ if (direct) return null;
const action =
command.body.type === 'session.reset'
? 'reset'
@@ -626,7 +632,8 @@ export async function runSharedHost(
delivery: 'queue',
},
},
- null
+ null,
+ false
);
};
/** Tells the parent whenever the session's busy state changes. */
@@ -725,7 +732,8 @@ export async function runSharedHost(
/** Runs a command, answering with what the host recorded for it, or why it did not run. */
const run = async (
value: unknown,
- requesterName: string | null
+ requesterName: string | null,
+ direct: boolean
): Promise<CommandStatus | string> => {
executionSignal.throwIfAborted();
active();
@@ -744,7 +752,7 @@ export async function runSharedHost(
// about a conversation a reset or a restart has since replaced.
if (command.epoch !== host!.snapshot().session.epoch)
return 'STALE_EPOCH: the session has been reset or restarted since this command was made.';
- const owed = followupFor(command, requesterName);
+ const owed = followupFor(command, requesterName, direct);
if (owed && !followups().some((record) => record.commandId === command.commandId))
await state.journal.append(owed);
const repeated = host!
@@ -852,7 +860,7 @@ export async function runSharedHost(
// Taken by the host before the delivery is acknowledged: the host's
// inbox is durable, so a crash between the two runs the message once
// rather than losing it.
- const outcome = await run(command, null);
+ const outcome = await run(command, null, false);
if (typeof outcome !== 'string' && outcome.status !== 'rejected') {
if (instructionsNote !== null) await instructionsTold();
if (room.instructions !== null)
@@ -886,7 +894,8 @@ export async function runSharedHost(
},
body: { type: 'session.reset' },
},
- null
+ null,
+ false
);
if (typeof outcome === 'string')
throw new Error(`Could not start a fresh conversation for a room message: ${outcome}`);
@@ -903,8 +912,8 @@ export async function runSharedHost(
parent?.serve({
// Busy is announced before the reply, so a parent that has the reply has
// already heard any change the command made.
- command: async ({ command, requesterName }) => {
- const outcome = await run(command, requesterName);
+ command: async ({ command, requesterName, direct }) => {
+ const outcome = await run(command, requesterName, direct === true);
announceBusy();
if (typeof outcome === 'string') throw new Error(outcome);
return outcome;
diff --git a/console/packages/plugins/src/switch-skill/SKILL.md b/console/packages/plugins/src/switch-skill/SKILL.md
index fe036e8a0..131a11432 100644
--- a/console/packages/plugins/src/switch-skill/SKILL.md
+++ b/console/packages/plugins/src/switch-skill/SKILL.md
@@ -1104,9 +1104,11 @@ is your owner and your owner's own agents. An acknowledgement reports command st
check the session transcript for the result. Unsupported controls fail explicitly.
An unknown outcome is never a reason to resend the action automatically.
After a confirmed reset or compaction, Switch queues a follow-up to reconnect,
-read context, re-assume the previous role if one was held, and confirm the result
-to the requester in the original thread. If the role cannot be restored, report
-that limitation. Failed or unknown controls do not queue a success announcement.
+read context, re-assume the previous role if one was held, and post a short
+confirmation in the original thread with `post_message`. If the role cannot be
+restored, report that limitation. In a direct chat nothing is queued: a reset
+there is meant to start the conversation fresh, so do not read back its history.
+Failed or unknown controls do not queue a success announcement.
## Tool index
diff --git a/core/switch_core/bridges/agent/commands.py b/core/switch_core/bridges/agent/commands.py
index d3e5147e0..cc06d7113 100644
--- a/core/switch_core/bridges/agent/commands.py
+++ b/core/switch_core/bridges/agent/commands.py
@@ -295,12 +295,15 @@ def room_control_frame(
thread_id: str | None,
surface: str,
requester_name: str,
+ direct: bool,
target_message_id: str | None,
) -> dict[str, object]:
"""The `session_command` frame a room control is relayed as.
Beside the contract command it names who asked, as the room knows them,
- so the session can answer that person once the control has applied.
+ so the session can answer that person once the control has applied, and
+ whether the room is a direct chat, where a reset is meant to leave the
+ session with none of the conversation.
`session_id` is None for a controller-backed agent, whose controller
picks the session from the room. `target_message_id` is the message a
`retry` runs again, and None for every other control.
@@ -332,6 +335,7 @@ def room_control_frame(
body=body,
)
frame["requesterName"] = requester_name
+ frame["direct"] = direct
return frame
@@ -601,6 +605,7 @@ async def _decide_control_command(
thread_id=event.thread_id,
surface=await _room_surface(client, meta.room_id),
requester_name=event.user_name,
+ direct=meta.channel_type == "direct",
target_message_id=target,
)
diff --git a/core/switch_core/chats/views.py b/core/switch_core/chats/views.py
index eafde4729..44068c7ac 100644
--- a/core/switch_core/chats/views.py
+++ b/core/switch_core/chats/views.py
@@ -38,7 +38,7 @@ from switch_core.delivery.addressing import (
MESSAGE_EVENT_TYPE = "m.room.message"
COMMAND_EVENT_TYPE = "com.switch.command"
-# A room command (`!reset @agent`) is shown so its threaded acknowledgement has a visible root.
+# A room command (`!reset @agent`) is shown, as a system line, so its threaded acknowledgement has a visible root.
SHOWN_EVENT_TYPES = (MESSAGE_EVENT_TYPE, COMMAND_EVENT_TYPE)
PREVIEW_CHARS = 140
@@ -336,12 +336,25 @@ async def chat_summaries(
return summaries
+_COMMAND_LINES = {
+ "reset": "Context reset requested for {agent}",
+ "compact": "Compaction requested for {agent}",
+ "interrupt": "Stop requested for {agent}",
+ "retry": "Retry requested for {agent}",
+}
+
+
def _command_text(message: Message) -> str:
if message.event_type != COMMAND_EVENT_TYPE:
return ""
command = message.content.get("command")
args = message.content.get("args")
- return f"!{command} {args}".strip() if args else f"!{command}"
+ target = args.split()[0] if isinstance(args, str) and args.split() else ""
+ line = _COMMAND_LINES.get(command) if isinstance(command, str) else None
+ if line is None or not target.startswith("@"):
+ return f"!{command} {args}".strip() if args else f"!{command}"
+ text = line.format(agent=target[1:])
+ return f"{text} by {message.sender_name}" if message.sender_name else text
async def chat_messages(
@@ -394,7 +407,9 @@ async def chat_messages(
for message in shown:
client = clients.get(message.sender_client_id or "")
agent = agents.get(message.sender_client_id or "")
- if agent is not None:
+ if message.event_type == COMMAND_EVENT_TYPE:
+ kind, source = "system", "switch"
+ elif agent is not None:
kind, source = "agent", "switch"
elif client is not None and client.type == MEMBER_CLIENT_TYPE:
kind, source = "human", "console"
diff --git a/core/tests/switch_core/bridges/agent/test_control_commands.py b/core/tests/switch_core/bridges/agent/test_control_commands.py
index eb1f698c3..c0320d54d 100644
--- a/core/tests/switch_core/bridges/agent/test_control_commands.py
+++ b/core/tests/switch_core/bridges/agent/test_control_commands.py
@@ -46,6 +46,7 @@ def _client(
enqueue: list[Any],
placed: str | None = None,
relayed: list[Any] | None = None,
+ channel_type: str = "channel_private",
) -> SimpleNamespace:
"""Minimal AgentRecipient stand-in for _dispatch_control_command."""
@@ -73,7 +74,7 @@ def _client(
room_id="room-1",
name="Room",
bridge_id="b1",
- channel_type="channel_private",
+ channel_type=channel_type,
)
@asynccontextmanager
@@ -342,9 +343,40 @@ async def test_a_session_in_the_room_is_sent_the_command_through_its_controller(
"messageId": "$reset-command",
}
assert frame["requesterName"] == "louisa"
+ assert frame["direct"] is False
assert reply.bodies[-1].startswith("Resetting my session")
+async def test_a_control_in_a_direct_chat_is_relayed_as_direct(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ relayed: list[Any] = []
+ monkeypatch.setattr(commands, "_reply", _Reply())
+
+ async def _surface(*_a: Any) -> str:
+ return "console"
+
+ monkeypatch.setattr(commands, "_room_surface", _surface)
+
+ await _cmd_reset(
+ _client(
+ _Reply(),
+ command_level="session_dependent",
+ enqueue=[],
+ placed="session-1",
+ relayed=relayed,
+ channel_type="direct",
+ ),
+ SimpleNamespace(room_id="!m:server"),
+ _event(),
+ False,
+ )
+
+ [frame] = relayed
+ assert frame["direct"] is True
+
+
@pytest.mark.asyncio
async def test_a_session_with_no_controller_connected_is_told_so(
monkeypatch: pytest.MonkeyPatch,
@@ -426,6 +458,7 @@ def test_an_interrupt_names_the_current_turn() -> None:
thread_id=None,
surface="slack",
requester_name="louisa",
+ direct=False,
target_message_id=None,
)
assert frame["body"] == {"type": "turn.interrupt", "turnId": "current"}
@@ -445,6 +478,7 @@ def test_a_retry_runs_again_the_message_it_names() -> None:
thread_id=None,
surface="switch-web",
requester_name="louisa",
+ direct=False,
target_message_id="$m1",
)
assert frame["body"] == {"type": "message.retry", "messageId": "$m1"}
@@ -459,6 +493,7 @@ def test_a_retry_runs_again_the_message_it_names() -> None:
thread_id=None,
surface="switch-web",
requester_name="louisa",
+ direct=False,
target_message_id=None,
)
diff --git a/core/tests/switch_core/fixtures/agent_controllers/stream_frames.json b/core/tests/switch_core/fixtures/agent_controllers/stream_frames.json
index cb364fd69..752003f67 100644
--- a/core/tests/switch_core/fixtures/agent_controllers/stream_frames.json
+++ b/core/tests/switch_core/fixtures/agent_controllers/stream_frames.json
@@ -89,7 +89,8 @@
"body": {
"type": "session.reset"
},
- "requesterName": "Ada"
+ "requesterName": "Ada",
+ "direct": false
}
}
},
diff --git a/core/tests/switch_core/gateway/test_chats_controls.py b/core/tests/switch_core/gateway/test_chats_controls.py
index fdf1a6721..5332d481d 100644
--- a/core/tests/switch_core/gateway/test_chats_controls.py
+++ b/core/tests/switch_core/gateway/test_chats_controls.py
@@ -130,11 +130,14 @@ async def test_a_posted_control_is_shown_in_the_chat(chats: _Harness) -> None:
)
assert page.status_code == 200, page.text
[shown] = [m for m in page.json()["messages"] if m["messageId"] == command_id]
- assert shown["body"] == "!reset @helper"
+ assert shown["body"] == "Context reset requested for helper by alice"
+ assert shown["sender"]["kind"] == "system"
listed = await chats.client.get("/chats", headers=chats.as_user(chats.alice))
[chat] = [c for c in listed.json()["chats"] if c["roomId"] == room_id]
- assert chat["lastMessage"]["preview"] == "!reset @helper"
+ assert (
+ chat["lastMessage"]["preview"] == "Context reset requested for helper by alice"
+ )
async def test_stop_refuses_unless_the_agents_current_turn_is_in_this_chat(
diff --git a/core/tests/switch_core/management/test_contract_fixtures.py b/core/tests/switch_core/management/test_contract_fixtures.py
index db854fb32..f32b06b39 100644
--- a/core/tests/switch_core/management/test_contract_fixtures.py
+++ b/core/tests/switch_core/management/test_contract_fixtures.py
@@ -422,6 +422,7 @@ class TestStreamFrames:
thread_id=None,
surface="slack",
requester_name="Ada",
+ direct=False,
target_message_id=None,
),
)
diff --git a/core/tests/switch_core/management/test_stream.py b/core/tests/switch_core/management/test_stream.py
index ebab7b055..abd8a2a78 100644
--- a/core/tests/switch_core/management/test_stream.py
+++ b/core/tests/switch_core/management/test_stream.py
@@ -407,6 +407,7 @@ class TestLiveChanges:
thread_id=None,
surface="slack",
requester_name="Ada",
+ direct=False,
target_message_id=None,
)
assert harness.protocol.connections.relay_session_command(agent_id, command)