Backpack is a secure, portable system for managing AI agents with encrypted state, credentials, and personality configurations. It solves the "Naked Agent" problem by providing a unified container format that travels with your agent code in version control.
| Pain point | Without Backpack | With Backpack |
|---|---|---|
| Credentials | Scattered in .env, dashboards, or copy-paste |
One vault; JIT injection with one prompt per key |
| Sharing agents | "Clone repo, then manually add keys and config" | Clone β backpack run agent.py β allow keys when prompted |
| Personality/config | Hardcoded or random config files | Version-controlled in agent.lock with the code |
| Secrets on disk | .env or config in plain text |
Keys only in OS keychain; never plain text in repo |
| Cloud Deployment | Manual env var setup per service | Automated via Master Key & Encrypted Portability |
| Time to first run | Find keys, create .env, restart |
backpack quickstart β add keys β run in minutes |
pip install backpack-agent
backpack quickstart # Interactive wizard: name, credentials, personality
backpack key add OPENAI_API_KEY # Add your keys when prompted
backpack run agent.py # Run with JIT injectionOr use a ready-made template:
backpack template list
backpack template use financial_analyst
backpack key add OPENAI_API_KEY
backpack run agent.pySee Quick Start below for more options.
- Why Backpack?
- Quick Start (3 steps)
- The Problem
- The Solution
- Features
- Installation
- Quick Start
- Templates & Examples
- Project Structure
- Architecture
- Documentation
- Security
- Contributing
Right now, an agent is just code. It has no state and no keys until a developer manually injects them.
- Code: Public (GitHub)
- Secrets: Private (Scattered in
.envor cloud dashboards) - Memory: Private (Stuck in a specific vector database)
This creates friction when sharing agents, managing credentials, and maintaining state across environments.
Backpack creates an agent.lock file that travels with the agent's code in the git repo. This file contains three distinct encrypted "variable" layers:
Content: Placeholders for OPENAI_API_KEY, TWITTER_TOKEN, etc.
Innovation: When a user clones the agent, the system sees the agent.lock. It checks the user's personal local keychain. If the user has a "Global OpenAI Key" saved, it automatically injects it into the agent's encrypted runtime. No manual .env setup required.
Content: "You are a senior financial analyst. Use a formal tone."
Innovation: These are variables that can be tweaked and version-controlled. A team can update the "Personality Variable" in Git, and everyone's local agent updates instantly upon git pull.
Content: User ID, Session History, last tool output.
Innovation: Local-first memory. The agent writes its "short-term memory" to an encrypted local file. This means you can stop an agent on your laptop, commit the encrypted state, push it to a server, and the agent resumes exactly where it left off.
- π Encrypted State Management: All agent data is encrypted using PBKDF2 and Fernet
- βοΈ Cloud Ready: Seamless deployment to Vercel/Railway with Master Key support
- π OS Keychain Integration: Secure credential storage using platform-native keyrings
- π JIT Variable Injection: Just-in-time credential injection with user consent
- π¦ Portable Containers:
agent.lockfiles travel with your code in version control - π§ Version-Controlled Personality: System prompts and configuration in Git
- πΎ Ephemeral Memory: Encrypted state that can be committed and shared
- π‘οΈ No Plain Text Secrets: Keys never written to disk in plain text
- Python 3.7+
- pip
pip install backpack-agentgit clone <repository-url>
cd backpack
pip install -e .backpack --helpOption A β Interactive wizard (fastest):
backpack quickstart
# Answer: agent name, credentials (e.g. OPENAI_API_KEY), personality
backpack key add OPENAI_API_KEY # and any other keys
backpack run agent.pyOption B β Manual init:
backpack key add OPENAI_API_KEY
backpack key add TWITTER_TOKEN
backpack init --credentials "OPENAI_API_KEY,TWITTER_TOKEN" --personality "You are a senior financial analyst. Use a formal tone."
backpack run example_agent.pyOption C β Use a template:
backpack template list
backpack template use financial_analyst # or twitter_bot, code_reviewer
backpack key add OPENAI_API_KEY
backpack run agent.pySee the value in 30 seconds:
backpack demoFor detailed usage, see USAGE.md.
Ready-made agents you can run immediately:
| Template | Description |
|---|---|
financial_analyst |
Formal, data-driven analyst persona; uses OPENAI_API_KEY |
twitter_bot |
Friendly Twitter bot; uses OPENAI_API_KEY, TWITTER_BEARER_TOKEN |
code_reviewer |
Constructive code review; uses OPENAI_API_KEY |
backpack template list
backpack template use <name>Each template includes a README and a runnable agent.py you can customize.
Backpack includes a comprehensive test suite using pytest.
Tests can run without installing the package (conftest.py adds src to PYTHONPATH):
# Install test dependencies
pip install -r requirements.txt
# Run all tests (no pip install -e . required)
pytest
# Run with coverage report
pytest --cov=src --cov-report=html
# Run specific test file
pytest tests/test_crypto.py
# Run with verbose output
pytest -vAlternatively, install in editable mode first: pip install -e .
Backpack uses Python's standard logging module:
- Library modules (
crypto,keychain,agent_lock) log at module level - The CLI configures a default logger when invoked
- Control verbosity with the
BACKPACK_LOG_LEVELenvironment variable (e.g.DEBUG,INFO,WARNING):
BACKPACK_LOG_LEVEL=DEBUG backpack run agent.pyNo secret values (keys, ciphertext, plaintext) are ever written to logs.
The test suite covers:
- β Encryption/decryption operations
- β Keychain storage and retrieval
- β Agent lock file management
- β CLI command execution
- β Error handling and edge cases
See htmlcov/index.html after running with coverage for detailed coverage reports.
backpack/
βββ example_agent.py # Example agent implementation
βββ requirements.txt # Python dependencies
βββ pytest.ini # Pytest configuration
βββ README.md # This file
βββ CONTRIBUTING.md # Contributing guidelines
βββ LICENSE # MIT License
βββ .gitignore # Git ignore rules
βββ docs/ # Documentation
β βββ api/ # API Reference
β βββ ARCHITECTURE.md # Architecture docs
β βββ USAGE.md # Usage guide
β βββ ...
βββ src/
β βββ backpack/
β βββ __init__.py
β βββ agent_lock.py
β βββ cli.py
β βββ crypto.py
β βββ exceptions.py
β βββ keychain.py
β βββ templates/
βββ tests/
βββ __init__.py # Test package initialization
βββ conftest.py # Pytest fixtures and configuration
βββ test_crypto.py # Encryption/decryption tests
βββ test_keychain.py # Keychain operation tests
βββ test_agent_lock.py # Agent lock file tests
βββ test_cli.py # CLI command tests
Backpack implements a three-layer encryption system:
- Credentials Layer: Stores placeholders for required API keys
- Personality Layer: Stores system prompts and agent configuration
- Memory Layer: Stores ephemeral agent state
All layers are encrypted using PBKDF2 key derivation and Fernet symmetric encryption. The master key can be set via the AGENT_MASTER_KEY environment variable.
For detailed architecture documentation, see ARCHITECTURE.md.
- USAGE.md: Detailed usage guide with examples
- ARCHITECTURE.md: System architecture and design decisions
- SECURITY.md: Security considerations and best practices
- CONTRIBUTING.md: Guidelines for contributing to the project
- PROJECT_ASSESSMENT.md: Comprehensive project assessment
- OPTIONAL_IMPROVEMENTS.md: List of optional future enhancements
- API Documentation: Detailed API reference
Backpack prioritizes security through:
- Encrypted storage of all agent data
- OS-native keychain integration
- No plain text secrets on disk
- User consent prompts for credential access
For detailed security information, see SECURITY.md.
This is where the "GitHub of Secret Management" thinking revolutionizes agents.
- Agent tries to run
- Agent crashes because
TWITTER_API_KEYis missing - User goes to Twitter Developer Portal, generates key, pastes into
.env - Restart
- Agent initializes
- It reads
agent.lockand sees it needsTWITTER_API_KEY - Intervention: Instead of crashing, the CLI pauses execution and prompts:
This agent requires access to Twitter. You have a Twitter key in your personal vault. Allow access? (Y/n) - Grant: User hits 'Y'. The CLI decrypts the key only into the agent's process memory
- The agent runs. The key is never written to disk in plain text
We welcome contributions! Please see CONTRIBUTING.md for guidelines on:
- Code style and standards
- Testing requirements
- Pull request process
- Development setup
This project is licensed under the MIT License - see the LICENSE file for details.
For a detailed assessment of the project's current state, strengths, gaps, and recommendations, see PROJECT_ASSESSMENT.md.
For issues, questions, or contributions, please open an issue on the repository.