AgentConnect
Operate & GovernSandboxing

Credential protection

How AgentConnect keeps code-host tokens, provider API keys, and saved logins out of agent sessions.

Whenever possible, the daemon keeps real credentials out of agent sessions. Instead of the real secret, the session receives a placeholder. When a request goes out to the intended destination, the daemon's credential proxy swaps in the real credential. Anything the agent reads from its environment or local files is useless anywhere else.

Code-host credentials

GitHub, GitLab, and Gitea access works this way in every execution environment: host, srt, microsandbox, Kubernetes pool pods, and sessions that a daemon group runs on another member's machine. It's enabled automatically.

  • git, gh, and glab work as usual. The proxy attaches a short-lived token scoped to the target repository and the agent's access level on it.
  • The session's environment, Git configuration, and files contain no usable token.
  • Any token explicitly given to the agent, such as its own GH_TOKEN or GITLAB_TOKEN secret, passes through unchanged.
  • The old gh-token and glab-token helper commands and the gh and glab wrappers have been removed. Scripts should invoke git, gh, or glab directly.

What the proxy refuses

RequestResult
A GitHub GraphQL mutationRefused: GraphQL is read-only. The error points to the agent's code-host tool for that write (pull requests, issues, comments, reviews), and the agent retries with it.
A GitLab or Gitea API writeRefused, pointing to the write tool. API reads work normally.
git push to a read-only repositoryRefused because the agent lacks write access. Grant Read & write to allow pushing.
A REST write that doesn't target a repositoryRefused. GitHub REST writes to a specific repository (such as gh api) go through at the agent's access level.

Because creating or editing GitHub Projects items and Discussions requires GraphQL mutations, agents can't perform those writes, though reading them still works.

If a session can't reach the proxy (for example, on a Kubernetes runtime image older than the daemon), it starts without code-host credentials and the daemon logs why.

Provider API keys

Model provider API keys use the same proxy. The runtime gets a placeholder, and the proxy injects the real key before forwarding the request to the provider.

KeySessions
Organization Infra → Provider keys, for an agent whose Model sign-in is Provider keyHost, srt, and microsandbox, including host sessions a daemon group runs on another member
API keys on the daemon's own machine, for the runtimes marked Proxy belowsrt and microsandbox
A Kubernetes install's keys: daemonPool.modelCredentials, modelEgress.clients.<client>.apiKey, and ANTHROPIC_API_KEY, OPENAI_API_KEY, DEEPSEEK_API_KEY, or COPILOT_PROVIDER_API_KEY mapped in daemonPool.runtimeEnvironmentPool pods (details)

Any extra headers configured on an organization key are added by the proxy and never enter the session. If you change a key's endpoint, start a new session for the change to take effect.

The following credentials still pass into the session as-is:

  • Keys whose endpoint is plain http://, since placeholder replacement only happens over HTTPS
  • Keys the daemon can't match to a single HTTPS endpoint for that runtime, such as one using a custom port (the daemon logs a warning once)
  • Short-lived per-session keys issued by a key server
  • Subscription and OAuth logins (covered below)
  • The daemon machine's own keys in a host session, since host sessions can read local files directly anyway

Trust and network

Because the proxy terminates TLS for code-host and provider requests, sessions must trust a certificate authority generated by the daemon. The daemon points the standard CA environment variables (SSL_CERT_FILE, NODE_EXTRA_CA_CERTS, GIT_SSL_CAINFO, REQUESTS_CA_BUNDLE) at a bundle combining system roots, the daemon CA, and any authorities already configured by the operator or session variables.

Sessions connect to the proxy via HTTPS_PROXY. If a client ignores HTTPS_PROXY or pins its own certificates, it sends only the placeholder directly to the code host or provider and gets rejected.

For operators:

  • Egress: Because the daemon makes the upstream request, it needs outbound HTTPS access to every code host and provider endpoint its agents use. On Kubernetes, this applies to the daemon pool, not the agent pods.
  • Private authorities: The proxy verifies upstream TLS using the daemon's trust roots and any authorities configured for the daemon.
  • Outbound proxy: If the daemon itself uses HTTPS_PROXY to reach the internet, the credential proxy routes upstream requests through it too and respects NO_PROXY.

Protection by runtime

The rest of this page covers logins saved on a self-hosted Linux daemon. Protection depends on the runtime and login method, and works the same way in srt and microsandbox.

RuntimeOAuthAPI key
Claude CodeTool rulesProxy
CodexTool rulesProxy
DeepSeek HarnessNAProxy
OpenCodeUnshieldedProxy
piUnshieldedProxy
Grok BuildUnshieldedProxy
Qwen CodeUnshieldedProxy
Oh My PiUnshieldedProxy
AmpNAProxy
Kimi CodeUnshieldedProxy
ClineUnshieldedProxy
DevinUnshieldedNA
Antigravity ACPUnshieldedProxy
GitHub CopilotUnshieldedProxy
Qoder CLIUnshieldedUnshielded
Qoder CN CLIUnshieldedUnshielded
  • Tool rules: The runtime blocks its built-in tools from reading or modifying protected credential files.
  • Proxy: The real API key stays on the host (supported sources listed below).
  • Unshielded: Tools inside the sandbox can read the credential directly.
  • NA: This login method isn't covered by the integration.

Claude Code and Codex also keep their tool rules active when using the API proxy.

OAuth and tool rules

OAuth credentials are mounted or copied into the session so the runtime can handle authentication and token refresh.

Claude Code and Codex enforce the same tool rules in both SRT and microsandbox. Claude Code restricts Bash and its file tools (including Read and Edit), while Codex uses permission profiles to block tool access to credential paths. The runtime itself can still read its credentials to authenticate.

These rules only cover the runtime's integrated tools, not arbitrary helper processes or MCP servers. Other runtimes receive OAuth credentials without extra tool restrictions.

API key proxy

For supported logins, the daemon passes a placeholder to the session instead of the real API key. The host proxy swaps in the real key in outgoing request headers, and only for the provider's approved HTTPS endpoint.

In both srt and microsandbox, this covers every saved key in the table below, plus keys set in the daemon's environment or runtime definition: ANTHROPIC_API_KEY for Claude Code, OPENAI_API_KEY for Codex, DEEPSEEK_API_KEY for DeepSeek Harness, and the keys for GitHub Copilot and Antigravity ACP. In srt, it also covers those environment variables for OpenCode.

Credential files imported into the sandbox contain only placeholders. For Oh My Pi, the daemon builds a private SQLite database with placeholders before writing any API-key records. The host's login files aren't modified.

The proxy reads provider settings from the host, so editing configuration inside the sandbox can't redirect a key to another destination. The authorized provider receives the real key, and its responses aren't redacted.

Supported saved keys

RuntimeKey source
Claude CodeprimaryApiKey in the active global configuration
CodexOPENAI_API_KEY in CODEX_HOME/auth.json
DeepSeek HarnessStandard DEEPSEEK_API_KEY entry in .dsh/.credentials.yaml or .dsh/.env
OpenCodeAPI records in auth.json (type: api)
piAPI records in auth.json, or provider keys in models.json
Grok BuildPer-model keys in config.toml (model.<id>.api_key)
Qwen CodeModel-provider keys in settings.json (including legacy security.auth.apiKey)
Oh My PiAPI-key records in agent.db
AmpNative CLI entries in secrets.json (apiKey@<service URL>)
Kimi CodeProvider keys in .kimi-code/config.toml (providers.<name>.api_key)
ClineProvider API keys in providers.json (apiKey or auth.apiKey)
GitHub CopilotCOPILOT_PROVIDER_API_KEY, sent to COPILOT_PROVIDER_BASE_URL
Antigravity ACPGEMINI_API_KEY (the gemini-api-key sign-in method)

Provider limits

  • DeepSeek uses https://api.deepseek.com and rejects custom endpoints at startup.
  • Grok, Qwen, and Kimi Code require an explicit HTTPS endpoint in host configuration (for Kimi Code, the provider's base_url).
  • Claude Code, Codex, OpenCode, and pi use supported host provider settings or built-in defaults. Custom Codex providers must set requires_openai_auth = true.
  • Oh My Pi uses built-in provider defaults.
  • pi, Oh My Pi, and Cline support the default endpoints for Anthropic, OpenAI, DeepSeek, Google, xAI, OpenRouter, Groq, and Mistral. Other Cline providers require an HTTPS baseUrl in the provider entry.
  • GitHub Copilot requires an HTTPS COPILOT_PROVIDER_BASE_URL.
  • Antigravity ACP uses the Gemini API, or GOOGLE_GEMINI_BASE_URL if set to an HTTPS endpoint.

If a recognized API key has no supported route, it stays hidden and that provider won't be available (for OpenCode, other configured providers continue working).

Protection only applies to the saved sources listed above. It doesn't automatically cover OS keyrings, command-based keys, arbitrary headers, custom plugins, or new logins created inside the sandbox. It also excludes Amp's separate amp-acp/credentials.json login, Oh My Pi keys stored only in custom model files, Cline's AWS credentials and custom headers, and Kimi Code providers that read their key from an environment variable (api_key_env).

Qoder CLI and Qoder CN CLI keys aren't proxied: personal access tokens are exchanged in the request body, and service account keys require a format that a placeholder can't satisfy. Devin signs in through a browser and has no separate API key login.

Supported endpoints must use HTTPS without custom ports or embedded URL credentials. Protected sessions reject custom TLS trust overrides and conflicting credential mounts.

Existing sessions and key changes

A protected VM reloads an updated host key the next time it resumes after stopping; a running VM keeps its current key. Changing login accounts, provider records, or credential layout can trigger a VM rebuild (see what is preserved).

How is this guide?

On this page

How is this guide?