Back to Qwen Code

Configuration Reference

docs/developers/daemon/17-configuration.md

0.18.226.1 KB
Original Source

Configuration Reference

Overview

This page collects every setting that affects the qwen serve daemon and its adapters: environment variables, CLI flags, settings.json keys, and programmatic options. Feature-specific pages link back here when they need cross-cutting configuration details.

CLI flags (qwen serve)

FlagTypeDefaultEffect
--hostname <host>string127.0.0.1Bind address. Loopback values: 127.0.0.1, localhost, ::1, [::1]. Non-loopback requires a bearer token at boot. host:port input is rejected with guidance to use --port.
--port <n>number4170Listen port; 0 means ephemeral.
--token <s>stringenvBearer token. Overrides QWEN_SERVER_TOKEN and is trimmed at boot. It appears in the process command line, so prefer env in deployments.
--require-authbooleanfalseExtends bearer auth to loopback and /health; boot refuses to start without a token.
--workspace <dir>absolute pathprocess.cwd()Bound workspace. Must be absolute and a directory; canonicalized once at boot.
--max-sessions <n>number20Active session cap. 0 / Infinity means unlimited; NaN / negative values throw.
--max-pending-prompts-per-session <n>number5Accepted but pending/running prompt cap per session. Excess prompt returns 503. 0 / Infinity means unlimited; negative or non-integer values throw.
--max-connections <n>number256HTTP listener server.maxConnections; 0 / Infinity means unlimited.
--enable-session-shellbooleanfalseEnables direct POST /session/:id/shell execution. Requires bearer token, and every call must carry a session-bound X-Qwen-Client-Id.
--event-ring-size <n>number8000Per-session SSE replay ring; soft cap is 1_000_000.
--http-bridgebooleantrueStage 1 bridge mode. --no-http-bridge still falls back to http-bridge and prints to stderr.
--mcp-client-budget <n>positive integerunsetSets WorkspaceMcpBudget.clientBudget and forwards it to the ACP child through childEnvOverrides.
--mcp-budget-mode <m>off / warn / enforcewarn when budget is set, otherwise offSets WorkspaceMcpBudget.mode; enforce requires --mcp-client-budget.
--allow-origin <pattern>repeatable stringunsetCross-origin allowlist that replaces the default CORS denial. * allows any origin but requires a token.
--allow-private-auth-base-urlbooleanfalseAllows /workspace/auth/provider to install localhost / private-network auth provider baseUrl; use only in trusted local development.
--prompt-deadline-ms <n>positive integerunsetServer-side prompt wallclock limit in ms. Timeout aborts and returns an error.
--writer-idle-timeout-ms <n>positive integerunsetPer-SSE-connection idle timeout in ms. The daemon closes the SSE connection when no event is sent for this duration.
--channel-idle-timeout-ms <n>non-negative integer0How long to keep the ACP child alive after the last session closes. 0 means reclaim immediately.
--session-reap-interval-ms <n>non-negative integer60000Session reaper scan interval; 0 disables it.
--session-idle-timeout-ms <n>non-negative integer1800000Disconnected-session idle reaping time; 0 disables it.
--rate-limit / --no-rate-limitbooleanenv / offEnables per-tier HTTP rate limiting for prompt, mutation, and read routes.
--rate-limit-prompt <n>positive integer10Prompt request limit per window; requires rate limiting to be enabled.
--rate-limit-mutation <n>positive integer30Mutation request limit per window; requires rate limiting to be enabled.
--rate-limit-read <n>positive integer120Read request limit per window; requires rate limiting to be enabled.
--rate-limit-window-ms <n>integer >= 100060000Rate limit window length; requires rate limiting to be enabled.
no flag--QWEN_SERVE_NO_MCP_POOL=1 fully disables the pool.

Environment variables

Read by runQwenServe / Express middleware

EnvEffect
QWEN_SERVER_TOKENBearer token; trimmed at boot.
QWEN_SERVE_DEBUG1 / true / on / yes (case-insensitive) enables verbose stderr logs. See 19-observability.md.
QWEN_SERVE_NO_MCP_POOL1 disables the workspace MCP transport pool and falls back to per-session McpClientManager; capabilities stop advertising mcp_workspace_pool / mcp_pool_restart.
QWEN_SERVE_PROMPT_DEADLINE_MSEnv fallback for --prompt-deadline-ms.
QWEN_SERVE_WRITER_IDLE_TIMEOUT_MSEnv fallback for --writer-idle-timeout-ms.
QWEN_SERVE_RATE_LIMIT1 / true enables per-tier HTTP rate limiting; CLI --rate-limit / --no-rate-limit wins.
QWEN_SERVE_RATE_LIMIT_PROMPTEnv fallback for --rate-limit-prompt.
QWEN_SERVE_RATE_LIMIT_MUTATIONEnv fallback for --rate-limit-mutation.
QWEN_SERVE_RATE_LIMIT_READEnv fallback for --rate-limit-read.
QWEN_SERVE_RATE_LIMIT_WINDOW_MSEnv fallback for --rate-limit-window-ms.

Forwarded to the ACP child through BridgeOptions.childEnvOverrides

runQwenServe builds these per handle so two daemons in one process do not race on process.env. The budget variables are not parent-process env fallbacks for qwen serve; the CLI path must generate them from --mcp-client-budget / --mcp-budget-mode.

EnvEffect
QWEN_SERVE_MCP_CLIENT_BUDGETPositive integer string consumed by the ACP child's readBudgetFromEnv().
QWEN_SERVE_MCP_BUDGET_MODEoff / warn / enforce.
QWEN_SERVE_MCP_POOL_TRANSPORTSComma-separated transport allowlist; default pooled transports are stdio,websocket; can explicitly include http,sse.
QWEN_SERVE_MCP_POOL_DRAIN_MSPool entry idle drain delay; default 30000, clamped to 1000..600000 ms.

Read by SDK / adapters

EnvEffect
QWEN_DAEMON_URLDaemon base URL for CLI TUI adapter, channels, and IDE companion.
QWEN_DAEMON_TOKENBearer token.
QWEN_DAEMON_WORKSPACEOverrides the cwd sent to POST /session.

settings.json keys

The daemon reads settings once at boot through loadSettings(boundWorkspace) inside runQwenServe. Malformed settings fall back to defaults through a try/catch guard.

KeyTypeEffect
policy.permissionStrategy'first-responder' | 'designated' | 'consensus' | 'local-only'Sets BridgeOptions.permissionPolicy; the active value appears in /capabilities as policy.permission. Boot validates through validatePolicyConfig() against SERVE_CAPABILITY_REGISTRY.permission_mediation.modes. Unknown literals throw InvalidPolicyConfigError and fail boot explicitly.
policy.consensusQuorumpositive integerN for the consensus policy. Default is floor(M/2) + 1 over votersAtIssue.size (M=2 means unanimous; larger even M means more than half). If set under a non-consensus policy, it is ignored and boot prints a stderr warning. Non-positive integers throw InvalidPolicyConfigError. See 04-permission-mediation.md.
context.fileNamestringOverrides getCurrentGeminiMdFilename() through BridgeOptions.contextFilename.
tools.disabledstring[]Tools disabled for the next ACP child spawn. Normalized through normalizeDisabledToolList() (packages/cli/src/config/normalizeDisabledTools.ts): non-array becomes [], non-string entries are skipped, whitespace is trimmed, empty entries are dropped, and duplicates are removed while preserving first occurrence. Boot and restartMcpServer settings refresh both run through this function. ToolRegistry.has(name) is exact and case-sensitive. POST /workspace/tools/:name/enable and tool_toggled update this key.
tools.approvalMode'default' | 'auto' | ...Default session approval mode; POST /session/:id/approval-mode writes here when persist: true.
telemetryobjectOTel config. Keys include enabled, otlpEndpoint, otlpProtocol, otlpTracesEndpoint, otlpLogsEndpoint, otlpMetricsEndpoint, target, outfile, includeSensitiveSpanAttributes, resourceAttributes, and metrics.includeSessionId. resolveTelemetrySettings() reads it at boot and initializes initializeTelemetry().

ServeOptions (programmatic embedding)

packages/cli/src/serve/types.ts defines the typed options object accepted by both runQwenServe and createServeApp. It mirrors the CLI flags above and adds:

FieldEffect
eventRingSizeOverrides the default per-session ring size.
maxPendingPromptsPerSessionPending prompt cap per session; 0 / Infinity means unlimited.
mcpPoolActiveProgrammatic switch, defaulting from QWEN_SERVE_NO_MCP_POOL.
allowOriginsCross-origin allowlist (string[]), corresponding to --allow-origin.
allowPrivateAuthBaseUrlAllows private / localhost auth provider baseUrl installation.
enableSessionShellEnables session shell execution; bearer token and session-bound client id are still required.
promptDeadlineMsPrompt wallclock limit.
writerIdleTimeoutMsSSE writer idle timeout.
channelIdleTimeoutMsHow long to keep the ACP child warm after the last session closes.
sessionReapIntervalMsSession reaper scan interval.
sessionIdleTimeoutMsDisconnected-session idle reaping time.
rateLimit*Per-tier HTTP rate limit switch, thresholds, and window.

BridgeOptions (programmatic bridge embedding)

packages/acp-bridge/src/bridgeOptions.ts defines bridge options. See 03-acp-bridge.md for the full table. Key fields:

FieldEffect
boundWorkspaceRequired canonical workspace.
sessionScope'single' (default) vs 'thread'.
initializeTimeoutMs, maxSessions, eventRingSize, permissionResponseTimeoutMs, maxPendingPermissionsPerSessionBounded resource caps.
channelFactoryPluggable ACP child factory; default is defaultSpawnChannelFactory.
fileSystemBridgeFileSystem adapter. See 07-workspace-filesystem.md.
permissionPolicy, permissionConsensusQuorum, permissionAuditMediator wiring.
statusProviderDaemon-host preflight cells.
childEnvOverridesPer-handle environment additions or removals.
contextFilenameOverrides getCurrentGeminiMdFilename().
channelIdleTimeoutMsHow long to keep the ACP child alive after the last session closes, in ms; default 0.

Important defaults

ConstantFileValueMeaning
DEFAULT_MAX_SESSIONSbridge.ts20Session cap before SessionLimitExceededError.
MAX_EVENT_RING_SIZEbridge.ts1_000_000Soft cap for BridgeOptions.eventRingSize; guards against typos.
DEFAULT_RING_SIZEeventBus.ts8000Per-session SSE replay ring depth.
DEFAULT_MAX_QUEUEDeventBus.ts256Per-subscriber queue cap.
DEFAULT_MAX_SUBSCRIBERSeventBus.ts64Per-bus subscriber cap.
WARN_THRESHOLD_RATIOeventBus.ts0.75slow_client_warning trigger.
WARN_RESET_RATIOeventBus.ts0.375Hysteresis re-arm threshold.
DEFAULT_INIT_TIMEOUT_MSbridge.ts10_000ACP initialize handshake timeout.
MCP_RESTART_TIMEOUT_MSbridge.ts300_000Bridge timeout for /workspace/mcp/:server/restart.
DEFAULT_PERMISSION_TIMEOUT_MSbridge.ts5 * 60_000Per-permission request wallclock.
DEFAULT_MAX_PENDING_PER_SESSIONbridge.ts64Aligned with DEFAULT_MAX_SUBSCRIBERS.
MAX_RESOLVED_PERMISSION_RECORDSpermissionMediator.ts512FIFO for recently resolved permissions.
KILL_HARD_DEADLINE_MSspawnChannel.ts10_000Per-channel graceful shutdown window.
SHUTDOWN_FORCE_CLOSE_MSrunQwenServe.ts5_000HTTP server force-close timer.
MAX_READ_BYTESfs/policy.ts256 * 1024Read cap.
MAX_WRITE_BYTESfs/policy.ts5 * 1024 * 1024Write cap.
MAX_DISPLAY_NAME_LENGTHbridge.ts256Session displayName cap.

Cross-references