JuliusBrussee/caveman · error

${routeOverrideLabel(agent)} ${routeOverride.surface}…

Error message

${routeOverrideLabel(agent)} ${routeOverride.surface} ${routeOverride.reason}

What it means

This is the generic guard at the end of the Qwen/others route-override handling in buildWrapEnv: after any agent-specific special cases, if agentRouteOverride(agent, agentArgs) still returns an override, the wrapper throws an error composed of the agent label, the CLI surface, and the reason the surface is unsafe. It exists so that any CLI surface known to break the 'what we inject' vs 'what we tell the proxy' consistency fails loudly instead of launching a mis-routed agent.

Solutions

  1. Read the interpolated message: remove the named surface (flag/config) from the agent invocation so agentRouteOverride returns undefined.
  2. Move the credential/behavior the flag was providing into the Caveman-managed configuration (env injection, gateway headers) instead of raw agent flags.
  3. If the override entry is stale for your pinned agent version, update the override table after verifying the surface is safe.

Example fix

// before
caveman agent qwen --openai-api-key sk-...   # raw key flag conflicts with managed routing
// after
caveman agent qwen                            # credentials provided via Caveman-managed env/headers
Defensive patterns

Strategy: try-catch

Validate before calling

// Check the override table yourself before launching
const override = getRouteOverride(agent, agentArgs);
if (override) {
  console.warn(`Blocked surface for ${agent.id}: ${override.surface} — ${override.reason}`);
  process.exit(1);
}

Try / catch

try {
  caveman.launch({ agent, args });
} catch (e) {
  if (e instanceof Error && /route override|unsafe surface/i.test(e.message)) {
    // message format: "<AgentLabel> <surface> <reason>"
    console.error(`Remove the flagged CLI surface from the invocation: ${e.message}`);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling buildWrapEnv (or the CLI agent-launch path) with arguments that match any entry in the route-override table for the selected agent — the thrown message interpolates routeOverrideLabel(agent), routeOverride.surface and routeOverride.reason, e.g. "Qwen --openai-api-key bypasses managed routing" style combinations.

Common situations: Passing provider/API-key flags directly to a wrapped agent so it can bypass the gateway; using a CLI flag combination registered as unsafe for your agent; a new agent release adding flags that the override table maps to an existing unsafe surface.

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/d32822eb54a1288a. Report an issue: GitHub.

Appendix: source

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

  }
  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"
      ? { optionalOpenAIKeyReference: "{env:OPENAI_API_KEY}" }
      : {};
    let rendered = renderDeep(content, renderedGw, env, renderOptions);
    if (agent.id === "kilo" && mcpMode === "auto") {
      const ownedMcp = ownedMcpRegistration(agent.id, agentArgs);
      if (ownedMcp) {
        // Project exact owned registration into Kilo's highest user-controlled
        // layer. Route preflight rejects active org/managed sources that load

View on GitHub (pinned to 3ee70a1026)