Skip to content

Headless --scan/--hack/--plan/--agent require OpenHack login even when a BYOK provider is selected #38

Open

Description

@shivaylamba

Summary

The headless commands (--scan, --hack, --plan, --agent) refuse to run unless an OpenHack account key is set, even when a bring-your-own-key provider is selected and has its own key. The TUI's /scan accepts the same setup.

Reproduce

On main (6a0675e), with no OpenHack key and a fresh HOME so no saved config is involved:

LLM_PROVIDER=nebius NEBIUS_API_KEY=anything uv run openhack --scan .

Output:

Error: not logged in.
Run 'openhack --login' to set up your account, or set OPENHACK_API_KEY.

In the same environment, OpenHack's own provider code says the provider is usable:

settings.llm_provider          -> "nebius"
providers.is_connected("nebius") -> True
settings.openhack_api_key      -> None

The same thing happens with any BYOK provider (OpenRouter, Groq, Together, Ollama, ...).

Cause

All four handlers in openhack/__main__.py start with:

if not settings.openhack_api_key:
    print("Error: not logged in.")
    return

This check dates from 2a90fe3 (2026-06-03), when the hosted OpenHack service was the only provider. Bring-your-own-key support came later in 5eb0a93 (2026-07-01). It made LLMClient resolve the selected provider and raise its own "export " error, but it didn't update these checks. The TUI already uses provider_registry.is_connected(active_provider) (openhack/tui.py, before a scan starts), so headless mode and the TUI disagree.

Suggested fix

Check credentials for the selected provider instead of always requiring an OpenHack key:

def _has_llm_credentials() -> bool:
    from openhack import providers
    from openhack.config import settings

    if settings.llm_provider == "openhack":
        if settings.openhack_api_key:
            return True
        print("Error: not logged in.")
        print("Run 'openhack --login' to set up your account, or set OPENHACK_API_KEY.")
        return False

    resolved = providers.resolve(settings.llm_provider)
    if resolved is None:
        print(f"Error: unknown LLM provider '{settings.llm_provider}'.")
        return False
    if resolved.missing_key_env:
        print(f"Error: {settings.llm_provider} is selected but {resolved.missing_key_env} is not set.")
        return False
    return True

Then replace each of the four checks with if not _has_llm_credentials(): return. I have this working locally with tests (BYOK with a key passes, BYOK without a key names the missing env var, hosted OpenHack still requires login) and am happy to open a PR.

If requiring an account for headless runs is intentional, the error message should say so, because right now it reads as if the BYOK key wasn't found.

Activity

  1. harshitgavita-07 commented on Nov 10, 2026

    @harshitgavita-07

    Is a PR for this still in flight? The suggested fix above reads complete (provider-aware credential check for the headless commands). If it is not about to be opened, I am happy to pick it up as written, with the BYOK / hosted-login tests described. If it is already on its way, I will leave it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions