Safeguard
AI Security•

Local or hosted AI coding agent: where does your code actually go?

Local agents still send context to a model service, and hosted agents run your code in someone else's environment. Know both data paths before you choose.

Safeguard Security Team
3 min read

A coding agent that runs on your laptop still usually sends code and prompts to a model service over the network, and a hosted agent also runs commands in the provider's environment. Trace both paths: where the model runs, where commands run, where data is stored, and for how long.

Two things that get confused

Where the agent program runs. On a laptop, in a container you manage, or in a provider's cloud.

Where the model runs. Almost always a hosted service, unless you run a model yourself.

A tool can be local on the first and hosted on the second. "Runs locally" often describes the program, not the data path. Ask about both.

The data paths to trace

QuestionLocal agent, hosted modelHosted agent
Where do commands execute?Your machineProvider environment
What leaves your network?Prompts and file contextPrompts, files, and the repository copy
Whose credentials does it use?Yours, on your machineCredentials you hand to the provider
Where are logs kept?Partly local, partly providerProvider, plus your own if exported
Who patches the runtime?YouProvider

OWASP lists proprietary source code and security credentials among the data at risk of sensitive information disclosure, and suggests clear retention and usage policies. Those policies are what you need from the provider in writing.

Questions to put in writing

  1. Which data is sent: prompts only, whole files, or repository copies?
  2. How long is it stored, and who can access it?
  3. Is it used for training, and can that be turned off for your organization?
  4. In which regions is it processed?
  5. What isolation exists between customers in hosted execution?
  6. What logs can you export?
  7. How are security issues in the tool reported and fixed?

Get the answers in the contract or a security document, not a chat reply. For a longer list, see AI coding assistant security questions for vendors.

Choose by data sensitivity

For low tier repositories, a hosted agent with solid answers may be fine. For high tier code, you may prefer a local agent with a model option that keeps data within your boundary, or no agent at all. Match the choice to your repository tiers.

What hosted agents change in your threat model

You hand over credentials, usually a token to your git host. Scope it to the repositories in scope and no more, and prefer short lived tokens. The agent runs without your direct view, so action records and a human review before merge matter more.

What local agents change

The agent inherits your whole environment. Run it with the permission limits in the permission matrix, and prefer a clean environment.

Do not assume, verify

Test with canary data in a scratch repository and watch the network from the machine. What you observe beats what any brochure says.

Safeguard offers asset discovery, an MCP Guardrail and agent identity, which help you see and scope what agents connect to.

Quick check

Does local mean private?

Not by itself. The program may be local while prompts and file context still go to a hosted model.

Is a hosted agent less secure?

Different, not worse by default. It trades control of the environment for the provider's operations, so the written answers matter more.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.