{"record":{"id":"249931afb13d1eec","repo":"JuliusBrussee/caveman","slug":"qwen-safe-mode-ignores-caveman-system-settings","errorCode":null,"errorMessage":"Qwen safe mode ignores Caveman system settings","messagePattern":"Qwen safe mode ignores Caveman system settings","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":9054,"sourceCode":"  const renderedGw = agent ? attributedGatewayUrl(gw, agent) : gw;\n  const env: NodeJS.ProcessEnv = {\n    ...process.env,\n    ...(agent?.injection.method === \"native-extension\" ? {} : wrapBaseUrlEnv(renderedGw)),\n  };\n  if (wrapMode(gw) === \"managed\") {\n    const gatewayKey = connectedGatewayAPIKey();\n    if (gatewayKey) env.CAVE_API_KEY = gatewayKey;\n  }\n  if (!agent) return env;\n  if (applyClaudeBedrockWrap(env, agent, renderedGw, gw)) return env;\n  const routeOverride = agentRouteOverride(agent, agentArgs);\n  if (agent.id === \"qwen\") {\n    const override = routeOverride;\n    if (override?.surface === \"effective settings\") {\n      throw new Error(\"cannot safely resolve Qwen's effective settings\");\n    }\n    if (override?.surface === \"--safe-mode\" && override.reason === \"ignores Caveman system settings\") {\n      throw new Error(\"Qwen safe mode ignores Caveman system settings\");\n    }\n    // These environment switches outrank settings in pinned Qwen 0.22.3.\n    // Keep side-request tools and workflow-spawned agents off in routed mode;\n    // corresponding system settings provide the durable second lock.\n    env.ENABLE_WEB_SEARCH = \"0\";\n    env.QWEN_CODE_DISABLE_WORKFLOWS = \"1\";\n  }\n  if (routeOverride) throw new Error(`${routeOverrideLabel(agent)} ${routeOverride.surface} ${routeOverride.reason}`);\n  const inj = agent.injection;\n  if (inj.method === \"env\") {\n    for (const [k, raw] of Object.entries(inj.env)) {\n      const val = renderTemplate(raw, renderedGw);\n      if (val !== \"\") env[k] = val;\n    }\n  } else if (inj.method === \"config-env-content\") {\n    const cc = inj.config_content;\n    const content = wrapMode(gw) === \"managed\" && cc.managed !== undefined ? cc.managed : cc.local;\n    const renderOptions: RenderDeepOptions = agent.id === \"kilo\"","sourceCodeStart":9036,"sourceCodeEnd":9072,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/5184b3d11ac6a1acb7d44b9bfaa31698157cff97/packages/cli/src/index.ts#L9036-L9072","documentation":"Thrown while building the wrapped environment for the Qwen agent: agentRouteOverride reports that Qwen was launched with --safe-mode, a mode that disregards Caveman-injected system settings. Continuing would silently produce a session that ignores the gateway wrap, so the guard aborts instead of mis-wrapping.","triggerScenarios":"Thrown at packages/cli/src/index.ts:9054 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Stop Qwen from launching with --safe-mode (remove the flag from agent args or the saved Qwen settings) so Caveman system settings take effect","Check the resolved route override (agentRouteOverride) to see which surface and reason triggered the refusal and address that setting","If safe mode is intentional, run Qwen outside Caveman wrapping rather than forcing the wrap"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5184b3d11ac6a1acb7d44b9bfaa31698157cff97","analyzedAt":"2026-09-06T12:00:26.372Z","contentChangedAt":"2026-09-06T12:00:26.372Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}