SSE & LLM Streams
recon sse opens an HTTP request, reads the text/event-stream response as it arrives, and splits it into events. When the event data matches a known LLM streaming format, Recon also pulls out the text delta, joins the deltas into one string, and reports time to first event and a tokens-per-second rate. Use it to test a streaming endpoint, or to see what an LLM API sends back chunk by chunk.
Quick example
Section titled “Quick example”Start the Studio server so the offline sandbox routes are available, then stream the sandbox AI endpoint. It sends six OpenAI-style chunks followed by data: [DONE].
recon init --demorecon ui --port 4600 --no-open &recon sse http://127.0.0.1:4600/_sandbox/local/v1/ai/streamSSE http://127.0.0.1:4600/_sandbox/local/v1/ai/stream -> HTTP 200 (provider=openai, events=6, tokens=6, ttft=0.5ms, rate=168857.1 tok/s, airlock=false)Recon live stream (local): elena@westminster.edu verified.The first line is the summary. The second line is the assembled text. Add --airlock to mask PII before it is printed:
recon sse http://127.0.0.1:4600/_sandbox/local/v1/ai/stream --airlockSSE http://127.0.0.1:4600/_sandbox/local/v1/ai/stream -> HTTP 200 (provider=openai, events=6, tokens=6, ttft=0.4ms, rate=2739.0 tok/s, airlock=true)Recon live stream (local): miriam.monroe.4411@example.edu verified.The sandbox writes the whole stream at once, so every event arrives in the same read and the rate is very high. Against a real model the numbers reflect actual chunk timing.
Targets and request options
Section titled “Targets and request options”The <TARGET> argument is either:
- the ID or name of a saved request from your
.httpcollections, or - a raw URL that starts with
http://orhttps://. A raw URL is sent asGETwith no body.
Anything else fails with E_NOT_FOUND and exit code 2.
To send a request body (for example a chat completion with "stream": true), save it as a request in a .http file and pass its name. Recon sends the saved method, headers and body:
### Chat Stream# @name Chat StreamPOST http://127.0.0.1:4600/_sandbox/local/v1/ai/streamContent-Type: application/jsonAuthorization: Bearer {{DEV_API_TOKEN}}
{"model":"demo","stream":true}recon sse "Chat Stream" --max-events 2SSE http://127.0.0.1:4600/_sandbox/local/v1/ai/stream -> HTTP 200 (provider=openai, events=2, tokens=2, ttft=0.5ms, rate=89035.3 tok/s, airlock=false)Recon liveRequest handling:
{{variables}}in the URL, headers and body are resolved from the selected environment (--env, or the workspacedefault_env).- If the request has no enabled
Acceptheader, Recon addsAccept: text/event-stream. - If the request has no
User-Agentheader, Recon sendsUser-Agent: recon-proto/0.1. --methodreplaces the request method. Any token is accepted;GET,POST,PUT,PATCH,DELETE,HEADandOPTIONSare recognised and any other value is sent as given in upper case.- Redirects are not followed.
- Pre-request and post-response scripts in the saved request are not run.
How the stream is parsed
Section titled “How the stream is parsed”Recon reads the body frame by frame and parses it line by line:
| Input | Behaviour |
|---|---|
| Line ending | Lines end at \n. A trailing \r is removed, so CRLF works. A bare \r is not treated as a line end. |
Line starting with : |
Comment, ignored. |
event: x |
Sets the event type. Without it the type is message. |
data: x |
Adds a data line. Multiple data: lines are joined with \n. |
id: x |
Sets the event ID. The ID carries over to later events until another id: line arrives. An ID that contains a NUL character is ignored. |
retry: and any other field |
Ignored. |
| Value prefix | One leading space after the colon is removed. data:x and data: x give the same value. |
| A line with no colon | Treated as a field name with an empty value. |
| Blank line | Ends the event. The event is kept if it has at least one data: line or an event: line. |
Data equal to [DONE] |
Stops reading. The stream is marked complete and the [DONE] event is not recorded. |
Limits
Section titled “Limits”| Limit | Default | Effect |
|---|---|---|
--max-events |
200 |
Reading stops once this many events are recorded. Values below 1 become 1. |
--timeout-ms |
15000 |
One deadline for the whole call: connecting, the response headers, and every event. The effective minimum is 500 ms. |
When the deadline passes:
- if no event has been recorded yet, the command fails with
protocol operation timed out after <ms> ms; - otherwise Recon stops reading, returns the events it has, and sets
completedtofalse.
There is no limit on response size in bytes other than these two settings.
For a response with status 400 or above, Recon reads the body until the server closes it, then fails with the status and body text. If the error body is still open when the deadline passes, you get the timeout error instead.
LLM stream decoding
Section titled “LLM stream decoding”Each event’s data is parsed as JSON. If it matches one of these shapes, Recon records the text as the event’s token_delta and the provider as provider_hint:
| Provider hint | Recognised when | Text taken from |
|---|---|---|
openai |
choices[0].delta.content is a string (Chat Completions stream) |
choices[0].delta.content |
openai |
type is response.output_text.delta and delta is a string (Responses API stream) |
delta |
anthropic |
type is content_block_delta and delta.text is a string (Messages stream) |
delta.text |
gemini |
candidates[0].content.parts[0].text is a string |
candidates[0].content.parts[0].text |
The checks run in that order and the first match wins. Data that is not JSON, or JSON that matches none of these shapes, has no token delta. provider_detected in the report is the hint of the first event that matched.
Recon does not extract finish reasons, stop reasons or usage counts. Those stay in the raw data of the event that carried them.
Metrics
Section titled “Metrics”| Field | How it is computed |
|---|---|
ttft_ms |
Time from just before the connection opens to the arrival of the first event whose data is not empty. This is the first event of any kind, not the first text delta. For an Anthropic stream it is the message_start event. |
tokens_count |
Number of events with a non-empty token_delta. This counts chunks, not model tokens. If no event carried a delta, it is the number of events. |
tokens_per_sec |
tokens_count divided by the time from the first non-empty delta to the end of the call. With no deltas, the whole call duration is used. 0 when there is nothing to count. |
total_ms |
Wall time of the whole call. |
offset_ms (per event) |
Time at which the network read that contained the event arrived. Events that arrive in the same read share the same offset. |
Assembled text
Section titled “Assembled text”If any event has a token_delta, assembled_text is all the deltas joined with no separator. Otherwise it is the data of every event joined with \n. For a plain event stream with no LLM data, that is every event’s payload.
Output
Section titled “Output”In human format Recon prints one summary line, then the assembled text if it is not empty. The summary shows provider=plain when no provider was detected.
In json and agent format Recon prints the full report:
recon --format json sse http://127.0.0.1:4600/_sandbox/local/v1/ai/stream --airlock --max-events 3{ "url": "http://127.0.0.1:4600/_sandbox/local/v1/ai/stream", "status": 200, "provider_detected": "openai", "ttft_ms": 0.494526, "total_ms": 2.726576, "events_count": 3, "tokens_count": 3, "tokens_per_sec": 1344.0559127259694, "assembled_text": "Recon live stream (", "events": [ { "index": 0, "offset_ms": 0.494526, "event_type": "message", "id": null, "data": "{\n \"choices\": [\n {\n \"delta\": {\n \"content\": \"Recon \"\n },\n \"index\": 0\n }\n ],\n \"id\": \"chatcmpl_demo\"\n}", "token_delta": "Recon ", "provider_hint": "openai" },... ], "airlocked": true, "compliance_receipt": { "salt_fingerprint": "9d2de0d49b08", "fields_masked": 0, "secrets_scrubbed": 0, "headers_stripped": 0, "verified_zero_leak": true, "leaked_tokens_found": [], "receipt_hash": "2793b88ad1e765073e4e3f2ba065041f93a80373a01cd5127af1edab31aef7f0" }, "completed": true}| Field | Meaning |
|---|---|
url |
The resolved URL with any secret values replaced by [SECRET:NAME]. |
status |
HTTP status of the response. |
provider_detected |
openai, anthropic, gemini, or null. |
ttft_ms, total_ms, tokens_count, tokens_per_sec |
See Metrics. |
events_count |
Number of recorded events. |
assembled_text |
See Assembled text. |
events[] |
index, offset_ms, event_type, id, data, token_delta, provider_hint for each event. |
airlocked |
true when --airlock was passed. |
compliance_receipt |
The PII Airlock receipt for the assembled text and response headers. |
completed |
true if the stream ended, [DONE] arrived, or --max-events was reached. false if reading stopped at the deadline. |
Response headers are not part of the report.
--airlock
Section titled “--airlock”With --airlock, each event’s data is passed through the PII Airlock before token decoding, so data, token_delta and assembled_text all hold masked values. JSON data is re-serialised during masking, which is why the data strings in the example above are pretty-printed. The assembled text is masked again as a whole.
The compliance_receipt is produced on every run. Without --airlock, the values in the report are the raw ones.
Secrets, auth and transport
Section titled “Secrets, auth and transport”-
Secret firewall. After variables, secret URIs and auth are resolved, the request passes through the Outbound Secret Firewall before Recon opens a connection. A blocked request exits with
1andE_FIREWALL_BLOCKED:Terminal window recon sse "Stripe Prod Key Leak Check"error E_FIREWALL_BLOCKED: Blocked secret `PROD_STRIPE_KEY` bound for `api.stripe.com` from being sent to unauthorized host `127.0.0.1`.hint: Switch environment or update secret allowed_hosts. -
Auth and signing. The saved request’s auth block is applied as for other requests, including OAuth 2.0 token acquisition, AWS SigV4 and HMAC signing. See Auth & Request Signing and Vault & Secret URIs.
-
Transport.
recon sseuses its own HTTP client:http://URLs use HTTP/1.1.https://URLs use TLS with the bundled Mozilla root certificates. ALPN offersh2andhttp/1.1, and HTTP/2 is used when the server picksh2.- The global
--proxy,--no-proxy,--ca-cert,--client-cert,--client-key,--insecure,--cookiesand--cookie-jarflags, and.recon/network.json, have no effect on this command. A server with a self-signed or private-CA certificate cannot be reached.
recon sse does not write to the Flight Recorder.
| Flag | Default | Description |
|---|---|---|
<TARGET> |
required | Saved request ID or name, or an http:// / https:// URL. |
--env <ENV> |
workspace default_env |
Environment used for variables and secrets. |
--method <METHOD> |
request method | Override the HTTP method. |
--max-events <N> |
200 |
Stop after this many events. |
--timeout-ms <MS> |
15000 |
Deadline for the whole call. Minimum effective value 500. |
--airlock |
off | Mask PII in event data and assembled text. |
Global flags such as --workspace, --format and --salt also apply. See the CLI Reference.
Errors and exit codes
Section titled “Errors and exit codes”| Exit | Code | When |
|---|---|---|
0 |
The stream was read. This includes a stream cut short by the deadline after at least one event. | |
1 |
E_FIREWALL_BLOCKED |
The secret firewall blocked the request. |
2 |
E_NOT_FOUND |
The target is not a saved request and not an http(s):// URL. |
2 |
E_CLI_RUNTIME |
Any other failure. Messages include protocol operation timed out after <ms> ms, SSE stream error: upstream returned HTTP <status>: <body> (for status 400 and above, with the body cut to 400 characters and secrets scrubbed), and transport error: ... for DNS, TCP and TLS failures. |
Error envelopes are written to stderr. See Output Formats & Exit Codes.
Also available via
Section titled “Also available via”| Surface | Name | Notes |
|---|---|---|
| MCP tool | recon_sse_stream |
Takes request or url, plus method, env, max_events (default 100, capped at 200) and timeout_ms (default 15000, clamped to 500 to 60000). Airlock is always on. The call goes through agent policy using the request’s method. |
| HTTP API | POST /api/v1/sse/stream |
Body: request (a full request object), optional env, optional config with max_events, timeout_ms and airlock. Returns { "report": ... }. See HTTP API. |
| Web Studio | Protocols, tab SSE / AI Stream | Method POST or GET, URL (default {{base_url}}/v1/ai/stream), max events (default 100), and an Airlock toggle that starts on. The timeout is fixed at 15000 ms. Shows provider, TTFT, throughput, event and token counts, the receipt, the assembled text and an event timeline. Also opened from the command palette entry “Open SSE / AI Stream Inspector”. |