Portal agent
Portal agent
The portal agent is a conversational interface for configuring your Writ tenant. It is docked in the right-side panel of the Overview page and acts as its own first-class principal (portal-agent).
What it can do
- Explain the product and your tenant’s current state in plain language: what a verb, policy, principal, grant, or receipt is; what the policy page means; and what recent receipts record. Explanations are read-only.
- Read the tenant policy, environment overrides, per-principal overrides, principals, API key metadata, recent receipts, and the audit-log chain verification.
- Update policy — tenant default, per-environment (
dev/staging/prod), and per-principal. - Create, update, and delete principals.
- Create, update, and delete custom verbs.
- Revert a policy change within one hour (“revert that”) — staged as a normal diff, approved the same way.
It cannot touch billing, other tenants, or API keys. It cannot disable its writ_check wrapping or touch the audit log.
Explaining policy and concepts
The agent can answer first-minute questions without staging a change:
- “What does this page mean?” reads the tenant policy and describes which verbs need a live grant, which pause for human approval, and that anything without a rule is denied by default.
- “What is a policy / principal / grant / receipt / verb?” answers from the product glossary baked into the agent’s system prompt.
- “How do we change the policy?” explains the shape of a request (verb, optional environment, target mode) and offers to draft the diff, without executing anything on the spot.
- “What do these mean?” after a receipt read explains that each receipt is a tamper-evident record of a Writ decision.
If a live read fails during an explanation, the agent falls back to the concept answer instead of the capability list.
How it works
Every mutating tool call the agent makes goes through POST /v1/check against the tenant’s own policy under agent.* verbs:
Destructive / irreversible actions (principal delete, key revoke, verb delete) always require step-up even if a tenant policy were somehow set to allow. Every prod environment policy change also forces step-up, widening or not.
Diff previews and approval
Nothing mutates on a bare chat message — not even when the tenant policy would allow the action. When the agent wants to write, it stages a pending action and returns a diff-preview card showing:
- The exact verb / environment / principal
- The current value (
before) - The proposed value (
after)
The user chooses Approve, Edit, or Cancel. Approving calls POST /v1/agent/actions/{actionId}/approve. If the verb requires step-up, the request must include a valid totpCode. An optional params object edits the staged diff — edited params are re-validated against the tool schema and the meta-policy, then re-checked before apply.
The approval endpoint re-runs the policy check (a flip to deny stops the write), enforces TOTP step-up with a one-time grant, verifies the fresh auth token immediately before the write, and only then executes the tool. A receipt with principal portal-agent and purpose = the user’s chat request is written to the audit log for every agent action.
Step-up codes: what you’re proving
When a diff card asks for your authenticator code, it is proving a human approved exactly this diff — the verb, the target, and the before/after values shown on the card. The code can’t be replayed, and a wrong code simply rejects the approval without touching anything. If the approve call answers 401 totp_code_required, check the totpEnrolled field: false means no authenticator is enrolled yet (enroll one first, then approve again); true means the code itself was wrong — open your authenticator app and try a fresh code.
Enrolling an authenticator
In the portal, open the Keys view and find the Security card:
- Click Enroll authenticator app and scan the QR code (or enter the secret manually).
- Enter the 6-digit code your app shows, then Confirm enrollment.
- Save the backup codes — each works once, in place of an authenticator code, if you lose your device. Use Copy or Download (
writ-backup-codes.txt); they are shown once and Writ stores only hashes.
Chat endpoint
Send a message:
Response when a diff is pending:
Approve with TOTP:
Approve with edits to the staged diff:
Streaming: send Accept: text/event-stream with POST /v1/agent/chat to receive the reply as SSE frames (event: message, then event: done).
Guardrails
- Tenant scope only — verified server-side on every tool call.
- No sponsor token — the agent rides the logged-in user’s session. It never holds, displays, or rotates the sponsor token.
- No full API keys in chat — key values are shown once at creation; the agent displays prefixes only.
- Prompt injection resistance — chat input is data, not instruction. The immutable server-side system prompt, the tool allowlist, and the policy engine are the backstops: a model-proposed plan naming an unknown tool is rejected outright.
- Rate caps — per-user / per-tenant tool-call ledger, 60 calls/hour by default, plus tenant-level and global kill switches.
- Disabled by default — for tenants where the agent is not enabled, the agent endpoints answer
403while every other route keeps working. (503only when the agent is disabled for the whole deploy or the kill switch is on.) - Meta-policy — the agent cannot edit
agent.*verbs, create or rename custom verbs into theagent.*namespace, delete/disable/rename itself, revoke its own keys, set per-principal policy on itself, disable its wrapping, or touch the audit log. Those controls are enforced in the tool layer, not in the prompt. - Model — the model runs server-side only; no model keys in the browser. When no model is configured, a deterministic parser handles core intents so the wrap stays testable without credentials.
Adversarial requests
Requests such as “disable the audit log”, “reveal the full API key”, or “allow * on prod” are detected and blocked with a DENY receipt written to the audit log.