{"record":{"id":"e216477f872904e7","repo":"headroomlabs-ai/headroom","slug":"error-e","errorCode":null,"errorMessage":"Error: {e}","messagePattern":"Error: (.+?)","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"headroom/cli/learn.py","lineNumber":207,"sourceCode":"        if ignored:\n            verb = \"is\" if len(ignored) == 1 else \"are\"\n            click.echo(f\"Note: {', '.join(ignored)} {verb} ignored with --verbosity.\")\n        _run_verbosity(\n            project=project,\n            analyze_all=analyze_all,\n            apply=apply,\n            agent=agent,\n            llm_judge=llm_judge,\n            model=model,\n        )\n        return\n\n    # Resolve model early to fail fast with a clear message\n    try:\n        resolved_model = model or _detect_default_model()\n    except RuntimeError as e:\n        click.echo(f\"Error: {e}\")\n        raise SystemExit(1) from None\n\n    analyzer = SessionAnalyzer(model=resolved_model)\n\n    # Determine which agents to scan\n    agent_configs: list[tuple[str, LearnPlugin]] = []\n\n    if agent == \"auto\":\n        detected = auto_detect_plugins()\n        if not detected:\n            click.echo(\"No coding agent data found.\")\n            return\n        click.echo(f\"Detected agents: {', '.join(p.display_name for p in detected)}\")\n        agent_configs = [(p.name, p) for p in detected]\n    else:\n        selected = get_plugin(agent)\n        agent_configs = [(selected.name, selected)]\n\n    total_projects = 0","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/cli/learn.py#L189-L225","documentation":"In `headroom learn`, the LLM model id is resolved early — either from the --model option or by _detect_default_model(). If detection fails (no credentials/config from which a default model can be inferred), the RuntimeError message is echoed as 'Error: {e}' and the command exits 1. This is a deliberate fail-fast so the (expensive) session analysis never starts without a usable model.","triggerScenarios":"Running `headroom learn` (or `headroom learn analyze`) with no --model while _detect_default_model() cannot find a default — e.g. no ANTHROPIC_API_KEY / OPENAI_API_KEY / agent config exposing a model, or no supported agent on the machine.","commonSituations":"Fresh machines or CI with no API keys in env; keys present but in a shell file not sourced into this session; headroom config that has never been initialized; detection supporting only specific providers.","solutions":["Pass the model explicitly: headroom learn --model claude-sonnet-4-5 (or your provider's id)","Export the credentials _detect_default_model looks for (e.g. ANTHROPIC_API_KEY / OPENAI_API_KEY) and retry","Run headroom's config/init command for your provider so a default model is recorded","Read the RuntimeError text echoed after 'Error:' — it names the specific thing detection lacked"],"exampleFix":"# before\n$ headroom learn\n# Error: no default model detected; set --model or configure credentials\n\n# after\n$ export ANTHROPIC_API_KEY=sk-ant-...\n$ headroom learn --model claude-sonnet-4-5","handlingStrategy":"try-catch","validationCode":"import os\nmodel = os.environ.get(\"HEADROOM_MODEL\") or (\n    \"claude-sonnet-4-5\" if os.environ.get(\"ANTHROPIC_API_KEY\") else None\n)\nif model is None and not os.environ.get(\"OPENAI_API_KEY\"):\n    raise SystemExit(\"no model resolvable — pass --model or export an API key\")","typeGuard":null,"tryCatchPattern":"try:\n    subprocess.run([\"headroom\", \"learn\", \"--model\", model, ...], check=True)\nexcept subprocess.CalledProcessError as e:\n    if e.returncode == 1 and \"Error:\" in (e.stdout or \"\"):\n        # model detection failed upstream — surface the message, do not retry blind\n        print(e.stdout)","preventionTips":["Always pass --model explicitly in automated runs of `headroom learn`","Export provider API keys in the environment that runs learn","Treat a fast 'Error:' exit as configuration failure, not a transient error — do not retry unchanged"],"tags":["cli","learn","model-detection","configuration","fail-fast"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}