# How it works

telltale is middleware in your app's backend. On the way out of each request it notes what happened, puts a record in an in-memory buffer, and a background task writes the buffer to the database every few seconds. The database is never on the path of a response, so a slow or missing database cannot slow your app. If the buffer fills up, telltale drops records and counts how many it dropped; `GET /health` reports that count. Tested in five apps, it added under half a millisecond per request.

## What gets recorded

Every response of 400 or above becomes an *event*, and so does every unhandled exception. A request slower than `TELLTALE_SLOW_MS` becomes a slow event. The browser package adds JavaScript errors, render crashes and failed fetch calls from the page.

Some failures look like success to the server. A search that finds nothing returns 200, but whoever sent it got nothing. telltale calls this a *dead end*. It cannot spot one by itself, so your code reports it with `tt.dead_end(...)` where it happens. Agents send queries a form would never produce, so dead ends are often where they get stuck.

Alongside events, telltale counts every request per minute by route pattern, surface and client type. These *rollups* give each error count a baseline: twelve errors on an endpoint that handled forty requests is a different problem than twelve out of forty thousand.

## Grouping

Events that share a kind, status code, route pattern, exception type and top stack frame get the same *fingerprint*. All events with one fingerprint form a *group*, so a thousand copies of one bug show up as one line with a count. A request to a path that matches no route is filed under `<unmatched>`, keeping only its first path segment, so an agent guessing at `/api/v2/...` many times makes one group. telltale keeps at most 60 events per fingerprint per minute and counts the rest.

When someone marks a group resolved and a new event arrives for it, the group goes back to `new` and is flagged as a regression.

## Client types

Each request gets one client type. The rules run in order, and the first match wins:

1. The app's own `classify_hook`, if it has one.
2. An `X-Telltale-Client` or `X-Client-Name` header. The browser package sends one, so your own web app is always `browser`.
3. A User-Agent starting with a prefix from `TELLTALE_OWN_CLIENTS`: `own_client`.
4. A request on the MCP path, named from the MCP handshake: `agent`.
5. A known AI user agent, such as `Claude-User`, `claude-code`, `ChatGPT-User` or `cursor`: `agent`.
6. A known crawler, such as `Googlebot` or `GPTBot`: `crawler`.
7. A generic HTTP library, such as `python-requests` or `curl`: `script`.
8. A browser User-Agent: `browser`.
9. Anything else: `unknown`.

Rule 7 catches many agents. An agent that calls your API through an ordinary HTTP library looks like any other script from its headers. Your app often knows better, from the API key it issued, and that is why the hook runs first. See [How to label your agents](/telltale/how-to/label-agents.md).

## What telltale never stores

telltale stores route patterns such as `/projects/{id}`, never the real path. It never stores request or response bodies, query values, `Authorization` or `Cookie` headers, or any header that looks like a token. For a failed validation it keeps the names of the fields that failed, never their values.

Caller addresses and user ids are hashed with a key that changes every day. You can count how many people hit a bug today, but you cannot follow one person from one day to the next.

Any text telltale keeps, such as an error message or a feedback note, is scrubbed first. Emails, tokens, JWTs, IP addresses, phone numbers, file paths and long ids become placeholders like `[email]` and `[id]`. The scrubber knows common key prefixes such as `ghp_` and `sk-`, but it cannot know the shape of keys your own app makes up; add those with `TELLTALE_EXTRA_SCRUB_PATTERNS`. A feedback note is stored only in its scrubbed form. An app that sets `TELLTALE_PRIVATE_DATA=true` keeps no error or dead-end messages at all.

When a signed-in person sends feedback, the app's `sender_hook` can attach their name and email so an admin can write back. That contact is shown only to admins signed in as people. Anything that reads the API with a key, including the reviewer and the `telltale` command, gets the note without the sender.

## The reviewer's check

The reviewer drafts GitHub issues from telltale's data, and a draft for a public repo could leak something the scrubber missed. Every draft goes through a check before it reaches the queue.

For a public repo, a draft is flagged if it names an internal host, an IP address or a file path; contains a stack trace, a long id or a fingerprint; uses security wording; links anywhere other than the app's repo and hosts you list as public; quotes feedback or copies 8 or more words from it; or comes from an app with private data. If no rule fires, a second model call must still answer that the draft is safe. For a private repo, only the scrub-level rules run.

Rules cannot catch user text that has been reworded, so the reviewer's prompt tells the model never to paraphrase what users wrote. The check only sets a flag. Every draft still lands in the queue, and the console shows the reasons before anyone files it.

The reviewer never talks to GitHub. It runs `claude -p` with no tools, in an empty temporary folder that is deleted after each call.

## Why the data stays in each app

An early version of telltale also had a second design: one shared service that every app sent its records to. Both versions ran in the same five apps on the same simulated traffic, and they recorded identical groups and counts. The shared service would have been one more thing to run, and private data from some apps would have left those apps. So each app keeps telltale's tables in its own database: a `telltale` schema on Postgres, or `telltale_*` tables on MySQL and SQLite.

## Why you copy it in

telltale is copied into each app's repo with `scripts/vendor.sh`. There is no package to publish or pin, and the code that records your traffic sits in your own repo where you can read it. `VENDORED_FROM` records a hash of what was copied. The copy is never edited by hand; changes go into telltale itself and are copied again.
