AI coding agents can inspect repositories, search files, generate code, modify existing files, run tests, and iterate on failures.
That makes them more useful than traditional code-completion tools, but it also creates an important question for teams working with private source code:
Does the coding agent need to send your code to a cloud service to work?
The answer is no in every architecture. A coding agent can be designed to keep model inference and repository data inside a controlled environment.
However, keeping source code local requires more than installing a local language model.
The entire workflow needs to be examined:
Developer
|
v
Coding Agent
|
+--> Local Repository
|
+--> Local Model
|
+--> Compiler
|
+--> Test Runner
|
+--> Local ToolsIf any component sends source code, prompts, logs, or files to an external service, the workflow is no longer completely local.
What Does "Without Sending Code to the Cloud" Actually Mean?
There are several different interpretations of a private coding workflow.
Fully Local Inference
The model runs on the developer's machine or internal infrastructure.
Repository
|
v
Local Agent
|
v
Local ModelThe source code does not need to be transmitted to an external model provider.
Self-Hosted Internal Inference
The model runs on infrastructure controlled by the organization.
Developer
|
v
Internal Coding Agent
|
v
Internal Model Server
|
v
Internal RepositoryThe model is not running directly on every developer machine, but the organization controls the environment.
Hybrid Architecture
Some operations remain local while others use external services.
Repository
|
v
Local Agent
|
+----> Local Model
|
+----> Cloud ModelThis can be useful, but it does not provide the same data-flow boundary as a completely local architecture.
A Coding Agent Needs More Than a Model
It is easy to think of a coding agent as:
Prompt -> Model -> CodeA real coding agent is usually closer to:
User Request
|
v
Agent
|
+--> Repository Search
|
+--> File Read
|
+--> Model
|
+--> File Write
|
+--> Compiler
|
+--> Test Runner
|
+--> Git
|
+--> External ToolsEvery component that receives repository information becomes part of the security boundary.
This is why simply running the language model locally does not automatically guarantee that source code stays local.
A Fully Local Coding Workflow
A fully local workflow can look like this:
Developer
|
v
+---------------+
| Local Agent |
+-------+-------+
|
+---------------+---------------+
| | |
v v v
Local Repository Local Model Local Toolchain
|
+-------+-------+
| |
v v
Compiler TestsThe model, repository, agent, and development tools all remain within the controlled environment.
This can reduce the number of external data paths that need to be trusted.
Repository Context Is the Real Challenge
An AI coding agent needs context.
Suppose the developer asks:
Add authentication to the existing API.The agent may need to inspect:
Program.cs
Controllers/
Services/
Models/
appsettings.json
Tests/A simple architecture might retrieve relevant files locally:
Repository
|
v
Local Index
|
v
Relevant Files
|
v
Local ModelThe model receives only the context needed for the current operation.
This can be more practical than sending an entire repository into every request.
How Repository Indexing Works
A local coding tool can maintain an index of repository content.
Conceptually:
Source Files
|
v
Parser / Indexer
|
v
Searchable Representation
|
v
Relevant Code
|
v
Model ContextThe index may contain information about files, symbols, functions, classes, and relationships.
The exact implementation depends on the agent.
The important point is that repository indexing itself can contain sensitive source information.
If privacy is a requirement, the index should also remain inside the approved environment.
Local Does Not Mean the Agent Cannot Leak Data
Consider a local agent with these permissions:
Read repository Yes
Write repository Yes
Run commands Yes
Internet access Yes
Read environment YesEven if the model runs locally, the agent may still be able to access external services.
For example:
Local Agent
|
+--> Source Code
|
+--> Environment Variables
|
+--> Git Credentials
|
+--> NetworkThe security question therefore becomes broader:
What can the agent access, and where can that data go?
Restrict Network Access
If an agent is supposed to work entirely offline, network access should be restricted.
A simplified architecture is:
+----------------------------------+
| Isolated Development Environment |
| |
| Repository |
| Local Model |
| Compiler |
| Test Runner |
| Agent |
| |
| Network: Restricted |
+----------------------------------+This makes the intended data boundary easier to enforce.
However, network restrictions can affect package restoration, dependency downloads, source control, documentation access, and other development workflows.
The environment therefore needs to allow only the connections required for legitimate development tasks.
Be Careful With Shell Access
Coding agents often need to run commands.
For a .NET project, the agent may execute:
dotnet build
dotnet test
dotnet restoreThis is useful because the agent can verify its changes.
But shell access is powerful.
A command execution capability can potentially access files or services outside the intended repository.
A safer architecture is to provide the agent with a restricted execution environment:
Agent
|
v
Command Runner
|
v
Sandbox
|
+--> Repository
+--> .NET SDK
+--> Test EnvironmentThe agent does not need unrestricted access to the developer's entire operating system.
Protect Secrets From the Agent
A repository may contain configuration references, but the actual environment may contain credentials such as:
Database passwords
Cloud credentials
API keys
SSH keys
Access tokensThese should not automatically be available to the agent.
For example, avoid making the entire environment available:
Agent
|
X
All Environment VariablesInstead, provide only the configuration required for the task.
Agent
|
v
Restricted Environment
|
+--> Required build configuration
+--> Test configurationA local model cannot protect a secret that the surrounding agent infrastructure has already exposed to it.
Can a Local Agent Use a Cloud Model Selectively?
Yes, but this changes the privacy model.
Join the conversation! Your thoughts help the community grow.