Skip to content

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

e2e: cover the decision settings and room auto-route routes

agent-runner35399262630c2bd
diff --git a/console/tooling-e2e/src/clients/switch-client.ts b/console/tooling-e2e/src/clients/switch-client.ts
index 02d026f16..aeebe3d4f 100644
--- a/console/tooling-e2e/src/clients/switch-client.ts
+++ b/console/tooling-e2e/src/clients/switch-client.ts
@@ -709,6 +709,40 @@ export class SwitchClient {
return toRoomDetail(row);
}
+ // ── decision routing (auto-route) ────────────────────────────────────────
+
+ /** `GET /gateway/decision-settings`: the signed-in workspace's decision settings. */
+ async decisionSettings(): Promise<Record<string, unknown>> {
+ return this.gateway("GET", "/decision-settings");
+ }
+
+ /** `PUT /gateway/decision-settings`: save the workspace's decision backend. */
+ async saveDecisionSettings(
+ body: Record<string, unknown>,
+ ): Promise<Record<string, unknown>> {
+ return this.gateway("PUT", "/decision-settings", body);
+ }
+
+ /** `DELETE /gateway/decision-settings`: back to the server default. */
+ async resetDecisionSettings(): Promise<void> {
+ await this.gateway("DELETE", "/decision-settings");
+ }
+
+ /** `POST /gateway/decision-settings/test`: one sample decision, nothing saved. */
+ async testDecisionSettings(
+ body: Record<string, unknown>,
+ ): Promise<Record<string, unknown>> {
+ return this.gateway("POST", "/decision-settings/test", body);
+ }
+
+ /** `PUT /gateway/rooms/{room_id}/auto-route`: the room's auto-route switch. */
+ async setRoomAutoRoute(
+ roomId: string,
+ body: { on?: boolean; fallback_agent?: string | null },
+ ): Promise<Record<string, unknown>> {
+ return this.gateway("PUT", `/rooms/${roomId}/auto-route`, body);
+ }
+
async deleteRoom(roomId: string): Promise<void> {
await this.gateway("DELETE", `/rooms/${roomId}`);
}
diff --git a/console/tooling-e2e/src/fast/decision-settings.ts b/console/tooling-e2e/src/fast/decision-settings.ts
new file mode 100644
index 000000000..b6984e623
--- /dev/null
+++ b/console/tooling-e2e/src/fast/decision-settings.ts
@@ -0,0 +1,83 @@
+import { expect } from 'vitest';
+import { SwitchHttpError } from '../clients/switch-client.ts';
+import type { FastScenario } from './scenario.ts';
+
+/**
+ * A workspace's decision routing settings and a room's auto-route switch,
+ * through the gateway as the workspace's admin:
+ *
+ * 1. the settings read back with where they come from (the server default
+ * until the workspace chooses);
+ * 2. Test runs without saving anything and says why it can't decide when
+ * nothing is configured;
+ * 3. choosing "none" turns auto-route off for the workspace, so a room can't
+ * turn it on and says why;
+ * 4. resetting goes back to the server default.
+ *
+ * It changes the workspace's setting while it runs, so it stays off shared
+ * environments.
+ */
+export const decisionSettings: FastScenario = {
+ header: {
+ id: 'decision-settings',
+ covers: [
+ 'GET /gateway/decision-settings',
+ 'PUT /gateway/decision-settings',
+ 'DELETE /gateway/decision-settings',
+ 'POST /gateway/decision-settings/test',
+ 'PUT /gateway/rooms/{room_id}/auto-route',
+ ],
+ lane: 'fast',
+ environments: ['ephemeral', 'local'],
+ owner: 'platform',
+ requires: [],
+ },
+ async run({ fixtures, switchClient, log }) {
+ const before = await switchClient.decisionSettings();
+ if (before.source === 'workspace') {
+ throw new Error(
+ 'The workspace already has its own decision setting; this scenario ' +
+ 'would overwrite it. Run it against a server whose workspace uses ' +
+ 'the server default.'
+ );
+ }
+ expect(before.workspace).toBeNull();
+ log(`decision settings start on the server default: ${JSON.stringify(before.server_default)}`);
+
+ try {
+ // ── Test with nothing saved ───────────────────────────────────────────
+ const tested = await switchClient.testDecisionSettings({ backend: 'default' });
+ if (!(before.server_default as { configured: boolean }).configured) {
+ expect(tested.ok).toBe(false);
+ expect((tested.error as { code: string }).code).toBe('not_configured');
+ }
+ expect((await switchClient.decisionSettings()).source).toBe('server_default');
+
+ // ── "none" turns auto-route off for the workspace ──────────────────────
+ const saved = await switchClient.saveDecisionSettings({ backend: 'none' });
+ expect(saved.source).toBe('workspace');
+ const effective = saved.effective as { backend: string; available: boolean };
+ expect(effective.backend).toBe('none');
+ expect(effective.available).toBe(false);
+
+ const agent = await fixtures.agent('dr');
+ const room = await fixtures.internalRoom('dr', [agent]);
+ const off = await switchClient.setRoomAutoRoute(room.id, { on: false });
+ expect(off.on).toBe(false);
+ expect(off.available).toBe(false);
+ const refused = await switchClient.setRoomAutoRoute(room.id, { on: true }).then(
+ () => null,
+ (error: unknown) => error
+ );
+ expect(refused).toBeInstanceOf(SwitchHttpError);
+ expect((refused as SwitchHttpError).status).toBe(409);
+ log("auto-route can't be turned on in a workspace that chose none");
+ } finally {
+ // ── back to the server default ────────────────────────────────────────
+ await switchClient.resetDecisionSettings();
+ }
+ const after = await switchClient.decisionSettings();
+ expect(after.source).toBe('server_default');
+ expect(after.workspace).toBeNull();
+ },
+};
diff --git a/console/tooling-e2e/src/fast/index.ts b/console/tooling-e2e/src/fast/index.ts
index 1cc5f88d2..98b2cbeff 100644
--- a/console/tooling-e2e/src/fast/index.ts
+++ b/console/tooling-e2e/src/fast/index.ts
@@ -3,6 +3,7 @@ import { agentIdentity } from "./agent-identity.ts";
import { attachmentNames } from "./attachments.ts";
import { clientMistakes } from "./client-mistakes.ts";
import { endSessions, memberErasure, retentionWindow } from "./data-protection.ts";
+import { decisionSettings } from "./decision-settings.ts";
import { followUps } from "./follow-ups.ts";
import { addressedDelivery, unaddressedHistory } from "./agent-messaging.ts";
import { mattermostRoundtrip } from "./mattermost-roundtrip.ts";
@@ -31,4 +32,5 @@ export const FAST_SCENARIOS: readonly FastScenario[] = [
retentionWindow,
memberErasure,
endSessions,
+ decisionSettings,
];