What counts as a secret
Your weather agent needs two things it shouldn't print or share: an API key for the forecast service, and the key it uses to send email. If someone else gets them, they can use your account and run up your bill.
A good rule: if it would let a stranger act as you, it's a secret. Your city name isn't. Your OPENWEATHER_API_KEY is.
How keys leak
Most leaks aren't hacks. They happen when a key is typed straight into the code:
API_KEY = "sk_live_4f9a..." # now in every copy of this fileThen the file gets pasted into a chat, pushed to GitHub, or zipped and sent to a friend, and the key goes with it.
Use a .env file
Put secrets in a file called .env next to your code, one per line:
OPENWEATHER_API_KEY=your-key-here
[email protected]Then tell git to ignore it, so it never ends up in your repository:
.envRead it from Python
Your code asks for the value by name instead of containing it:
import os
from dotenv import load_dotenv
load_dotenv() # reads .env when you run locally
api_key = os.environ["OPENWEATHER_API_KEY"]On Thinkmon
When your assistant uploads your agent, the deployment instruction tells it to leave .env and credential files behind. Thinkmon then lists the names your code reads, such as OPENWEATHER_API_KEY, and you enter the values in the dashboard.
Saved values are never shown again on screen. Your code reads them exactly as it did locally, through os.environ.
Host the agent you just cleaned up. It starts paused, so nothing runs until you check it.