JuliusBrussee/caveman · warning

Qwen safe mode ignores Caveman system settings

Error message

Qwen safe mode ignores Caveman system settings

What it means

Qwen CLI's --safe-mode flag makes Qwen ignore external/system settings files, including the Caveman-injected system settings that provide the durable second lock for managed routing. Because safe mode would silently defeat those settings, the wrapper refuses to launch when it detects a route override on the --safe-mode surface with that reason. You can still use safe mode, just not combined with the routed wrap.

Solutions

  1. Drop --safe-mode from the Qwen invocation; the wrapper already disables risky surfaces via ENABLE_WEB_SEARCH=0 and QWEN_CODE_DISABLE_WORKFLOWS=1 in routed mode.
  2. Run Qwen directly (not through the Caveman managed wrap) if --safe-mode is required.
  3. Keep the safety guarantee via the injected env switches and system settings rather than the Qwen flag.

Example fix

// before
caveman agent qwen --safe-mode   # throws
// after
caveman agent qwen               # ENABLE_WEB_SEARCH=0 and QWEN_CODE_DISABLE_WORKFLOWS=1 injected instead
Defensive patterns

Strategy: validation

Validate before calling

const args = qwenArgs.filter(a => a !== "--safe-mode");
if (args.length !== qwenArgs.length) {
  console.warn("--safe-mode removed: incompatible with Caveman routed mode; env switches provide the safeguards.");
}

Try / catch

try {
  caveman.launch({ agent: "qwen", args });
} catch (e) {
  if (e instanceof Error && e.message === "Qwen safe mode ignores Caveman system settings") {
    console.error("Drop --safe-mode or run Qwen directly without the Caveman wrap.");
  } else throw e;
}

Prevention

When it happens

Trigger: Launching the qwen agent through the managed/routed wrapper while agentRouteOverride reports { surface: "--safe-mode", reason: "ignores Caveman system settings" } — i.e. the Qwen invocation includes --safe-mode (or an equivalent alias captured by the override table).

Common situations: Adding --safe-mode to a Qwen alias or script that is then launched via Caveman; organizational wrappers that always pass --safe-mode; trying to harden Qwen while simultaneously routing it through the managed gateway.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/249931afb13d1eec. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/index.ts:9361

  const renderedGw = agent ? attributedGatewayUrl(gw, agent) : gw;
  const env: NodeJS.ProcessEnv = {
    ...process.env,
    ...(agent?.injection.method === "native-extension" ? {} : wrapBaseUrlEnv(renderedGw)),
  };
  if (wrapMode(gw) === "managed") {
    const gatewayKey = connectedGatewayAPIKey();
    if (gatewayKey) env.CAVE_API_KEY = gatewayKey;
  }
  if (!agent) return env;
  if (applyClaudeBedrockWrap(env, agent, renderedGw, gw)) return env;
  const routeOverride = agentRouteOverride(agent, agentArgs);
  if (agent.id === "qwen") {
    const override = routeOverride;
    if (override?.surface === "effective settings") {
      throw new Error("cannot safely resolve Qwen's effective settings");
    }
    if (override?.surface === "--safe-mode" && override.reason === "ignores Caveman system settings") {
      throw new Error("Qwen safe mode ignores Caveman system settings");
    }
    // These environment switches outrank settings in pinned Qwen 0.22.3.
    // Keep side-request tools and workflow-spawned agents off in routed mode;
    // corresponding system settings provide the durable second lock.
    env.ENABLE_WEB_SEARCH = "0";
    env.QWEN_CODE_DISABLE_WORKFLOWS = "1";
  }
  if (routeOverride) throw new Error(`${routeOverrideLabel(agent)} ${routeOverride.surface} ${routeOverride.reason}`);
  const inj = agent.injection;
  if (inj.method === "env") {
    for (const [k, raw] of Object.entries(inj.env)) {
      const val = renderTemplate(raw, renderedGw);
      if (val !== "") env[k] = val;
    }
  } else if (inj.method === "config-env-content") {
    const cc = inj.config_content;
    const content = wrapMode(gw) === "managed" && cc.managed !== undefined ? cc.managed : cc.local;
    const renderOptions: RenderDeepOptions = agent.id === "kilo"

View on GitHub (pinned to 3ee70a1026)