VanaAPI

← Writing

Keep Secrets Out of Coding Agent Context

Agents at the terminalEN2026-10-24

Coding agents can read project files, run commands, and include tool output in model requests. A credential does not have to appear in your prompt to enter the conversation: a configuration dump, test failure, or debug log can expose it. This walkthrough separates the credentials your tools need from the information your coding agent can inspect.

§ 1. Map where secrets can enter context

Before starting an agent session, identify its working directory, inherited environment, available tools, and filesystem permissions. Include local integrations and connected services in that review.

  • Files: environment files, deployment configuration, database exports, notebooks, and saved terminal output.
  • Commands: environment dumps, verbose HTTP clients, diagnostic scripts, and application logs.
  • External sources: issue descriptions, support tickets, and documentation that may contain copied credentials.

Check the actual agent settings rather than assuming it sees only the files you explicitly attach.

§ 2. Replace real values with useful placeholders

Keep a sanitized configuration example in the repository. Show variable names, expected formats, and whether each value is required, but use obvious placeholders instead of working credentials. Describe secrets by purpose, such as “read-only staging database password.”

Store real values in an approved secret manager or protected runtime configuration outside the agent workspace. Exclude local secret files from version control, but remember that a Git ignore rule does not prevent an agent from reading them. Agent-specific exclusions can reduce accidental inclusion; they are not a substitute for filesystem permissions or sandboxing.

§ 3. Separate model access from project credentials

An agent client may need an API key to call its model provider. Your application may need entirely different credentials to run. Keep these roles separate, and do not place either credential in repository instructions or prompts.

Vana API provides one OpenAI-compatible endpoint and also supports Anthropic Messages and Gemini native protocols. When configuring a supported client such as Claude Code, Codex, or Gemini CLI, follow its documented credential configuration rather than asking the agent to write a live key into project files. Create a Vana API account if you want to use it for this setup.

Configuration location alone is not isolation. If the client passes its environment to shell tools, an agent may still be able to retrieve the key. Review that behavior and restrict the tool environment where supported.

§ 4. Give tools a secret-free execution boundary

Run agent-controlled commands in a dedicated container, sandbox, or restricted account. Mount only the project files the task requires. Leave credential directories, secret-manager sessions, and unrelated home-directory files outside that boundary.

Prefer an explicit allowlist of environment variables over inheriting your entire shell environment. For development tests, supply dummy values and local service substitutes. Verify that the agent cannot read host secrets through mounted paths or access privileged container sockets.

§ 5. Move credentialed operations behind a narrow interface

When a task genuinely requires a live service, use a separate process or trusted runner that holds the credential. Let the agent request a bounded operation, such as running one staging smoke test, rather than receiving the credential itself.

Return only the result needed for debugging: status, sanitized error details, and a request identifier. Avoid interfaces that accept arbitrary commands, arbitrary destination URLs, or unrestricted headers. Otherwise, the agent may be able to redirect an authenticated request or extract sensitive responses. Require human approval for sensitive operations and use short-lived, least-privilege credentials.

§ 6. Check outputs before they reach the agent

Disable unnecessary request tracing and redact authorization headers, cookies, connection strings, and sensitive response fields at the source. Inspect test reporters and failure handlers: they often print configuration when something breaks.

Run secret scanning on repository changes and generated artifacts. Treat it as a backstop, not proof of safety; scanners can miss unfamiliar token formats. Test your controls with a distinctive fake secret and confirm that files, logs, and tool responses do not expose it.

§ 7. Prepare for accidental exposure

If a real credential enters agent context, stop the workflow and revoke or rotate it. Review relevant access logs, remove exposed copies where possible, and check stored transcripts or shared artifacts under your retention policy. Deleting a local message does not revoke a credential.

The practical goal is simple: let the agent understand configuration and request approved operations without giving it the secret values that authorize them.