Skip to content

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

Redesign Guardrails settings as a disclosure row, rename Switch Trust's agent identity

Timo Bozsolik-Torresa1f14d120ed3
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/GuardrailsSection.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/GuardrailsSection.tsx
index 30d6b8b8f..ddbab7327 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/GuardrailsSection.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/GuardrailsSection.tsx
@@ -4,6 +4,7 @@ import { failureText } from '@renderer/lib/errors/describe-failure';
import { rpc } from '@renderer/lib/ipc';
import { Button } from '@renderer/lib/ui/button';
import { Checkbox } from '@renderer/lib/ui/checkbox';
+import { DisclosureRow } from '@renderer/lib/ui/disclosure-row';
import { Field, FieldGroup, FieldLabel } from '@renderer/lib/ui/field';
import { Input } from '@renderer/lib/ui/input';
import { cn } from '@renderer/utils/utils';
@@ -83,7 +84,6 @@ export const GuardrailsSection = observer(function GuardrailsSection({
if (result.kind === 'loaded') {
setSettings(result.settings);
setForm(formFor(result.settings));
- setOpen(result.settings.enabled);
} else {
setLoadError(recoverableResultText(result));
}
@@ -135,7 +135,6 @@ export const GuardrailsSection = observer(function GuardrailsSection({
try {
applyResult(await rpc.switchServers.clearTrustSettings(serverId));
setConfirmingOff(false);
- setOpen(false);
} catch (cause) {
setActionError(failureText(cause, 'Could not turn off Switch Trust.'));
} finally {
@@ -151,53 +150,24 @@ export const GuardrailsSection = observer(function GuardrailsSection({
{form && settings && (
<>
- <label className="group/field flex cursor-pointer items-start gap-2.5">
- <Checkbox
- checked={settings.enabled}
- onCheckedChange={() => {
- if (settings.enabled) {
- setConfirmingOff(true);
- } else {
- setOpen((v) => !v);
- }
- }}
- className="mt-0.5"
- />
- <span className="flex flex-col gap-0.5">
- <span className="text-sm font-medium text-foreground">
- Switch Trust Integration enabled
+ <DisclosureRow
+ open={open}
+ onToggle={() => setOpen((v) => !v)}
+ title="Switch Trust Integration"
+ meta={
+ <span className="flex items-center gap-1.5">
+ <Checkbox checked={settings.hasApiKey} disabled />
+ {settings.hasApiKey ? 'Monitoring Active' : 'Monitoring Inactive'}
</span>
- <span className="text-xs text-foreground-muted">
- {settings.enabled
- ? 'Every message this server sends is checked before it goes out.'
- : 'Set a Switch Trust endpoint and an API key to turn it on.'}
- </span>
- </span>
- </label>
+ }
+ />
<div className={cn('flex flex-col gap-3 pt-3', !open && 'hidden')}>
+ <p className="text-xs text-foreground-muted">
+ Every message this server sends is checked before it goes out once an endpoint and
+ an API key are set.
+ </p>
<FieldGroup>
- <Field>
- <FieldLabel>Switch Trust Endpoint</FieldLabel>
- <Input
- value={form.endpoint}
- onChange={(e) => setForm({ ...form, endpoint: e.target.value })}
- spellCheck={false}
- autoComplete="off"
- />
- </Field>
- <Field>
- <FieldLabel>
- Guardrails Policy ID
- <span className="ml-1 font-normal text-foreground-muted">(optional)</span>
- </FieldLabel>
- <Input
- value={form.policyId}
- onChange={(e) => setForm({ ...form, policyId: e.target.value })}
- spellCheck={false}
- autoComplete="off"
- />
- </Field>
<Field>
<FieldLabel>
Switch Trust API key
@@ -216,6 +186,24 @@ export const GuardrailsSection = observer(function GuardrailsSection({
onChange={(e) => setForm({ ...form, apiKey: e.target.value })}
/>
</Field>
+ <Field>
+ <FieldLabel>Guardrails Policy ID</FieldLabel>
+ <Input
+ value={form.policyId}
+ onChange={(e) => setForm({ ...form, policyId: e.target.value })}
+ spellCheck={false}
+ autoComplete="off"
+ />
+ </Field>
+ <Field>
+ <FieldLabel>Switch Trust Endpoint</FieldLabel>
+ <Input
+ value={form.endpoint}
+ onChange={(e) => setForm({ ...form, endpoint: e.target.value })}
+ spellCheck={false}
+ autoComplete="off"
+ />
+ </Field>
</FieldGroup>
{actionError && <p className="text-xs text-destructive">{actionError}</p>}
<div className="flex items-center gap-2">
@@ -226,6 +214,16 @@ export const GuardrailsSection = observer(function GuardrailsSection({
>
{saving ? 'Saving…' : 'Save'}
</Button>
+ {settings.hasApiKey && !confirmingOff && (
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={saving || clearing}
+ onClick={() => setConfirmingOff(true)}
+ >
+ Turn off
+ </Button>
+ )}
{confirmingOff && (
<>
<span className="text-xs text-foreground-muted">Turn off Switch Trust?</span>
diff --git a/core/switch_core/trust/client.py b/core/switch_core/trust/client.py
index 2cfc2dc27..aa9b6a76d 100644
--- a/core/switch_core/trust/client.py
+++ b/core/switch_core/trust/client.py
@@ -32,7 +32,7 @@ Role = Literal["user", "assistant"]
# traffic onto one Switch Trust agent rather than inventing a per-sender
# identity Switch Trust has no use for. `x-agent-session-id` (the room) and
# `x-agent-turn-id` (one per check) carry the per-call distinction instead.
-_AGENT_NAME = "Switch Rooms"
+_AGENT_NAME = "Switch Rooms Agents"
# The outcome a check settles on. "errored" covers both what the wire protocol
# calls GUARDRAIL_RESULT_OUTCOME_ERRORED (a detector itself failed, but the
diff --git a/core/tests/switch_core/trust/test_client.py b/core/tests/switch_core/trust/test_client.py
index fa3d52dd7..9cad8cab9 100644
--- a/core/tests/switch_core/trust/test_client.py
+++ b/core/tests/switch_core/trust/test_client.py
@@ -146,7 +146,7 @@ async def test_posts_the_one_message_with_the_expected_headers():
# Always the same constant agent identity (Switch has no single "agent" to
# attribute a check to); the room and a fresh per-check id carry the
# per-call distinction instead.
- assert seen["agent_name"] == "Switch Rooms"
+ assert seen["agent_name"] == "Switch Rooms Agents"
assert seen["session_id"] == "room-1"
assert uuid.UUID(str(seen["turn_id"])) # a fresh, well-formed UUID
assert seen["body"] == {"messages": [{"role": "user", "content": "hi"}]}
diff --git a/docs/design/switch-trust-guardrails-v1.md b/docs/design/switch-trust-guardrails-v1.md
index 7948e3dc3..01f435201 100644
--- a/docs/design/switch-trust-guardrails-v1.md
+++ b/docs/design/switch-trust-guardrails-v1.md
@@ -60,7 +60,7 @@ interception point further down the stack.
added in [hoot#2397](https://github.com/sandbox-quantum/hoot/pull/2397) —
with headers `x-guardrails-policy-id`, `x-flintai-api-key`, and three
always-set identity headers Switch Trust uses to group checks:
- - `x-agent-name`: a constant, `Switch Rooms` — Switch has no single agent
+ - `x-agent-name`: a constant, `Switch Rooms Agents` — Switch has no single agent
to attribute a check to (a room can hold several, and a human-authored
message has none at all), so every check is reported under one identity
rather than inventing a per-sender one Switch Trust has no use for.