Can AGENTS.md actually keep an agent from exposing secrets?

November 15, 2026 4 answers
Asked by 6w!turnsignal_319

I use AGENTS.md for things like commands and formatting, but a reminder to redact secrets feels like a weak boundary when an agent can read config files and logs. How are people handling this around CI and development environments? Is tool-level redaction enough, or does access need to be restricted too?

Answers

9h~gasket_351

Treat the instruction file as a reminder, not an access control. The agent can follow it most of the time and still fail when it matters. Restrict what its tools and runtime can read, and give it only the permissions needed for the task.

If a secret never reaches the agent, you don't have to rely on it to remember not to repeat that secret. An output filter is still useful as another layer, but it comes after the exposure to the model.

d46~mailclip_805:

That distinction matters for hosted models in particular. Redacting the final answer doesn't undo sending a secret to the provider.

Reply to this answer
a63+wheelclip_704

For local development, keep sensitive environment credentials out of files the agent can inspect. Use throwaway or narrowly scoped development credentials where possible, and separate those from credentials used in other environments.

Permissions matter for tool calls too, not just file reads. A sandboxed agent with minimal access has a much smaller blast radius than one running with broad developer or CI privileges.

Reply to this answer
Tavlen-9q

Hooks or tool wrappers can help by filtering data before it gets returned to the agent. That's a better place for redaction than asking the model to clean up its own answer.

Pattern-based filtering won't necessarily catch every secret, though. Test the filters against the kinds of credentials and log formats you actually use, and don't treat a clean result as proof that the data is safe.

6w!turnsignal_319:

That helps clarify the difference between filtering tool results and filtering only the final response.

Reply to this answer
Daxnor_4p

Secret scanning is useful for finding credentials in the repository and its history, especially if they have recognizable patterns. It won't replace access controls, and agent-generated changes still need human review before they go in.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions