Sub topic 3
Where your data goes: prompts, context, tools, and telemetry
This chapter assumes you can use Git and a command line, have used an AI coding assistant or chat tool, and know what an environment variable is. It builds a working model of how information leaves your machine when you use an AI tool. Later chapters cover the controls. Here the goal is to see every path clearly, because you can't protect a path you don't know about.
The four paths
Data reaches an AI provider through four paths:
- Prompts. Text you type or paste.
- Context. Material the tool collects for you: open files, search results, repository snippets, and earlier conversation turns.
- Tool calls. Commands, file reads, and requests to other services that the model asks the tool to run. Their output is sent back to the model.
- Telemetry. Usage data the tool reports about itself, such as crash reports, feature use, and sometimes snippets of content.
Most people only think about the first path. In practice the second and third carry most of the sensitive data, because they happen without you typing anything.
Notice the loop. A tool call's output becomes part of the next request, so anything a command prints can be sent to the provider.
Path 1: prompts
A prompt is sent to the provider as you submit it. Common errors:
- Pasting a full stack trace that includes a connection string or an
Authorizationheader. - Pasting a configuration file "just to get help with the syntax" when it holds real values.
- Pasting a
curlcommand copied from browser developer tools. These often include session cookies and bearer tokens.
Pasting is usually deliberate, so it is the easiest path to control. The habit is to replace values with placeholders before you submit. The "Redacting what you paste" chapter covers this in detail.
Path 2: context
Many tools build the request for you. An editor assistant may include the current file, other open tabs, files it finds with search or embeddings, and the diff of your recent changes. A command-line agent may read files on demand as it works.
This means you can leak a secret without ever mentioning it. If a .env file is open in a tab while you ask a question about another file, a tool that includes open tabs can send it.
Context has a second dimension, which is time. Conversation history is usually resent with every turn. If you paste a secret in turn 2, it is likely sent again in turns 3 through 20, and it stays in any saved session file on disk. Deleting it from your next message doesn't remove it from history.
Typical sources of context, from most to least obvious:
| Source | Example | How a secret gets in |
|---|---|---|
| Your message | Pasted log | You paste it |
| Attached files | `@config.yaml` | You attach the whole file |
| Open editor tabs | `.env` visible | Tool includes tabs automatically |
| Search or index results | Snippets from the repo | Index includes files you forgot about |
| Conversation history | Earlier turns | Old content is resent |
| Project instruction files | Rules or notes files | Someone put a token in them |
Path 3: tool calls
Agent-style tools let the model ask for actions: read a file, list a directory, run a shell command, fetch a URL, or call a tool server. The tool runs the action on your machine, with your permissions, and sends the result back to the model.
Two risks follow.
Output is data. Running env, cat ~/.aws/credentials, git remote -v (which can show a URL with an embedded token), or docker inspect prints secrets. The model may ask for these while debugging, and if you approve them, the output goes to the provider. Test commands that print their configuration on failure are a common source.
The agent inherits your environment. A child process gets the environment variables of the process that started it. If you launch an agent from a shell where AWS_SECRET_ACCESS_KEY or GITHUB_TOKEN is set, every command the agent runs can read it, and so can any command output that echoes it.
You can check what a tool would inherit. This script prints only variable names that look sensitive, never values:
import os
SUSPECT = ("KEY", "SECRET", "TOKEN", "PASSWORD", "PASSWD")
for name in sorted(os.environ):
if any(word in name.upper() for word in SUSPECT):
print(name)Run it in the same shell you use to start your AI tool. Every name it prints is something a command run by the agent can read.
To start a tool with a minimal environment, use env -i and pass through only what it needs:
env -i PATH="$PATH" HOME="$HOME" TERM="$TERM" your-agent-commandReplace your-agent-command with your tool's actual command. Some tools need extra variables, such as one for their own login, so add them one at a time rather than passing everything. Note that HOME still lets the agent read files such as ~/.aws/credentials. Environment filtering only closes the variable path, not the file path.
Path 4: telemetry
Telemetry is data the tool reports about its own use. It ranges from anonymous counters ("feature X was used") to crash reports that can include stack traces and local variable values, to, in some tools, prompt and response content for quality improvement.
Points to check for any tool you use:
- Whether telemetry is on by default, and whether there is a setting or environment variable to turn it off.
- Whether telemetry content is separate from the content used for model training. They are different things, with different policies.
- Whether extensions or plugins send their own telemetry, independent of the main tool's setting.
Don't assume that the telemetry setting also controls what is sent in prompts. Turning telemetry off does not stop the tool from sending your prompt to the model. It only stops the reporting channel.
Where else the data may travel
The provider is not always the last stop. After a request arrives, it may pass through:
- An intermediary. A gateway, proxy, or aggregator that routes requests to one of several models. It is a second party that can log traffic.
- The provider's logs and storage. Prompts may be kept for abuse monitoring or debugging for some period. The "Reading provider retention and training policies" chapter explains how to read these terms.
- Human review. Some plans allow staff to review flagged or sampled content.
- Your own machine. Chat history, session transcripts, and caches are stored locally, often as plain text in your home directory. A secret that was sent once may also sit on disk.
A practical audit
To build your own picture for a tool you use, answer these questions from its documentation and settings:
- What does it include in context by default? Open tabs, the whole repository, terminal output?
- Can it run commands or read files without asking? Which actions need approval?
- What environment does it run commands in?
- Where does it store history locally?
- Which provider receives requests, and does an intermediary sit in between?
- What telemetry is sent, and how do you disable it?
Write the answers down once per tool. This is the input to every later control: ignore rules (path 2), agent permissions (path 3), and policy choices (all paths).
Common errors
- Believing only typed text is sent. Context and tool output are sent too.
- Treating "I deleted the message" as removal. The provider already received it, and local history may still hold it.
- Fixing one path and ignoring the others. An ignore file prevents file context. It does not stop a command from printing the same file.
- Assuming a local tool means local data. A command-line agent running on your laptop still sends requests to a remote model unless the model is itself self-hosted.
- Trusting the telemetry toggle to cover everything. It usually covers only reporting.
Exercise
You run an agent from a shell that has GITHUB_TOKEN set. The agent proposes running git remote -v to debug a push failure, and your remote URL has the form https://user:[email protected]/org/repo.git. Which path does this exposure use, and what are two ways to reduce it?
Show answer
It uses the tool-call path. The command prints the embedded token, and the output is sent to the model in the next request. You can reduce it by (1) declining the command, or changing the remote to a URL without an embedded credential and using a credential helper or SSH key, and (2) launching the agent without GITHUB_TOKEN in its environment, for example with env -i plus only the variables it needs. Removing the credential from the remote URL fixes the root cause.
Exercise
You turned off telemetry in your editor assistant. A colleague says your code is therefore no longer sent anywhere. What is wrong with this claim?
Show answer
Telemetry is the reporting channel for usage and crash data. Prompts and context are sent to the model service as part of normal operation, and the telemetry setting doesn't stop that. Code is still sent whenever it is included as context, so you need ignore rules, narrower context settings, or a different tool or plan to control it.