Add support-agent example: mock customer-support agent

Demonstrates two harness surfaces the previous examples skipped:

- SkillProvider: KB articles in examples/support-agent/kb/ are exposed
  via runtime.SkillProvider. The runtime auto-registers load_skill and
  inlines a compact article index into the static (cacheable) system
  prompt; full bodies load on demand.

- PermissionChecker: tickets_update and escalate_to_human are gated on
  a 'supervisor' flag. FilterToolDefs hides the gated tools from the
  LLM tool list in non-supervisor mode so it doesn't waste turns
  inventing calls that would just be denied.

Five concrete tools (kb_search, tickets_get, tickets_create,
tickets_update, escalate_to_human) plus the auto-registered load_skill.
Five seed KB articles cover refund policy, escalation matrix, account
recovery, password reset, and API rate limits — chosen to exercise the
common support patterns each tool involves.

In-memory ticket store (examples/support-agent/store.go) seeded with
four tickets in different states. Webhook delivery for escalations is
optional via SUPPORT_AGENT_WEBHOOK; when unset the tool prints the
escalation banner to stdout, so the demo runs with only
ANTHROPIC_API_KEY set.

Tests (support_test.go) cover store CRUD, defensive copying, the
permission checker's read/write split, and KB indexing/search — all
offline, no API needed.
This commit is contained in:
sausheong committed 2026-05-08 00:10:49 +08:00
1 parent 152f653dd7
commit 8ed38d7b66
12 files changed
+1368 -2

No files matched your search

@@ -0,0 +1,40 @@
# Account Recovery
When a customer reports they've lost access or their account was
compromised, follow this script. Do **not** improvise: every step here
exists because of a past incident.
## Step 1 — Triage in one question
Ask: "Are you locked out of your account, or are you still logged in
but seeing activity you don't recognise?"
- **Locked out** → password-reset flow (see `password-reset` article).
- **Unfamiliar activity** → suspected compromise (continue below).
## Step 2 — Suspected compromise
1. **Do not ask for the password**, ever.
2. Tell the customer to immediately:
- Sign out of every active session from Settings → Security → Sign
out everywhere.
- Rotate their password via the standard reset flow.
- Rotate any API keys via Dashboard → API → Keys → Rotate.
- Enable 2FA if not already on.
3. File a ticket with subject `Possible account compromise` and
priority `urgent`.
4. Add an internal note listing what the customer reported (IPs,
timestamps, what they noticed).
5. **Escalate to Security** via `escalate_to_human` — do not attempt
to investigate access logs yourself.
## Step 3 — What we tell them
> "I've filed an urgent ticket and our security team will reach out
> within 30 minutes. While you wait, please rotate your credentials
> using the steps above. If you see any further suspicious activity,
> reply to this thread with timestamps and we'll add them to the
> investigation."
Never confirm or deny what the security team will find — that's their
call to make.
@@ -0,0 +1,46 @@
# API Rate Limits
Default limits for Acme API clients. When a customer reports 429s or
unexpected throttling, check their plan tier first via the dashboard
before escalating.
## Default limits per plan
| Plan | Requests / minute | Requests / day | Concurrent streams |
|------------|-------------------|----------------|--------------------|
| Free | 20 | 1,000 | 1 |
| Starter | 120 | 50,000 | 5 |
| Growth | 600 | 500,000 | 25 |
| Enterprise | Custom (≥ 1,200) | Custom | Custom |
## How to read the headers
Every response includes:
- `X-RateLimit-Limit` — the per-minute cap
- `X-RateLimit-Remaining` — calls left in the current window
- `X-RateLimit-Reset` — Unix epoch (seconds) when the window rolls over
- `Retry-After` — present on 429 responses; seconds to wait
Tell customers to back off using `Retry-After`, not arbitrary delays.
## When 429s aren't actually rate limits
A surprising fraction of "rate limit" tickets are something else. Rule
these out before escalating:
1. **Auth failure cascading**: 401s in a tight retry loop look like
429s when the customer reads aggregate request graphs. Confirm by
checking response codes individually.
2. **Same key on multiple processes**: the limit is per-key, not
per-process. A customer running 4 workers on a Starter plan will
share 120 RPM across all of them.
3. **Quota vs rate**: hitting the daily quota returns 429 too. Check
`X-RateLimit-Limit` — if it's the daily number, they need a higher
plan, not a rate-limit increase.
## Requesting an increase
- Free / Starter / Growth: increases are not granted; suggest upgrading.
- Enterprise: file a ticket with priority `high`, subject
`Rate-limit increase request`, and CC the account's CSM.
@@ -0,0 +1,28 @@
# Escalation Matrix
Use `escalate_to_human` (supervisor mode only) when one of the
following thresholds is hit. The agent should still file a ticket
first so the human has context on landing.
| Trigger | Priority | Route to |
|----------------------------------------------------------|----------|-----------------|
| Account compromise / suspicious logins | urgent | Security |
| Chargeback threat or legal language ("lawyer", "sue") | urgent | Billing + Legal |
| Reported data loss or accidental deletion | urgent | On-call SRE |
| Service downtime claim with customer impact > 1 hour | high | On-call SRE |
| Refund request > $100 outside the discretionary window | high | Billing |
| Customer explicitly asks to speak to a manager / human | high | Senior support |
| Repeated (3rd+) ticket for the same root cause | medium | Tier 2 |
## Escalation note conventions
When escalating, add an internal note that includes:
1. **One-sentence summary** of what the customer wants.
2. **What you've already tried / verified** (e.g. "confirmed propagation
delay via /status endpoint at 14:32 UTC").
3. **The KB article(s)** you cited.
4. **Anything the customer was promised** ("told them we'd respond
within 30 min").
Format: `ESCALATION: <one-line summary> | did: <…> | promised: <…>`
@@ -0,0 +1,28 @@
# Password Reset
For the standard "I can't log in / forgot my password" case. If the
customer reports unfamiliar activity in addition to being locked out,
treat it as a compromise — see `account-recovery`.
## The standard flow
1. Direct the customer to https://app.acme.example/reset and ask them
to enter the email address they signed up with.
2. The reset email arrives within 2 minutes from `[email protected]`.
3. The link is single-use and expires in 1 hour.
## Common failure modes
| Symptom | Likely cause | Action |
|---------------------------------------------|---------------------------|---------------------------------------------------------------------|
| No email after 5 minutes | Corporate spam filter | Have customer check spam, then ask IT to allowlist `acme.example`. |
| "Email not found" error | Wrong address or typo | Confirm the spelling; check whether SSO is configured for them. |
| Link expired | > 1 hour since send | Issue a fresh reset; verify the customer is acting on the new one. |
| SSO error after reset | SSO required by org | Reset doesn't apply — customer must log in via their SSO provider. |
| 2FA prompt after reset, no device available | Lost authenticator | File a ticket; only Security can reset 2FA. **Do not** disable it. |
## Don'ts
- Don't email a temporary password.
- Don't disable 2FA on the customer's behalf — always escalate.
- Don't ask the customer for any portion of their password "to verify".
@@ -0,0 +1,40 @@
# Refund Policy
Acme issues refunds under the following conditions. The agent should
quote the matching clause verbatim when discussing a refund with a
customer.
## Subscription charges
- **Within 14 days of renewal**: full refund, no questions asked.
- **Day 15–30 of renewal**: prorated refund for unused portion of the
billing period.
- **After day 30**: no refund. Customer may downgrade to take effect at
next renewal.
## Usage / overage charges
- Refunds are **discretionary** and capped at **$100 per billing
period** when one of the following applies:
1. The customer did not receive the 80% / 100% rate-limit warning
emails (verify via `tickets_get` notes or the email-events
dashboard).
2. A documented platform incident on our side caused the spike (cross-
reference status.acme.example).
3. The overage is the customer's first ever and the amount is < $50.
- Overages > $100 require supervisor approval. File a ticket with
priority `high` and escalate.
## One-time purchases (add-ons, professional services)
- Refunds are not available once the engagement begins or the add-on is
consumed.
- Unused engagements may be transferred once to a different team within
the same account.
## Disputes
- If the customer threatens a chargeback or mentions their bank, do
**not** discuss refund eligibility further. File a ticket with
priority `urgent`, status `escalated`, and add an internal note
flagging "billing dispute — chargeback risk". Hand off to billing.