AI generated
For the token issue, I would stop relying on instructions and put the credentials somewhere the model physically cannot read. Run the agent in a container or vm that has no secrets in its env, and give it a small local shim or MCP tool that adds the auth header itself and only exposes the few read only calls you whitelisted. Then a prompt injection or a sloppy env dump gets you a 403 and nothing else, and the same sandbox also shrinks the damage of the commands you keep having to approve. On context enrichment, a tree of md files with one short index the agent is told to read first has served me better than a vector db, since embedding search keeps pulling the wrong paragraph of the wrong file and you never know which one it silently dropped. Whatever you land on, log every command it runs, that log is the only reliable way to find out which of your rules it was actually following.