JuliusBrussee/caveman · error · Error
cannot safely resolve Qwen's effective settings
Error message
cannot safely resolve Qwen's effective settings
What it means
In buildWrapEnv, before any other Qwen handling, the CLI checks agentRouteOverride for command-line flags that change how Qwen loads its configuration. If the user passed a flag/argument combination whose effect on Qwen's effective settings cannot be safely reproduced in the temporary system settings (override.surface === "effective settings"), the wrap aborts fail-closed with this error rather than launching Qwen with settings that could silently bypass or contradict the Caveman route.
Source
Thrown at packages/cli/src/index.ts:9051
if (agent?.id === "gemini" && wrapMode(gw) === "managed") {
throw new Error("managed Gemini CLI routing is unsupported because Gemini CLI cannot send separate Caveman and upstream credentials");
}
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") {View on GitHub (pinned to 5184b3d11a)
Solutions
- Remove the settings-affecting flag from the wrapped invocation and let caveman supply its temporary system settings.
- If you need custom Qwen settings, edit the layer caveman reads (project/system Qwen settings) instead of overriding via CLI flags.
- Check `agentRouteOverride` behavior in the CLI version you run; upgrade the CLI if a flag you need should now be supported.
- For debugging, run the raw qwen binary directly (not through caveman wrap) — but understand it will not be routed/compressed.
Example fix
// before: flag forwarded that overrides effective settings caveman qwen --settings ./my-settings.json // after: default resolution via caveman's temp settings caveman qwen
Defensive patterns
Strategy: validation
Validate before calling
// Screen forwarded args before invoking the qwen wrap
const settingsFlags = ["--settings", "--config", "-c"];
const args = process.argv.slice(2);
if (args.some((a) => settingsFlags.some((f) => a === f || a.startsWith(f + "=")))) {
throw new Error("Settings-override flags cannot be forwarded through `caveman qwen`; edit Qwen settings files directly instead.");
} Try / catch
try {
execSync("caveman qwen", { stdio: "inherit" });
} catch (e) {
if (e instanceof Error && e.message.includes("cannot safely resolve Qwen's effective settings")) {
console.error("Remove settings-override flags from the wrapped qwen invocation.");
process.exit(1);
}
throw e;
} Prevention
- Do not forward Qwen settings-selection flags through `caveman wrap qwen` / `caveman qwen`.
- Configure Qwen by editing its settings layers, not per-invocation flags, when routed through caveman.
- In wrapper scripts, filter or reject settings-affecting flags before spawning the wrap.
- Check the CLI's agentRouteOverride surface list when adding new qwen flags to automation.
When it happens
Trigger: Running `caveman wrap qwen ...` (or `caveman qwen ...`) while passing agent arguments that agentRouteOverride classifies as altering "effective settings" — e.g. flags that point Qwen at alternate settings files or override its settings resolution — so the CLI cannot guarantee the pinned Qwen 0.22.3 settings precedence.
Common situations: Passing Qwen's own settings-selection flags through the wrap; scripts that forward arbitrary flags to the underlying qwen binary via caveman; operator attempts to use a personal settings file while routed, which would defeat managed routing.
Understand the failure class
Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.
Related errors
- cannot safely resolve Qwen's effective OPENAI_API_KEY
- Qwen routed profile is missing ${key}
- cave_harness_model_identity_missing
- cave_stale_lock:${checked.stale.join(",")}: run npm run buil
- cave_runtime_segment_id_collision
AI-assisted analysis of JuliusBrussee/caveman@5184b3d11a (2026-09-06).
Data as JSON: /api/errors/66029235f2536db3.
Report an issue: GitHub.