What Spanway stores
Spanway keeps two kinds of data about a request. Metadata says who sent it, which model served it, how many tokens it used, what it cost, how long it took, whether it worked and how it relates to other requests. Content is what was said, meaning the prompt, the response, tool inputs and outputs, retrieved text, guardrail inputs and error text that quotes the request. Metadata is always kept so that spend, budgets, traces and dashboards work. Content is kept only when every setting that applies allows it. Database tables maps every table in the gateway database, with what it holds and how long it is kept.
A real-world scenario
A legal team asks whether the gateway keeps the text of customer conversations. The platform admin opens the Logs page, picks a recent request and sees Request/Response Data Not Available, because prompt storage is off by default. The team then decides that one internal team may keep prompts for debugging while the customer facing team may not. The admin turns store_prompts_in_spend_logs on and gives the customer facing team a zero data retention policy, so its requests are redacted everywhere whatever the gateway setting says.
Check what is kept for a request
-
Send a request with a tag you can find again:
curl -X POST http://localhost:4000/v1/chat/completions \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"model": "claude-haiku-5-5", "messages": [{"role": "user", "content": "Hi"}], "metadata": {"tags": ["storage-check"]}}' -
In the Admin UI open Logs. The request is in the table with its model, tokens and cost, which are always kept. Click the row.
-
In the drawer, the Request & Response section shows the messages when content is kept, or Request/Response Data Not Available when it is not. On a new install it is not kept.
-
Read the same row from the API with the request id from the table:
curl "http://localhost:4000/spend/logs?request_id=chatcmpl-7f3a9c2e" \-H "Authorization: Bearer $SPANWAY_API_KEY"Expected result: the row carries
model,spend,total_tokens,startTime,endTimeand the key, team and user, and itsmessagesandresponsefields are{}until prompt storage is on and no redaction applies. -
To keep content, set
store_prompts_in_spend_logs: trueundergeneral_settingsin the config file (or the prompt storage switch in the Logging Settings of Admin Settings), restart or reload, and send another request. Only new requests are affected.
When content is kept
Spanway's own stores keep content only when all three of these hold for the request. Logging integrations you configure follow only the second and third.
general_settings.store_prompts_in_spend_logsistrue, or it is unset and theSTORE_PROMPTS_IN_SPEND_LOGSenvironment variable istrue. A savedfalse, from the config file or the Logging Settings switch, wins over the variable, so the switch always shows what really happens. Both are off by default, so a new install keeps no content.- Message logging is not turned off, either for the whole gateway with
spanway_settings.turn_off_message_loggingor for the request, for example through a team logging setting. - No zero data retention policy applies. A policy applies when the key, its team or its organization sets
data_policy.require_zdr, when one of those policies cannot be read, or when the request itself asks for zero data retention withprovider.zdr: trueor a key or team provider preference that carries it.
Zero data retention always wins. A key or team that allows clients to opt out of message redaction loses that opt out while a zero data retention policy applies. Requests under zero data retention are also never written to the response cache.
The gateway works this out once per request and stamps the result into the request metadata, so every store and logging callback reads the same answer. Requests that fail before the gateway has prepared them, for example a budget or rate limit refusal, are checked against the key's policy when the failure is logged.
Stores
| Store | Always kept as metadata | Content kept when | Under zero data retention | Retention setting that deletes it | Data subject export and erasure |
|---|---|---|---|---|---|
Spend logs (Spanway_SpendLogs) | Request id, key hash and alias, user, team, organization, end user, the caller's IP address and user agent, model and model group, provider, tokens, cost, start and end time, status, cache hit, tags, error class and code, MCP tool name and server, vector store id, guardrail name, status and timing. | store_prompts_in_spend_logs is on and the request is not redacted. Then the stored request body, the response, MCP tool arguments and results, vector store queries and results, guardrail inputs and outputs, and error text are kept. | The request body, response and messages are stored as {}. Tool arguments and results, vector store queries and results and guardrail inputs and outputs are removed, and error text has any quoted request input replaced with redacted-by-spanway. | maximum_spend_logs_retention_period | Export includes the rows. Erasure replaces the subject with a pseudonym and empties the stored prompt, response and request body. |
Lens copy of request logs (Lens ClickHouse spend_logs, written by the gateway's ClickHouse logger and by the Lens exporter) | The same metadata as spend logs. | The same rule as spend logs. | messages, response and the caller's request metadata are empty, and error text is redacted as above. | AGENT_TRACING_RETENTION_DAYS on Lens, 14 days by default. | Export returns up to 1,000 rows. Erasure asks Lens to delete them, or deletes them through CLICKHOUSE_URL when the gateway has it. When Lens cannot be reached the request is recorded as partial. |
| Lens traces (agent spans) | Trace and span ids, the span tree, span name, service, kind, duration, status code, agent name, framework, model, token counts, tool call ids, the exception type, and a small set of identifying attributes such as session.id and gen_ai.operation.name. | Lens is connected to the gateway and the gateway's latest content policy says prompts are stored and the trace credential's team is not under zero data retention. A Lens that runs without a gateway connection keeps metadata only unless LENS_KEEP_SPAN_CONTENT=true is set on it. | Span inputs, outputs, input previews, free-form attributes, status messages and exception messages are dropped before the span is written. | AGENT_TRACING_RETENTION_DAYS on Lens, 14 days by default. | Export returns up to 1,000 spans. Erasure deletes the subject's spans and every span of the traces they took part in, the same way as the request logs. |
Custom agent runs (Spanway_CustomAgentRun) | Run id, agent, caller, surface, steps, tools called, tool denials, tokens, cost, stop reason and timing. | store_prompts_in_spend_logs is on, turn_off_message_logging is off and the caller's key, team and organization do not require zero data retention. | Input and answer are stored as redacted-by-spanway, the transcript is empty and the stop event keeps no detail. The caller still receives the full answer. | maximum_custom_agent_run_retention_period, never longer than spend logs. | Export includes the runs. Erasure deletes the runs the user started. |
Workflow runs (Spanway_WorkflowRun and its steps, attempts and pins) | Run and step ids, states, timing, spend, error codes, character counts. | workflow_runner.capture_io is on, store_prompts_in_spend_logs is on, message logging is not turned off and no key in the run is under zero data retention. Otherwise the run is metadata_only. | The run is metadata_only. A run whose key starts requiring zero data retention while it runs is redacted at once. | maximum_workflow_run_retention_period, never longer than spend logs. | Export includes the runs. Erasure deletes them, or scrubs and pseudonymises a run that is still running. |
Online eval scores (Spanway_OnlineEvalScoreTable) | Rule, rule version, backfill id when a backfill wrote it, request id, scorer, score, pass or fail, model, team, key hash, judge cost, latency. | The judge's reason is kept only when store_prompts_in_spend_logs is on. | The request is never scored. | maximum_online_eval_score_retention_period, never longer than spend logs. | Rows follow their request id. They hold no subject id of their own. |
Eval runs and results (Spanway_EvalRunTable) | Run, dataset, models, scores and costs. | Always, because results and transcripts are built from the dataset you chose to run. | Not affected, since eval runs score datasets, not live requests. | maximum_eval_run_retention_period | Erasure deletes the results built from the subject's dataset items. |
End-user feedback (Spanway_EvalFeedback) | Request id, session id, end user, score, label, team, organization. | The optional comment the app sends is kept as sent. | The comment is dropped when the key that sends the rating, its team or its organization requires zero data retention. The score, label and ids are kept. | maximum_eval_feedback_retention_period, never longer than spend logs. | Export includes feedback recorded for the end user, and erasure deletes it. |
Lens feedback (Lens ClickHouse lens_feedback) | Trace id, team, author, score. | The comment a reviewer writes in Lens is kept as written. | Not affected. | Kept until deleted. | Erasure deletes it the same way as the Lens request logs. |
| Lens datasets (Lens ClickHouse state) | Dataset name, revision, who saved it, case count. | Always. Each case is a copy of a conversation chosen from a trace or a finding, so it holds prompts and answers, and it stays after the trace expires. | Spans written without content give cases without content. | Kept until deleted, with no expiry. | Not reached. Export and erasure do not cover dataset cases, so delete the datasets that copied a person's conversations by hand. |
Lens eval runs and results (Lens ClickHouse lens_eval_traces and state) | Eval, run, case, pass or fail, scores, the users and team of the run. | Always. Eval traces hold the case input and the agent's output. | Judged evals refuse runs under zero data retention, so their content is never sent to a judge. | Kept until deleted, with no expiry. | Erasure deletes the eval traces the subject took part in. Results kept in state are not reached. |
| Lens findings, signals and analysis settings (Lens ClickHouse state) | Finding titles, the runs that support them, signal questions, analysis model, frequency and budget, spend this month. | Finding descriptions can quote short trace excerpts. | Excerpts come only from spans that kept content. | Kept until deleted. | Not reached. |
| Lens tracing keys and GitHub connection (Lens ClickHouse state) | Tracing key names, hashes and who created them. The GitHub App installation and repository. | Never. Keys are stored hashed. | Not affected. | Kept until revoked or disconnected. | Not reached, they hold no subject data. |
Lens trace summaries and call costs (Lens ClickHouse lens_trace_summaries, lens_call_costs) | Per trace summary, agent, user, model call costs. | Never. | Not affected. | AGENT_TRACING_RETENTION_DAYS on Lens. | Erasure deletes them for the subject's traces. |
Error logs (Spanway_ErrorLogs) | Request id, model, deployment, API base, exception type, status code and time. | The request_kwargs and exception_string columns of rows written by earlier versions can hold request input. The current gateway does not write this table. | Not affected, since nothing new is written. | maximum_error_log_retention_period | Not reached. Let the retention period delete old rows, or empty the table. |
Audit log (Spanway_AuditLog) | Who changed which setting, key, team or other object, and when, plus who viewed, revealed or exported request logs and spend data, with their address, browser and, for a reveal, the reason they typed. | Never. Read events name the request id and the fields involved, never the content. | Not affected. | maximum_audit_log_retention_period | Export includes entries about the subject and entries they made. The log is hash chained, so erasure does not rewrite it and the retention period bounds how long a person stays named there. An erasure records the deleted user under its pseudonym with no copy of the row, but a plain /user/delete keeps a copy of the deleted user row, email and metadata included, as the entry's before value. |
| Logging integrations and alerts, including a cold storage bucket for spend log payloads | Whatever metadata the integration records. | Message logging is not turned off for the gateway, the callback or the request. store_prompts_in_spend_logs does not control integrations, so set turn_off_message_logging when a destination must not receive content. | Every integration receives the redacted payload, with messages and responses replaced and tool arguments, retrieved text and quoted request input removed. Alerts and gateway error logs leave out the prompt and any request input the provider quoted back. Outside zero data retention they also leave out the prompt by default, because spanway_settings.redact_messages_in_exceptions defaults to true. Setting it to false puts the first 100 characters of the messages into exception debug text and slow request alerts. | Set in the destination. | Not reached. Delete the data in the destination. |
The Lens rows come from the Lens service, which keeps its own ClickHouse database. Data subject export and erasure reach Lens as described in data subject requests.
Lens trace spans
Agents send their spans straight to Lens, not through the gateway, so the gateway tells Lens what it may keep. Every 30 seconds the gateway sends Lens a content policy with two facts, whether prompts are stored (store_prompts_in_spend_logs is on and turn_off_message_logging is off) and which teams require zero data retention, directly or through their organization, or have a policy that cannot be read. Lens keeps span content only for a trace credential whose team is not on that list, and only while it holds a policy younger than 90 seconds. With no policy, a stale policy, or a gateway that cannot read its teams from the database, Lens keeps metadata only. A connected Lens has no setting of its own for span content, so store_prompts_in_spend_logs controls spans the same way it controls spend logs. The same policy also names every team with a restricting data policy, and Lens never sends eval runs of those teams or of zero data retention teams to an LLM judge.
The policy reaches one Lens replica at a time through SPANWAY_LENS_URL. That replica stores it in the Lens ClickHouse database, and every replica reloads the stored policy every 10 seconds, so all of them enforce the same policy. A replica that has not loaded a policy younger than 90 seconds keeps metadata only and judges nothing until it does.
A Lens started without SPANWAY_LENS_SERVICE_TOKEN has no gateway policy to follow. It keeps span metadata only unless LENS_KEEP_SPAN_CONTENT=true is set on it.
Traces and evals without stored content
Traces, dashboards and most evals keep working when no content is stored, because what they need is metadata.
- Spend, budgets, rate limits, usage dashboards and the Logs page use tokens, cost, model, key, team and status, which are always kept.
- A Lens trace still shows the full span tree, each model and tool call, their timing, token counts, cost and status, which agent made them and where they failed. Only the inputs and outputs of each span are blank.
- The run ledger, custom agent runs and workflow runs keep every step, tool name, cost and outcome.
Evals that grade what was said need that text. They can use content in three ways.
- Store it on purpose for the keys and teams where it is allowed, by turning on
store_prompts_in_spend_logsand leaving zero data retention off for them. - Upload or build datasets, which hold the inputs and expected outputs you chose to keep. Eval runs score those datasets and do not depend on stored requests.
- Use online scoring, which scores a live response in memory as it happens and keeps only the score. Online scoring skips every request whose content is redacted, including every request under zero data retention, and it keeps the judge's reason only when prompts are stored.
Building a dataset from logs or sessions, review queues and Lens analysis read stored content, so they have nothing to work with for requests whose content was not kept.
What is not covered
Debug output is meant for development and prints request bodies whatever these settings say. Never run with --detailed_debug, SPANWAY_LOG=DEBUG or SPANWAY_PRINT_STANDARD_LOGGING_PAYLOAD in production. The gateway logs a warning at startup that names each of these modes that is on. Content you store yourself, such as memories, managed files, prompts in prompt management and eval datasets, is kept because you saved it, and each has its own retention period on the compliance page.
Errors
| What you see | Where | Meaning | Fix |
|---|---|---|---|
| Request/Response Data Not Available | Logs page drawer | Prompt storage is off, or this request was redacted by a zero data retention policy or turn_off_message_logging. | Turn store_prompts_in_spend_logs on for new requests. Redacted requests never keep their bodies, by design. |
messages and response are {} | GET /spend/logs | The same reasons as above. | The same fix. |
redacted-by-spanway in a run, an answer or an error text | Custom agent runs, run ledger, logging destinations | The request was under zero data retention, so the text was replaced before it was stored or sent. | By design. Check the key, team and organization data policies. |
| A trace in Lens shows blank inputs and outputs | Lens | Lens has no content policy younger than 90 seconds from the gateway, or the trace credential's team requires zero data retention. | Check SPANWAY_LENS_URL and the gateway's connection to Lens, and the team's data policy. |
Logs
| Level | Line | Meaning |
|---|---|---|
| WARNING | DEBUG OUTPUT PRINTS REQUEST AND RESPONSE BODIES: <modes>. Prompts, responses and request metadata reach the logs whatever store_prompts_in_spend_logs, turn_off_message_logging or zero data retention say. Never run this in production. | The gateway started with one of the debug modes named in the line. Turn them off outside development. |
Related
- Logs page for reading individual requests.
- Data policy routing for zero data retention policies.
- Compliance for retention periods and data subject requests.
- Logging for what reaches each destination.
- Audit logs for the one store that is never redacted or erased.
- Error reference and log reference.