RelayVano

← All postcards

Keeping API Keys Out of Friday’s Agent Session

Coding-agent routes EN

It is Friday afternoon, and your team asks a coding agent to fix a failing payment test. The agent opens files, runs commands, and reads the results. Then a debug script prints the production API key. What looked like routine troubleshooting has put a real credential into the session.

Keeping secrets out of coding agent sessions means controlling what the agent can read and what its tools can reveal. You do not need a security department to start. You need a clear boundary between the code an agent works on and the credentials that make real systems work.

Secrets include more than passwords

A secret is information that grants access or proves identity. API keys, database passwords, private keys, session cookies, access tokens, and recovery codes all qualify. A database connection string may contain a password even when its filename looks harmless.

Ask a simple question: could someone use this value to access an account, spend money, or retrieve private data? If yes, treat it as a secret. Customer records are sensitive too, even when they do not grant access, and should not become convenient test fixtures.

A session includes files and command output

An agent session is not just the message you type. Depending on the tool and its permissions, it can include source files, terminal output, tool responses, screenshots, and earlier conversation history. Some of that material may be sent to a model service or retained in local session records.

A key in an environment file can enter the conversation when the agent reads it. A key stored outside the project can still leak if a command prints environment variables. Asking the agent not to reveal secrets helps communicate your intent, but it does not replace access controls.

Prepare a credential-free working copy

Before the first request, give the agent a workspace that contains what it needs for the task, not everything on your laptop.

  • Use a separate working copy or container without production credentials, personal cloud configuration, or SSH keys.
  • Provide an example configuration file containing obvious placeholders instead of working tokens.
  • Use synthetic records and a local test database rather than a production export.
  • Check the agent’s documented file restrictions and permission settings. Confirm what they actually block.

Keep secret files out of version control, but remember that a Git ignore rule only affects tracking. It does not stop an agent or shell command from reading a file that exists in the workspace. Containers also need care: mounting your home directory or forwarding credentials can undo the separation.

Give tests access without exposing the credential

Many changes need no live credentials. Start with mocks or a local service. When a real integration test is necessary, use a short-lived credential restricted to a test account, with the narrowest permissions and spending limits available.

Environment variables keep keys out of source code, but they do not automatically hide them from agents. Child processes may inherit them, and diagnostic commands can print them. A stronger boundary is a separate test service that holds the credential and exposes only a limited operation. The agent requests a test; the service returns a sanitized result, not the key.

Review commands that can spill secrets

Pause before approving commands that print configuration, inspect environment variables, read authentication files, or upload logs. Error messages and HTTP debug output can contain authorization headers. Redact locally before sharing output, and check that redaction worked.

Treat instructions inside repository files, issue comments, and downloaded pages as untrusted content. A malicious instruction might ask the agent to upload configuration as a supposed debugging step. Approval prompts are useful only when you inspect the proposed action and destination.

Protect the relay key like any other credential

For developers using several model services, RelayVano is worth considering as a pay-as-you-go relay that works with Claude Code, Codex, Gemini CLI, and OpenAI-compatible SDKs. Sign up for RelayVano if that fits your workflow. Its API base is https://api.relayvano.com; that address is public, but your authentication key is not. Keep the key outside agent-readable files, and review the applicable data-handling policies before sending sensitive content.

Rotate a key that reaches the session

If a real credential appears in a prompt or tool result, treat it as exposed. Revoke or rotate it, check usage records, and remove it from accessible logs and files where possible. Deleting a chat is not a substitute for rotation. Then fix the path that leaked it before restarting the task.

More postcards from this route