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

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 IAM intranet endpoint fallback override; defaults to iam.inner.api.ksyun.com when unset
IAM_INTRANET_URLCompatibility alias for KSYUN_IAM_INTRANET_URL

When public IAM returns an error such as “inner account can only access through intranet”, the runtime retries the intranet endpoint. Public environments normally do not hit this branch; internal environments can override the address with KSYUN_IAM_INTRANET_URL or IAM_INTRANET_URL.

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

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_VERSION@kingsoftcloud/ksadk-web npm dist-tag or version used by make sync-ksadk-web-static; default latest
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.

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
LANGFUSE_PUBLIC_KEYcompatibility path for older Langfuse tracing auto-configuration
LANGFUSE_SECRET_KEYLangfuse secret
LANGFUSE_BASE_URLLangfuse base URL
LANGFUSE_HOSTcompatibility alias for Langfuse host
LANGFUSE_USE_CALLBACKuse framework callback mode instead of direct OTLP path
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 Dual-Write (CLOUD_MONITOR_*)

From 0.6.7, setup_tracing() auto-detects CLOUD_MONITOR_* environment variables and mounts the CloudMonitor OTLP exporter and the CloudMonitor Langfuse SDK CallbackHandler in parallel; neither suppresses self-hosted Langfuse or standard OTLP, and a single span can be reported to both the self-hosted cluster and the CloudMonitor trace platform at once.

VariablePurpose
CLOUD_MONITOR_APP_KEYCloudMonitor OTLP AppKey; injected as the Ksc-Appkey auth header (sensitive)
CLOUD_MONITOR_OTLP_ENABLEDexplicitly enable or disable the CloudMonitor OTLP exporter; auto-detected by default
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 URL-encoded (sensitive)
CLOUD_MONITOR_OTLP_TRACES_ENDPOINTCloudMonitor traces-specific endpoint; takes precedence over the generic endpoint
CLOUD_MONITOR_OTLP_TRACES_PROTOCOLCloudMonitor traces-specific protocol; takes precedence over the generic protocol
CLOUD_MONITOR_LANGFUSE_ENABLEDexplicitly enable or disable the CloudMonitor Langfuse SDK callback; auto-detected by default
CLOUD_MONITOR_LANGFUSE_HOSTCloudMonitor AppMonitor Langfuse SDK host; falls back to CLOUD_MONITOR_OTLP_ENDPOINT
CLOUD_MONITOR_LANGFUSE_PUBLIC_KEYCloudMonitor Langfuse public key (sensitive)
CLOUD_MONITOR_LANGFUSE_SECRET_KEYCloudMonitor Langfuse secret key (sensitive)

Set CLOUD_MONITOR_OTLP_ENABLED=false or CLOUD_MONITOR_LANGFUSE_ENABLED=false to disable the corresponding path.

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