agentsafe
Agent Safe agentsafe is a Python library and CLI for storing application configuration
values—API keys, access tokens, passwords, and connection strings—as KMS-backed
ciphertext. It never generates, stores, or manages encryption key material.
Every encryption and decryption operation is delegated to a customer-managed
Oracle Cloud Infrastructure (OCI) KMS key.
The PyPI distribution is named agentconfigsafe; Python imports and the CLI
are named agentsafe.
Why use it?
Applications often need sensitive configuration but should not keep it in
source control, plaintext .env files, or application configuration files.
agentsafe keeps encrypted values in project-local files — a JSON appconfig
store, a standard-shaped .env file, or both — while leaving encryption
authority with the customer's OCI KMS key and IAM policies.
Common uses include:
- API keys for LLM, SaaS, or third-party integrations used by AI agents.
- Database connection strings, webhook secrets, and service credentials.
- Teams that want their encrypted secrets and KMS settings checked into git and shared, so a fresh clone has everything it needs except each developer's own local OCI credentials.
- Setup scripts that configure a secret once, followed by runtime SDK reads.
Security model
- Plaintext values are encrypted through OCI KMS before they reach
appconfigor.env. appconfigand.envcontain ciphertext envelopes and provider metadata only; neither ever contains plaintext values, OCI credentials, or key material.- OCI KMS configuration is stored separately in the project-local
.agentsafe/configfile, not inappconfig/.env. Unlike ciphertext, these are identifiers (a key OCID, a crypto endpoint URL, a profile name) — safe to commit alongside the ciphertext they route to, since OCI itself never treats an OCID or endpoint as a secret. get()decrypts in memory only for the duration of the call (or, forenv.load(), until it populatesos.environ). Values are not otherwise cached byagentsafe.listandenv listreturn names only and never call KMS Decrypt.agentsaferelies on OCI's standard profile configuration and IAM. It does not implement a second authentication system..env.agentis the one place a developer types a real secret in the clear — it is never committed, andagentsafe env encryptwarns if it isn't gitignored. The compiled.envit produces is always fully encrypted.
Avoid placing real secrets directly in shell arguments: they can be exposed in
shell history and process listings. Prefer the hidden set prompt or piping
the value on stdin.
Install
Install the OCI provider extra in the application environment:
python -m pip install "agentconfigsafe[oci]"
You also need an OCI profile in ~/.oci/config, a vault crypto endpoint, and
a KMS key that the profile is allowed to use for Encrypt and Decrypt.
Quick start: CLI
Create the project-local KMS configuration. This writes OCI identifiers to
.agentsafe/config in the current directory; it does not create or modify
appconfig.
agentsafe init --profile DEFAULT \
--crypto-endpoint https://<vault>-crypto.kms.<region>.oraclecloud.com \
--key-id <key-ocid>
agentsafe config # displays the project KMS configuration; does not contact KMS
Store a value. Omitting the value opens a hidden prompt (or reads piped
stdin); the first set creates the local appconfig ciphertext store.
agentsafe set OPENAI_API_KEY
agentsafe get OPENAI_API_KEY
agentsafe list
agentsafe remove OPENAI_API_KEY
Use --path /path/to/appconfig with set, get, list, or remove when a
project's ciphertext store is not in the current directory.
.agentsafe/config and appconfig are both project-local and safe to commit
to git together — a teammate who clones the repo only needs their own OCI
profile locally (see "Security model") to decrypt.
.env support
A second, parallel store for teams whose other tooling (frameworks,
docker compose, CI systems) already auto-loads a .env file. It uses the
same KMS-backed encryption and the same .agentsafe/config settings as
appconfig — just persisted as KEY=value lines instead of JSON.
Write real values into .env.agent (plaintext, gitignored, never
committed), then compile it into a fully-encrypted, git-committable .env:
echo 'OPENAI_API_KEY=sk-...' >> .env.agent
agentsafe env encrypt
.env now holds OPENAI_API_KEY="agentsafe:v1:<base64 ciphertext envelope>"
— safe to commit. agentsafe env encrypt always fully regenerates .env
from .env.agent; .env is a derived artifact and shouldn't be hand-edited.
Single-entry equivalents of set/get/remove/list are also available:
agentsafe env set OPENAI_API_KEY
agentsafe env get OPENAI_API_KEY
agentsafe env list
agentsafe env remove OPENAI_API_KEY
From Python, decrypt everything into os.environ (like dotenv.load_dotenv()),
or fetch one value at a time:
from agentsafe import env
env.load() # decrypts every .env entry into os.environ
api_key = env.get("OPENAI_API_KEY") # decrypts one value without touching os.environ
There is deliberately no CLI command that decrypts everything to stdout —
consume decrypted values via env.load()/env.get() in your application,
not by piping a CLI dump.
Python SDK
from pathlib import Path
from agentsafe import AgentSafe, AgentSafeError
safe = AgentSafe(Path("/srv/billing/appconfig"))
try:
api_key = safe.get("OPENAI_API_KEY")
except AgentSafeError as error:
# Covers a missing key (KeyNotFoundError), a project that hasn't been
# initialized or has no appconfig yet (ConfigError), and KMS auth/access
# failures (KMSError) — catch the common base class so none of them
# surface as a raw traceback.
raise RuntimeError(f"could not read OPENAI_API_KEY: {error}") from None
# Pass api_key directly to the consuming client. Do not log or persist it.
For initial provisioning from Python, register the project's KMS settings first:
from agentsafe import AgentSafe
AgentSafe.init(
profile="DEFAULT",
crypto_endpoint="https://example-crypto.kms.us-phoenix-1.oraclecloud.com",
key_id="ocid1.key.oc1..example",
)
Settings resolve in this order: explicit SDK/CLI arguments, AGENTSAFE_*
environment variables, then the project-local .agentsafe/config file. OCI
is the default provider; OCI requires a profile, crypto endpoint, and key
OCID — no compartment, since OCI's Encrypt/Decrypt API doesn't take one.
profile is the one setting that legitimately
varies per developer (it names a profile in their ~/.oci/config) — set
AGENTSAFE_PROFILE locally if it differs from what's committed.
Examples
See examples/README.md for two runnable examples: one
initializes a project-local configuration, stores a non-sensitive validation
value in appconfig, and reads it back through OCI KMS; the other does the
same round trip through the .env/.env.agent store.
Current scope
OCI KMS is the bundled provider in this release. The provider architecture uses Python entry points so additional customer-managed KMS backends can be added without changing the storage or SDK layers. Key rotation and cloud resource creation are intentionally outside the current scope.
Metadata
Release files for agentconfigsafe 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agentconfigsafe-0.2.0.tar.gz | 30.3 kB | With provenance | Details for agentconfigsafe-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentconfigsafe-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for agentconfigsafe-0.2.0-py3-none-any.whl |
Total release size: 48.6 kB
Release files / agentconfigsafe-0.2.0.tar.gz
| Download URL | agentconfigsafe-0.2.0.tar.gz |
|---|---|
| Size | 30.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86cfbc1462139b85a4e9f7ea3e337c0f4b9be3fa27cbeea534779f2f0a3991ca
|
|
BLAKE2b-256 checksum How to use checksums |
382ad47bf1c74d8b0f8208dd9da71574ce7359bd6de9f9679da0eef07f572c43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / agentconfigsafe-0.2.0-py3-none-any.whl
| Download URL | agentconfigsafe-0.2.0-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a468d5834793ceb24683dc24a90ac11ff0c32a05e5d8aa32c3aec74b3f713ab1
|
|
BLAKE2b-256 checksum How to use checksums |
e453ff34e931879c687c41898e41c47fcf670cb28a9268642cf43ae3d4b6e449
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logSecurity for agentconfigsafe 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for agentconfigsafe-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.