KsADK

Environment Variables

This reference lists the environment variables most projects need when running KsADK locally or in a release pipeline. Use placeholders in committed files and put real values in local .env files or CI secrets.

Model Provider

OpenAI-compatible provider and hosted runtime model policy variables.

VariablePurpose
OPENAI_API_KEYAPI key for an OpenAI-compatible model provider
OPENAI_BASE_URLprovider base URL, usually ending in /v1
OPENAI_API_BASEcompatibility alias for OPENAI_BASE_URL
OPENAI_MODEL_NAMEdefault model name used by local runners and UI
AGENTENGINE_MODEL_POLICY_JSONmodel policy JSON injected by hosted runtimes to declare primary / multimodal / fallback defaults
OPENAI_FALLBACK_MODEL_NAMEcompatibility fallback model variable read by Hermes-style runtimes
HERMES_DEFAULT_MODELexplicit Hermes default model override
HERMES_FALLBACK_MODELexplicit Hermes fallback model override
HERMES_MODEL_CATALOG_JSONHermes model catalog JSON; overrides policy default catalog
OPENCLAW_DEFAULT_MODELexplicit OpenClaw default model override
OPENCLAW_FALLBACK_MODELexplicit OpenClaw fallback model override
OPENCLAW_IMAGE_MODELexplicit OpenClaw multimodal / image model override
OPENCLAW_MODEL_CATALOG_JSONOpenClaw model catalog JSON; overrides policy default catalog
MODEL_NAMEcompatibility alias used by some projects

Example:

bash
OPENAI_API_KEY=sk-test
OPENAI_BASE_URL=https://api.example.com/v1
OPENAI_MODEL_NAME=my-model

Codex and model proxy

VariablePurpose
KSADK_CODEX_APPROVALCodex approval policy; Studio can select it for the next turn
KSADK_CODEX_HOMEexplicit native Codex HOME override; normally isolated automatically
KSADK_CODEX_ISOLATE_HOMEdefaults to 1; set to 0 only when debugging with the process HOME
KSADK_CODEX_SANDBOXCodex sandbox mode: read_only, workspace_write, or full_access
KSADK_CODEX_USE_PROXY1 forces the local Codex protocol proxy and 0 forces direct mode; unset performs a conservative probe for custom upstreams only
KSADK_PROXY_UPSTREAM_BASECodex proxy upstream URL override; defaults to the OpenAI-compatible base URL
KSADK_PROXY_UPSTREAM_KEYCodex proxy upstream credential override (sensitive)
KSADK_PROXY_TOKENbearer token between the loopback proxy and Codex subprocess (sensitive; normally generated by the SDK)
KSADK_MODEL_PROXY_ENABLEDenables the experimental model protocol proxy; default 0
KSADK_MODEL_PROXY_AGENTScomma-separated agent allowlist
KSADK_MODEL_PROXY_MODELScomma-separated model allowlist
KSADK_MODEL_PROXY_DENYcomma-separated denylist for an emergency proxy disable
KSADK_STUDIO_NO_SECURITYcontrolled tests only; 1 disables the local session and CSRF checks
KSADK_STUDIO_SESSION_TOKENlocal Studio browser session token (sensitive; generated randomly when unset)
KSADK_STUDIO_TRACE_CONTENTpersist trace event content, default 1; set to 0 to retain metadata only

Runtime, A2A, and A2UI in 0.8

The following variables belong to 0.8 managed Runtime and A2A data-plane contracts. Variables marked “platform injected” are deployment inputs; users must not put them in .env or commit them.

Codex ManagedRuntime

VariableOwnerPurpose
AGENTENGINE_BASE_INSTRUCTIONSconsole / serverserver input used to write manifest prompt during declarative Codex creation; local web reads YAML directly.
AGENTENGINE_MANAGED_RUNTIME_NAMEplatform injectedRuntime name resolved by the catalog; image startup must match manifest runtime.name.
AGENTENGINE_MANAGED_RUNTIME_VERSIONplatform injectedRuntime version resolved by the catalog; the image also validates installed openai-codex.
AGENTENGINE_MANIFEST_PROTOCOLplatform injectedinline manifest protocol; currently runtime-manifest/v1.
AGENTENGINE_MANIFEST_SHA256platform injectedSHA-256 of normalized agentengine.yaml; checked at startup to prevent silent drift.

A2A Runtime

VariableOwnerPurpose
KSADK_A2A_SPACE_IDSplatform injectedJSON array of A2A Spaces configured for the Runtime; callers must select space_id explicitly when there is more than one.
KSADK_A2A_CONTROL_PLANE_URLplatform injectedA2A control-plane base URL; it does not fall back to the generic AgentEngine server URL.
KSADK_A2A_ENABLE_PUBLIC_EGRESSdeployment layerallows external_public; absence is fail-closed as false.
KSADK_A2A_EVENT_OUTBOX_PATHplatform / developerdurable A2A task-event outbox path; production should place it on a writable Runtime volume.
KSADK_A2A_TOKEN_DIRtoken sidecarprojected directory for audience workload JWTs; never create or commit these tokens yourself.

Hosted UI

VariableOwnerPurpose
KSADK_A2UI_GENERATION_TIMEOUT_SECONDSplatform / developerA2UI structured-generation timeout in seconds; valid range 1 through 120, default 20.

See A2A Runtime, Codex Managed Runtime, and Hosted UI and Event Replay for their protocol and runtime boundaries.

Unified Model Policy And Fallback (0.6.6+)

Hosted deployments can inject a shared policy through AGENTENGINE_MODEL_POLICY_JSON. Hermes, OpenClaw, and generic agents share one default semantics. In 0.6.6, model policy v1 defaults to glm-5.2 as the primary model, kimi-k2.7-code as the multimodal model, and deepseek-v4-pro as the fallback model. Explicit request fields and explicit environment-variable overrides (such as HERMES_DEFAULT_MODEL / OPENCLAW_FALLBACK_MODEL) still take precedence over policy defaults.

  • Fallback retry semantics: the conversation runtime automatically retries once with the fallback model on recoverable errors (timeout, rate limit, 5xx, model unavailable, permission/quota); 400 parameter errors, business errors, and tool errors are not swallowed.
  • Reasoning declaration (0.6.7): DEFAULT_MODEL_POLICY adds a reasoning: true declaration per model, and the catalog output exposes a reasoning field so the console can tell whether a model supports thinking.
  • Thinking-disable injection (0.6.7): when model_options.thinking is disabled (reasoning.effort=none, or thinking.type=disabled, or max_reasoning_tokens<=0), the runtime auto-injects enable_thinking=false and chat_template_kwargs.enable_thinking=false into extra_body (DeepSeek-style compatibility) and filters reasoning output items from the stream.

Project And Local UI

VariablePurpose
KSADK_PROJECT_DIRproject directory resolved by agentengine web
AGENTENGINE_UI_DIRlocal UI state directory; defaults under .agentengine/ui
KSADK_UI_PROFILEAgent UI profile selector; custom exposes custom UI bootstrap (0.6.7)
KSADK_UI_PATHcustom UI mount path, e.g. / or /research; /chat is auto-rewritten to / for custom profile (0.6.7)
KSADK_UI_URLexternal custom UI URL (0.6.7)
KSADK_UI_BUNDLE_PATHcustom UI static bundle path relative to project; local auto-detects research-ui/dist (0.6.7)
KSYUN_REGIONregion used by cloud actions and some SDK clients

Cloud Account Identity Resolution

VariablePurpose
KSYUN_IAM_ENDPOINTOptional public IAM endpoint override; defaults to iam.api.ksyun.com when unset
KSYUN_IAM_INTRANET_URLOptional platform-provided IAM intranet endpoint override; normally unset in public environments
IAM_INTRANET_URLCompatibility alias for KSYUN_IAM_INTRANET_URL

Set KSYUN_IAM_INTRANET_URL or IAM_INTRANET_URL only when a platform operator supplies an approved intranet endpoint. Do not put that address in project files, documentation examples, or Agent manifests.

Session Storage

VariablePurpose
KSADK_SESSION_BACKENDsession backend, for example local or postgres
AGENTENGINE_SESSION_BACKENDcompatibility alias for session backend
KSADK_SESSION_DSNPostgreSQL or shared backend DSN
KSADK_SESSION_PATHlocal session database path
KSADK_SESSION_NAMESPACEnamespace for shared session backends
KSADK_SESSION_CONNECT_TIMEOUTPostgreSQL session backend connect timeout in seconds, default 5; on failure raises SessionBackendUnavailable and server returns 503 instead of 500 (0.6.7)
KSADK_STM_BACKENDshort-term memory/session backend compatibility variable
KSADK_STM_PATHlocal SQLite path for UI/session state
KSADK_STM_DB_PATHcompatibility alias for local SQLite path
KSADK_STM_URLcompatibility DSN for database-backed session state
KSADK_STM_DB_URLcompatibility DSN for database-backed session state
KSADK_ADK_SESSION_BACKENDADK-native session backend selector
KSADK_ADK_SESSION_PATHADK-native SQLite session path
KSADK_ADK_SESSION_URLADK-native database session URL
KSADK_TENANT_IDtenant id used for session namespace scoping
KSADK_WORKSPACE_IDworkspace id used for session namespace scoping
AGENTENGINE_TENANT_IDcompatibility tenant id
AGENTENGINE_WORKSPACE_IDcompatibility workspace id

Local UI usually sets:

bash
KSADK_STM_BACKEND=sqlite
KSADK_STM_PATH=.agentengine/ui/sessions.sqlite

Agent Kernel

VariablePurpose
KSADK_AGENT_KERNELexplicitly enable Kernel ingress for local development; disabled by default
AGENT_KERNEL_ENABLEDplatform-projected hosted enable flag; older Agents without it remain on the historical path
AGENT_KERNEL_STORE_DRIVERmemory, local sqlite, or postgres; the hosted production composition supports ephemeral memory or durable PostgreSQL
AGENT_KERNEL_STORE_DSNrequired for postgres; may be a database file path for local sqlite; not used by memory
AGENT_KERNEL_DURABILITY_TIERephemeral or durable; hosted memory must explicitly select ephemeral
AGENT_KERNEL_AUTHORITY_MODElocal or hosted; hosted mode trusts Server permits only
AGENT_CONTROL_JWKS_URLplatform-projected JWKS URL used to verify Server-signed permits
AGENT_CONTROL_PERMIT_ISSUERtrusted permit issuer projected by the platform
AGENT_KERNEL_CONTRACT_DIGESTfrozen control-plane / Runtime contract digest; hosted startup rejects a mismatch
AGENT_KERNEL_CAPABILITY_DIGESTdigest of the actual Runtime capability matrix; admission rejects an adapter mismatch
AGENT_BUNDLE_DIGESTimmutable Agent Bundle identity used by owner and recovery evidence

PostgreSQL is not the default dependency

A single-replica hosted Agent that does not need cross-Pod recovery can use memory with AGENT_KERNEL_DURABILITY_TIER=ephemeral. Choose postgres only for a durable Inbox, cross-Pod takeover, or high availability; a missing AGENT_KERNEL_STORE_DSN then fails startup.

Checkpoint Storage

VariablePurpose
KSADK_CHECKPOINT_BACKENDcheckpoint backend: local / sqlite / memory / postgres; default local (0.6.7)
KSADK_CHECKPOINT_PATHlocal SQLite checkpoint path, default .agentengine/ui/checkpoints.sqlite (0.6.7)
KSADK_LANGGRAPH_CHECKPOINT_DSNLangGraph PostgreSQL checkpoint DSN; required when backend is postgres (0.6.7)

Local agentengine web defaults to local session backend and SQLite LangGraph checkpoints, reducing the local resume path's dependency on PostgreSQL (0.6.7).

Ambient Runtime Context

VariablePurpose
KSADK_KB_AMBIENT_ENABLEDenable runtime-injected knowledge context; default enabled
KSADK_KB_AMBIENT_POLICYon_demand, always, or disabled
KSADK_LTM_AMBIENT_ENABLEDenable runtime-injected memory context; default enabled
KSADK_LTM_AMBIENT_POLICYon_demand, always, or disabled
KSADK_LTM_AUTO_SAVEsave completed turns to long-term memory when supported
KSADK_LTM_AGENT_IDagent id recorded with memory entries

Workspace Files

VariablePurpose
KSADK_WORKSPACE_FILES_ENABLEDenable workspace file routes
KSADK_WORKSPACE_ROOT_LABELdisplay label for the workspace root
KSADK_WORKSPACE_MAX_UPLOAD_BYTESsingle upload size limit

Long-Term Memory

VariablePurpose
KSADK_LTM_BACKENDmemory backend: local, http, or sdk
KSADK_LTM_TOP_Kdefault number of memories to retrieve
KSADK_LTM_INDEXlocal or generic memory index name
KSADK_LTM_APP_NAMEapplication name used by memory service
KSADK_LTM_HTTP_URLHTTP memory backend URL
KSADK_LTM_HTTP_TOKENHTTP memory backend token
KSADK_LTM_ACCESS_KEYSDK memory access key; can fall back to cloud AK env vars
KSADK_LTM_SECRET_KEYSDK memory secret key; can fall back to cloud SK env vars
KSADK_LTM_REGIONSDK memory region
KSADK_LTM_ENDPOINTSDK memory endpoint
KSADK_LTM_SCHEMESDK memory scheme, usually https
KSADK_LTM_NAMESPACESDK memory namespace
KSADK_LTM_AGENT_IDagent id recorded with memory entries
KSADK_LTM_SCENE_IDscene id, default _sys_general
KSADK_LTM_AUTO_SAVEenable automatic memory saving when supported
KSADK_MEMORY_BACKENDgeneric memory backend selector for legacy integrations
KSADK_MEMORY_URLgeneric memory backend URL
KSADK_MEMORY_PREFIXgeneric memory key prefix
KSADK_MEMORY_TTLgeneric memory TTL in seconds

Knowledge Base

VariablePurpose
KSADK_KB_DATASET_IDenable a knowledge dataset integration
KSADK_KB_TOP_Knumber of snippets to retrieve
KSADK_KB_ACCESS_KEYoptional knowledge SDK access key
KSADK_KB_SECRET_KEYoptional knowledge SDK secret key
KSADK_KB_REGIONknowledge service region
KSADK_KB_ENDPOINTknowledge service endpoint
KSADK_KB_SEARCH_METHODretrieval method, default intelligence_search
KSADK_KB_SCORE_THRESHOLDoptional score threshold
KSADK_KB_RERANKING_ENABLEenable reranking when supported

Skill Runtime

VariablePurpose
KSADK_SKILL_SPACE_IDScomma-separated Skill Space ids
SKILL_SPACE_IDcompatibility alias for a single Skill Space id
KSADK_PUBLIC_SKILL_SPACE_IDScomma-separated public Skill Space ids appended after user spaces
KSADK_PUBLIC_SKILL_ALLOWLISTcomma-separated public Skill names to expose
KSADK_LOCAL_SKILLS_DIRlocal directory containing SKILL.md packages
KSADK_SELECTED_SKILL_NAMEScomma-separated Skill names selected by an outer agent
KSADK_SKILLS_MODESkill loading mode: auto, local, or sandbox
KSADK_SKILL_SERVICE_URLSkill Service endpoint
KSADK_SKILL_SERVICE_TOKENSkill Service bearer token when token auth is used
KSADK_SKILL_SERVICE_ACCESS_KEYsigned Skill Service access key
KSADK_SKILL_SERVICE_SECRET_KEYsigned Skill Service secret key
KSADK_SKILL_SERVICE_ACCOUNT_IDaccount id for signed requests
KSADK_SKILL_SERVICE_REGIONSkill Service region
KSADK_SKILL_SERVICE_API_VERSIONSkill Service API version
KSADK_SKILL_SERVICE_SIGN_SERVICEsigning service name
KSADK_SKILL_CACHE_DIRlocal cache for downloaded skill packages
KSADK_SKILL_ALLOW_HASH_MISMATCHallow unverified skill package preview
KSADK_SKILL_MANIFEST_TIMEOUTremote Skill manifest listing timeout in seconds
KSADK_SKILL_MANIFEST_LIMITmaximum manifests injected into agent instructions
KSADK_SKILL_RUNTIME_BACKENDisolated execution backend, for example local_process or e2b
KSADK_SKILL_RUNTIME_TEMPLATE_IDruntime template id
KSADK_SANDBOX_BACKENDsandbox backend selector used as a compatibility fallback
KSADK_SANDBOX_TEMPLATE_IDsandbox template id; also enables E2B-style backend
KSADK_SKILL_RUNTIME_TIMEOUTisolated execution timeout in seconds
KSADK_SANDBOX_TIMEOUTsandbox timeout compatibility variable
KSADK_SKILL_RUNTIME_ALLOW_INTERNET_ACCESSallow internet access for sandbox execution
KSADK_SKILL_RUNTIME_AGENT_PATHlocal process runtime agent path
KSADK_SKILL_WORKDIRworkspace directory exposed to skill execution
KSADK_SKILL_ARTIFACT_PROJECTartifact project name for generated outputs

Tool Gateway

VariablePurpose
KSADK_TOOL_APPROVAL_MODEtool approval mode; set to strict to make medium / high / critical risk tools return approval_required before execution

MCP

VariablePurpose
KSADK_ENABLE_MCP_TOOLSenable or disable MCP tools
KSADK_MCP_SERVERSJSON array of MCP server definitions
KSADK_BUILD_ENABLE_MCPinclude MCP runtime dependencies during code build

Example:

bash
KSADK_ENABLE_MCP_TOOLS=1
KSADK_MCP_SERVERS='[{"name":"docs","url":"http://127.0.0.1:9000/mcp"}]'

Build And Packaging

VariablePurpose
KSADK_BUILD_PIP_INSTALL_TIMEOUT_SECONDSpip install timeout in build flows
KSADK_BUILD_ENABLE_ATTACHMENT_OCRinclude OCR-related attachment dependencies
KSADK_BUILD_ENABLE_POSTGRES_SESSIONinclude PostgreSQL session dependencies

Object Storage Credentials (KS3)

VariablePurpose
KS3_BUCKETKS3 bucket name; derived from account_id + region when unset
KS3_REGIONKS3 region; falls back to KSYUN_REGION, default cn-beijing-6
KS3_ACCESS_KEYKS3 access key; can fall back to cloud AK env vars (sensitive)
KS3_SECRET_KEYKS3 secret key; can fall back to cloud SK env vars (sensitive)

Image Registry Credentials

VariablePurpose
KCR_REGISTRYimage registry address
KCR_ENDPOINTimage registry endpoint
KCR_USERNAMEimage registry username; required for enterprise KCR and third-party registries (sensitive)
KCR_PASSWORDimage registry password; required for enterprise KCR and third-party registries (sensitive)

Personal KCR (*.kce.ksyun.com) allows KSYUN_ACCOUNT_ID to fall back as the username; enterprise KCR (*.ksyunkcr.com) and third-party registries must set KCR_USERNAME / KCR_PASSWORD explicitly, to avoid wrongly using the cloud account id as an enterprise image username (0.6.5).

Build Context .env Boundary

agentengine deploy and agentengine launch support --env KEY=VALUE (repeatable) and --env-file for runtime environment variables; explicit env goes into the deploy payload env_vars. Real .env / .env.local files are excluded from Code, Container, and MCP build contexts; only .env.example / .env.sample / .env.template template files are kept (0.6.5).

Web UI Static Sync

VariablePurpose
KSADK_WEB_VERSIONpublished @kingsoftcloud/ksadk-web npm version used by make sync-ksadk-web-static; the 0.8.4 default is 0.3.7. Publish and verify a new version before using it in a wheel build.
KSADK_WEB_PACKAGEnpm package name used for local UI static sync; default @kingsoftcloud/ksadk-web
KSADK_WEB_TARBALL_NAMEsaved filename when KSADK_WEB_RELEASE_URL is set; npm pack mode uses the real tarball filename returned by npm
KSADK_WEB_RELEASE_URLoptional fallback; when set, skips npm pack and downloads from this tarball URL
KSADK_WEB_CACHE_DIRKsADK Web package extraction cache directory; default .cache/ksadk-web

make build / make build-wheel automatically run sync-ksadk-web-static; no manual sync needed.

DSH Plugin Bridge

VariablePurpose
KSADK_DSH_HOMEIsolated managed DSH Profile directory; defaults to .agentkit/dsh-home in the workspace. Studio never mutates an explicitly configured directory.
KSADK_DSH_PROFILEDSH Profile name to use; defaults to studio.
KSADK_DSH_BINOptional absolute DSH command path for fixed-toolchain core development or CI verification; version mismatches fail closed.

Observability

VariablePurpose
OTEL_SERVICE_NAMEOpenTelemetry service name; also used as an agent name fallback
OTEL_RESOURCE_ATTRIBUTESOpenTelemetry resource attributes as comma-separated key=value pairs
OTEL_EXPORTER_OTLP_ENDPOINTgeneric OTLP HTTP endpoint; KsADK derives /v1/traces when no traces endpoint is set
OTEL_EXPORTER_OTLP_PROTOCOLgeneric OTLP protocol; KsADK auto HTTP exporter supports http/protobuf
OTEL_EXPORTER_OTLP_HEADERSgeneric OTLP HTTP headers, comma-separated with URL-encoded values; may contain auth data
OTEL_EXPORTER_OTLP_TRACES_ENDPOINTtraces-specific OTLP HTTP endpoint; takes precedence over the generic endpoint
OTEL_EXPORTER_OTLP_TRACES_PROTOCOLtraces-specific OTLP protocol; takes precedence over the generic protocol
OTEL_EXPORTER_OTLP_TRACES_HEADERStraces-specific OTLP HTTP headers; takes precedence over generic headers and may contain auth data
KSADK_OTLP_MAX_EXPORT_BATCH_SIZEmaximum spans exported per OTLP batch, default 64, to avoid oversized collector requests
SESSION_TITLE_MODELmodel override for generated local session titles
COMPACTION_DISABLE_SEMANTICdisable semantic session summary compaction
COMPACTION_SUMMARY_TIMEOUT_MStimeout for summary generation
COMPACTION_SUMMARY_MAX_GROUPSmaximum message groups summarized
COMPACTION_SUMMARY_MODELmodel override for semantic summaries

CloudMonitor OTLP Dual-Write (CLOUD_MONITOR_*)

setup_tracing() auto-detects CLOUD_MONITOR_OTLP_* variables and builds a CloudMonitor OTLP exporter writing in parallel with the primary Langfuse OTLP (standard OTEL_EXPORTER_OTLP_*). A single span enters both backends with the same trace_id and span_id. Managed Agents created from either the CLI or console receive both routes by default; use --no-observability, or turn observability off in the console, to disable them explicitly. The Langfuse CallbackHandler path has been removed.

VariablePurpose
CLOUD_MONITOR_APP_KEYDeprecated transition fallback; used as Ksc-Appkey only when both CLOUD_MONITOR_OTLP_TRACES_HEADERS and CLOUD_MONITOR_OTLP_HEADERS are entirely absent (sensitive)
CLOUD_MONITOR_OTLP_ENDPOINTCloudMonitor generic OTLP HTTP endpoint; derives /v1/traces when no traces endpoint is set
CLOUD_MONITOR_OTLP_PROTOCOLCloudMonitor generic OTLP protocol; currently supports http/protobuf
CLOUD_MONITOR_OTLP_HEADERSCloudMonitor OTLP extra headers, comma-separated and RFC 3986 encoded (sensitive)
CLOUD_MONITOR_OTLP_TRACES_ENDPOINTCloudMonitor traces-specific endpoint; takes precedence over the generic endpoint
CLOUD_MONITOR_OTLP_TRACES_HEADERSCloudMonitor traces-specific headers; take precedence over generic headers and fail closed when present without Ksc-Appkey (sensitive)
CLOUD_MONITOR_OTLP_TRACES_PROTOCOLCloudMonitor traces-specific protocol; takes precedence over the generic protocol

When one backend fails the other still works: primary failure keeps the secondary, secondary failure keeps the primary, Agent business is not blocked.

Safety Rules

  • Never commit real values for keys, tokens, DSNs, private endpoints, customer dataset ids, or kubeconfigs.
  • Prefer local .env for development and CI secrets for automation.
  • Keep public docs on placeholders such as sk-test, my-model, and https://api.example.com/v1.

On this page