Environment Variables

May 20, 2026 ยท View on GitHub

This reference lists environment variables read by the current repository code. Flags and config files can override several of these values; command help remains the closest executable reference.

Repository-Wide

VariableUsed byDefaultNotes
PG_DSNcg service run, cg admission run, cg setup project, database setup scripts, demo scriptsNonePostgreSQL DSN. Required for database-backed service, setup, admission, and full tests.
CG_BASE_URLCLI clients, Admin Service runner, NanoBot runtimes, demo scriptshttp://127.0.0.1:8000 where a default is providedCommonGround Service base URL.
CG_PROJECT_IDAdmin Service runner, NanoBot runtimes, demo scriptscg-demo in local Admin/demo paths; required by NanoBot runtime entrypointsProject namespace.

CommonGround Service

Read by CommonGround/service/config.py through ServiceConfig.from_env().

VariableDefaultNotes
CG_HOST127.0.0.1Bind host for cg service run.
CG_PORT8000Bind port.
CG_LOG_LEVELinfoUvicorn/service log level.
CG_SERVICE_NAMEcommonground-v3-serviceService name in runtime settings.
CG_CLAIM_TIMEOUT_SECONDS30Claim lease timeout.
CG_CLAIM_REAPER_INTERVAL_SECONDS0Claim reaper interval.
PG_DSNNoneRequired for PostgreSQL-backed service.
CG_AGENT_PROJECT_HEADERX-CG-Project-IdHeader name used for Agent project identity.
CG_AGENT_ID_HEADERX-CG-Agent-IdHeader name used for Agent id identity.

CLI Client

Read by CommonGround/cli.py, CommonGround/cli_config.py, and CommonGround/cli_profiles.py.

VariableDefaultNotes
CG_CONFIG_PATH~/.config/commonground/config.json when present or when writingCLI JSON config path. Flags take precedence.
CG_BASE_URLhttp://127.0.0.1:8000CommonGround Service URL.
CG_AGENT_CREDENTIAL_TOKENNoneDirect AgentCredential bearer token for CommonGround requests.
CG_AGENT_CREDENTIAL_TOKEN_FILENoneFile containing AgentCredential token. File permissions must be 0600.
CG_CALLER_PROJECT_IDNoneCaller project id when identity is not inferred from command arguments or profile.
CG_CALLER_AGENT_IDNoneCaller agent id; must pair with caller project id.
CG_ADMIN_BASE_URLNone for general CLI, http://127.0.0.1:8001 in setup client-config defaultsAdmin Service URL for profile bootstrap.
CG_ADMIN_AUTH_TOKENNoneDirect Admin Service API bearer token.
CG_ADMIN_AUTH_TOKEN_FILEDefault setup path for local admission/setup flows; none for generic CLI unless config or env supplies itFile containing Admin Service API bearer token. File permissions must be 0600.
PG_DSNNoneUsed by cg setup project seed/status; required unless --pg-dsn is passed.

cg worker claim run also injects these variables into the child process:

VariableMeaning
CG_PROJECT_IDClaimed turn project id.
CG_TURN_IDClaimed turn id.
CG_AGENT_IDClaiming Agent id.
CG_CLAIM_FILEPath to JSON claim file.
CG_CONTEXT_FILEPath to JSON context file.
CG_CLAIM_TOKENJSON-serialized claim handle.

Admin Service Admission

Read by Integrations/admin_service/admission_runner.py and setup helpers.

VariableDefaultNotes
PG_DSNNoneRequired for cg admission run and project setup.
CG_BASE_URLhttp://127.0.0.1:8000CommonGround Service URL used by the Admin Service Agent.
CG_PROJECT_IDcg-demoProject admitted by the local Admin Service API.
CG_ADMIN_SERVICE_TOKEN_FILE~/.local/share/commonground/operator/projects/<project_id>/admin-service.cgacFile containing the Admin Service AgentCredential.
CG_ADMIN_AUTH_TOKEN_FILE~/.local/share/commonground/operator/projects/<project_id>/admin-api-bearer.tokenFile containing the Admin Service API bearer token.
CG_ADMIN_HOST127.0.0.1Bind host for cg admission run.
CG_ADMIN_PORT8001Bind port.
CG_ADMIN_INVITE_CONFIG_JSONNoneOptional invite config JSON for byoa.conversation_worker.v1.
CG_ADMIN_LOG_LEVELinfoUvicorn log level.

NanoBot Runtime

Read by Integrations/nanobot/runtime/* and provision handlers.

VariableUsed byDefaultNotes
CG_BASE_URLLeaf worker, self-root frontside, runtime clientshttp://127.0.0.1:8000CommonGround Service URL.
CG_PROJECT_IDLeaf worker, self-root frontside, demo configsRequired by runtime entrypointsProject id.
CG_AGENT_IDLeaf worker, self-root frontsideRequiredRuntime Agent id.
CG_AGENT_CREDENTIAL_TOKENLeaf worker, self-root frontside, runtime client auth, demo configsRequired by runtime clientsAgentCredential bearer token.
CG_AGENT_CREDENTIAL_TOKEN_FILEDemo NanoBot config fragmentsNonePassed through configs for runtimes that resolve token files outside the Python entrypoint.
CG_AGENT_REGISTRATION_SPECLeaf workerOptionalEncoded registration spec. When present, role, capabilities, grants, and accepts_work must match the registered leaf Agent.
CG_PROVISION_TURN_IDLeaf workerOptionalSource provision turn id passed to provisioned leaf workers.
NANOBOT_REPO_ROOTRuntime factory, leaf worker, provision launch envOptional; adjacent checkout is auto-detected only when presentOptional NanoBot source checkout used to override the installed nanobot package.
NANOBOT_CONFIG_PATHLeaf worker, demo configsOptionalNanoBot config file path.
NANOBOT_WORKSPACELeaf workerOptionalWorkspace path for the provisioned runtime.
CG_NANOBOT_LOG_LEVELRuntime factoryINFONanoBot runtime logging level.
CG_PROVISION_LIFECYCLE_CLEANUP_INTERVAL_SECONDSscripts/demo/run_nanobot_provisioner.py30.0Provision lifecycle cleanup interval for the demo provisioner.
CG_PROVISION_LIFECYCLE_TTL_SECONDSscripts/demo/run_nanobot_provisioner.pyNoneOptional provision lifecycle TTL for the demo provisioner.

Provision handlers may construct child runtime environments with CG_BASE_URL, CG_PROJECT_ID, CG_AGENT_ID, CG_AGENT_CREDENTIAL_TOKEN, CG_PROVISION_TURN_ID, NANOBOT_REPO_ROOT, NANOBOT_CONFIG_PATH, and NANOBOT_WORKSPACE. The process substrate removes CG_*CLAIM*TOKEN* variables before launching child processes.

Demo Scripts And Examples

Read by scripts under scripts/demo/ and configs under examples/nanobot/.

VariableDefaultNotes
CG_DEMO_LOG_LEVELINFODemo logging level in common demo helpers.
CG_HTTP_LOG_LEVELWARNINGHTTP library logging level in common demo helpers.
CG_FRONTSIDE_AGENT_IDfrontside in common demo helpersFrontside/requester Agent id for demos.
CG_NANOBOT_A_AGENT_IDnanobot_aDemo NanoBot A Agent id.
CG_NANOBOT_PROVISIONER_AGENT_IDnanobot_provisioner_alphaDemo provisioner Agent id.
NANOBOT_REQUESTER_WORKSPACE~/.nanobot-cg-requesterRequester workspace for demo helpers.
NANOBOT_A_WORKSPACE~/.nanobot-aNanoBot A workspace.
NANOBOT_LEAF_WORKSPACE~/.nanobot-leafLeaf workspace.
NANOBOT_PROVISIONER_WORKSPACE~/.nanobot-provisionerProvisioner workspace.
CG_BINRepository .venv/bin/cg in the cg-skill roundtrip demoOverride path to the cg executable for demo scripts.
CG_AUTH_TOKENNoneAllowed through scripts/demo/send_demo_request.py requester config; current cg CLI auth uses CG_AGENT_CREDENTIAL_TOKEN.
CG_AUTH_TOKEN_FILENoneAllowed through scripts/demo/send_demo_request.py requester config; current cg CLI auth uses CG_AGENT_CREDENTIAL_TOKEN_FILE.

Public docs and examples must use placeholders for DSNs, bearer tokens, provider API keys, and workstation-specific paths.