API Configuration
These environment variables are required for authenticating with AI providers.API key for Anthropic Claude models.You can also use the OAuth configuration flow:
API key for OpenAI GPT models.
API key for OpenRouter service.
Custom API Key Suffixes
You can use multiple API keys by adding suffixes:Behavior Control
Override the maximum number of conversation steps an agent can take.
Default: 1000This prevents infinite loops and controls agent execution time.
Context Management
Enable or disable automatic context compaction when approaching model limits.
Default: true (enabled)When enabled, AgentUse automatically compacts older messages when context approaches the model’s token limit.
Percentage of context limit to trigger compaction.
Default: 0.7 (70%)Must be a decimal between 0 and 1.
Number of recent messages to preserve during compaction.
Default: 3These messages are never compacted to maintain conversation flow.
Logging and Debug
Set the logging level for AgentUse output.
Default: INFOControls which messages are displayed during execution.
Enable debug logging and verbose output.
Default: falseShows detailed execution information, tool calls, and internal state.
Development Variables
For local development with self-signed certificates (HTTPS testing).
Never use this in production. It disables SSL certificate verification.
MCP Server Environment Variables
Security by Design: AgentUse intentionally prevents hardcoding secrets in
.agentuse
files. All sensitive values must come from environment variables, keeping your secrets secure and out of version control.The Security Model
MCP servers can access environment variables through two fields:requiredEnvVars
: Variables that MUST exist or the agent fails immediatelyallowedEnvVars
: Variables that are passed through if they exist (optional)
Why This Design?
- No Secrets in Code:
.agentuse
files are often committed to version control - Clear Requirements: Developers know exactly what env vars are needed
- Early Failure: Missing required vars fail fast with clear error messages
- Security Allowlist: Only explicitly allowed vars are passed to MCP servers
Setting Environment Variables
- Option 1: .env File (Recommended)
- Option 2: Shell Export
- Option 3: Inline Command
- Option 4: Secret Managers
Create a AgentUse automatically loads
.env
file in your project root:.env
files from the project root (detected via .git/
, .agentuse/
, or package.json
).Override Options:Add
.env
to your .gitignore
to prevent committing secrets!Error Messages
AgentUse provides clear, actionable error messages:Complete Example
.env
file:
Using .env Files
AgentUse automatically loads.env
files if present in your project directory:
Never commit
.env
files to version control. Add them to .gitignore
.Priority Order
Environment variables are loaded in this order (later overrides earlier):- System environment variables
.env
file in current directory- Command-line environment variables
Security Best Practices
Store Secrets Securely
Never hardcode API keys in agent files:Use .gitignore
Always exclude sensitive files:Validate Required Variables
For MCP servers that require specific environment variables, they will fail with clear error messages if the variables are not set.Troubleshooting
API key not found
API key not found
Verify the environment variable is set:If empty, set it:Or use the auth command:
Wrong API key being used
Wrong API key being used
Check which key is being used:The tool prioritizes OAuth tokens over API keys for Anthropic.
MAX_STEPS not working
MAX_STEPS not working
Ensure you’re setting it before running the agent: