Environment Variables
Polygent has two levels of environment variables:
- App-level — passed to the API/Agent processes themselves. Used to override
appsettings.jsonvalues. - Workspace-level — managed in the Settings UI and injected into every session that runs in a workspace.
App-Level
App-level variables come from the operating system / service environment that hosts the API or Agent. They override matching keys in appsettings.json using __ (double underscore) as the section separator.
# Override the database connection string
Database__ConnectionString="Host=db;Database=polygent;Username=polygent;Password=secret"
Database__Provider="PostgreSql"
# Override the storage path
StoragePath="/var/lib/polygent"
# Override the bind URL (ASP.NET Core convention)
Urls="http://0.0.0.0:5000"
# OAuth credentials (recommended over committing to appsettings.json)
Login__LoginType="Google"
Login__ClientId="..."
Login__ClientSecret="..."
Login__ClientUrl="https://polygent.example.com"
# Microsoft tenant (Microsoft only)
Login__TenantId="common"
# Public URLs advertised to clients / MCP consumers
ClientUrl="https://polygent.example.com"
McpUrl="https://polygent.example.com/mcp"
# Local in-process session host
LocalHost__Enabled="true"
LocalHost__MaxConcurrentSessions="16"
# Ticket sync interval (minutes) and ready-for-QA summary toggle
Tickets__SyncIntervalMinutes="15"
Tickets__EnableReadyForQaSummary="false"
# Merge conflict tuning
MergeWorktreePrefix="merge"
MergeAiTimeoutSeconds="1800"
# Log level (only the Default key is applied at runtime)
Logging__LogLevel__Default="Information"
This is the recommended path for secrets in container and Windows-Service deployments — keep appsettings.json checked-in-safe and inject credentials via the environment.
App-Level Reference
| Env var | appsettings.json path | Purpose |
|---|---|---|
Database__Provider | Database:Provider | Sqlite / SqlServer / PostgreSql |
Database__ConnectionString | Database:ConnectionString | Provider-specific connection string |
StoragePath | StoragePath | Root directory for keys, logs, worktrees, DB |
ClientUrl | ClientUrl | Public client URL (overrides Settings UI value) |
McpUrl | McpUrl | Public MCP endpoint URL |
Login__LoginType | Login:LoginType | Google, Microsoft, or OpenIdConnect |
Login__ClientId / ClientSecret | Login:ClientId / Login:ClientSecret | OAuth provider credentials |
Login__TenantId | Login:TenantId | Microsoft tenant (common or specific GUID) |
Login__ClientUrl | Login:ClientUrl | OAuth redirect base URL |
Login__EnableTestLogin | Login:EnableTestLogin | Bypass OAuth for testing — never enable in production |
Login__EnableSeamlessSso | Login:EnableSeamlessSso | Suppress OAuth account picker |
Login__AllowNewUsers | Login:AllowNewUsers | Allow first-time users to auto-register |
Login__AccessTokenMinutesLifetime | Login:AccessTokenMinutesLifetime | JWT TTL (minutes) |
Login__RefreshTokenDaysLifetime | Login:RefreshTokenDaysLifetime | Refresh token TTL (days) |
Tickets__SyncIntervalMinutes | Tickets:SyncIntervalMinutes | External ticket sync poll interval |
Tickets__EnableReadyForQaSummary | Tickets:EnableReadyForQaSummary | Generate AI summary when entering QA stage |
LocalHost__Enabled | LocalHost:Enabled | In-process session host on/off |
LocalHost__MaxConcurrentSessions | LocalHost:MaxConcurrentSessions | Per-host concurrent session cap (default 16) |
MergeWorktreePrefix | MergeWorktreePrefix | Merge worktree directory prefix |
MergeAiTimeoutSeconds | MergeAiTimeoutSeconds | AI conflict resolution timeout |
Logging__LogLevel__Default | Logging:LogLevel:Default | Minimum log level (only this key is applied at runtime) |
Workspace-Level
Workspace environment variables are managed in the Settings UI and injected into every session, hook, task, and provider CLI invocation that runs inside the workspace. They apply uniformly to both local and remote session agents — the variables travel with each user message over the same channel that carries the message itself, so a remote agent worker sees the same environment as an in-process one.
Configure
- Open your workspace
- Open Settings → Environment Variables
- Add key-value pairs
- Use Import / Export to move sets of variables between workspaces or dump them to JSON for backup
Common Workspace Variables
| Variable | Purpose |
|---|---|
ANTHROPIC_API_KEY | API key for Claude Code |
GEMINI_API_KEY | API key for Gemini CLI |
OPENAI_API_KEY | API key for Codex / OpenCode (when using OpenAI) |
QWEN_API_KEY | API key for Qwen Code |
| Project secrets (DB URL, build flags, etc.) | Passed to scripts and tasks during sessions |
Provider CLIs read their own credentials from the environment; setting them at the workspace level is the cleanest way to scope keys per project.
Per-User Environment Values (TFS PAT)
Azure DevOps / TFS access uses a per-user, per-workspace PAT stored under the user's Profile. Unlike workspace env vars, these are not visible to other workspace members. Encrypted at rest, max 500 chars. See the Tickets sync guide.
Security
- Workspace env vars are encrypted at rest
- Variables are scoped to the workspace they belong to and never injected into sessions in other workspaces
- Polygent never logs variable values
- Prefer environment variables (or per-user PATs) over inline secrets in prompts, scripts, or commit messages
Variable Resolution Order
When an agent process starts, environment variables resolve in this order (later wins):
- The host's OS environment (where the API or session-agent worker runs)
- App-level overrides from
appsettings.json/ launch environment - Provider defaults applied for the selected agent
- Workspace environment variables (override any of the above)
- Provider-managed internal variables — these always win so each provider's configuration contract with its CLI is preserved
Workflow init parameters that reference $env:VAR_NAME resolve against the merged workspace environment at workflow-build time and are baked into the resulting prompt, separately from the process-level injection above.
See Also
- Authentication —
Loginsection keys - Database —
Database__ConnectionString/Database__Provider - Storage —
StoragePath - Global Settings — runtime UI settings (separate from
appsettings.json)