Skip to content

Doctor reports Anthropic OK while real invocation fails; oneshot hides provider error #45155

Open

Description

@wkomers-hash

Summary

Hermes diagnostics reported Anthropic connectivity as OK, but an actual Anthropic oneshot failed. The CLI error shown to the user was only:

hermes -z: no final response was produced; treating the run as failed.

A direct API probe revealed the real provider error was an Anthropic billing/credit error:

HTTP 400 invalid_request_error: Your credit balance is too low to access the Anthropic API.

Hermes should surface that provider error in the oneshot failure, and hermes doctor should distinguish between "key exists / endpoint reachable" and "a real model invocation can succeed".

Environment

  • Hermes: 0.16.0
  • Platform: macOS
  • Python: 3.11.14
  • Active working config after recovery: ollama-cloud / qwen3-coder:480b

Reproduction

With ANTHROPIC_API_KEY configured:

hermes auth status anthropic

reported:

anthropic: logged in

and:

hermes doctor

reported:

✓ Anthropic API
✓ ollama-cloud

But an actual Anthropic invocation failed:

hermes -z 'Say exactly HERMES_ANTHROPIC_PROBE and nothing else.' \
  --provider anthropic \
  -m claude-sonnet-4-6 \
  --ignore-rules \
  --cli

Output:

hermes -z: no final response was produced; treating the run as failed.

Afterward, hermes auth list marked the Anthropic credential exhausted with:

invalid_request_error (400)

A direct Anthropic /v1/messages request using the same key/model returned:

status 400
invalid_request_error: Your credit balance is too low to access the Anthropic API.

Expected behavior

  1. hermes -z should surface the provider error that caused no final response, especially for structured provider errors such as Anthropic invalid_request_error.
  2. hermes doctor should not show ✓ Anthropic API in a way that implies a real invocation can succeed when the account has insufficient credits. It could report something like:
    • key present
    • endpoint reachable
    • invocation failed: insufficient credits / billing required
  3. If a failed provider request marks a credential exhausted, the user-facing error should explain why.

Actual behavior

  • Doctor showed Anthropic as OK.
  • Oneshot failed with only a generic "no final response" error.
  • The actionable reason was only discoverable through logs / credential exhaustion metadata / direct API probing.

Related migration/default-provider issue

Before switching Hermes back to a working default, the config pointed at:

model:
  default: gpt-5.3-codex
  provider: openai-codex

but hermes status showed OpenAI Codex auth was not logged in / missing access_token. A live probe failed with:

hermes -z: agent failed: Codex auth is missing access_token. Run `hermes auth` to re-authenticate.

Hermes may need a stronger migration/status guard to avoid leaving an unauthenticated provider as the default after updates, or at least flag the active default as unusable prominently.

Workaround

Switching the default back to a provider that passed a live invocation fixed Hermes locally:

hermes config set model.provider ollama-cloud
hermes config set model.default qwen3-coder:480b

Then:

hermes -z 'Say exactly HERMES_PROBE' --ignore-rules --cli

returned:

HERMES_PROBE

Security note

No secret values are included in this report.

Activity

  1. added
    type/bugSomething isn't working
    comp/cliCLI entry point, hermes_cli/, setup wizard
    P2Medium — degraded but workaround exists
    on Jun 12, 2026
  2. GottZ commented on Jul 29, 2026

    @GottZ

    This was generated by AI during triage.

    Summary

    One PR addresses issue #45155. #52473 targets the swallowed oneshot provider error by capturing redirected output, but it does not address the separate hermes doctor false-positive diagnostic.

    Related pull requests

    • fix(cli): surface provider errors in -z oneshot instead of swallowing them #52473 [closed] partial — (+78/-27) — partial fix; closed as implemented on main: the diff captures and surfaces provider/agent output when oneshot returns no final response, directly addressing the hidden Anthropic billing/authentication error, but leaves hermes doctor unchanged. It remains relevant as the proposed implementation, while contributor review documents that current main now provides the same user-facing guarantee through structured run_conversation() results and that this diff's _run_agent return-value assumption is stale.

    Suggested consolidation

    Merge none. Keep #52473 closed because its oneshot objective is implemented on main through the structured conversation-result path; keep issue #45155 open only for the unresolved hermes doctor distinction between credential/endpoint availability and successful model invocation.

    Complex graph

    flowchart LR
        classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
        classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
        classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
        classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
        classDef best stroke-width:3px,stroke:#b45309
        classDef target stroke-width:3px,stroke:#4338ca
        I45155(["issue #45155 (open)"])
        P52473["PR #52473 (closed)"]
        P52473 -.->|partial| I45155
        class I45155 open
        class I45155 target
        class P52473 closed
        click I45155 "https://github.com/NousResearch/hermes-agent/issues/45155"
        click P52473 "https://github.com/NousResearch/hermes-agent/pull/52473"
    
    Loading

    Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed or no verify verdict yet (state tag in the node label).

    Cross-PR triage: Reviewed 1 pull request and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 7 kB of PR diffs, 6 kB of issue/PR text, 1 kB of discussion (1 comments), 1 verify verdict. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

  3. teamster22 commented on Aug 28, 2026

    @teamster22

    Hit this on v0.20.6 (upstream 306db277, Debian 12, headless) with a subscription-OAuth credential rather than an API key, and traced the logged in false positive to a specific line. Adding it here since this issue's point 2 ("doctor/status should not imply a real invocation can succeed") is exactly the gap, and the cause turns out to be a deliberate fix for a different issue.

    The same three-way disagreement, on OAuth

    $ hermes auth status anthropic
    anthropic: logged in
    
    $ hermes auth list anthropic
    anthropic (1 credentials):
      #1  <label>    oauth   hermes_pkce  exhausted (58m 5s left) ←
    
    $ hermes -z "reply with OK only" --provider anthropic -m claude-opus-5
    hermes -z: agent failed: No Anthropic credentials found. Set ANTHROPIC_TOKEN or
    ANTHROPIC_API_KEY, run 'claude setup-token', or authenticate with 'claude /login'.
    

    Same shape as the original report — status says yes, list says exhausted, real invocation says no credentials. In my case the credential was genuinely unrecoverable (access token expired, refresh token rejected), so this wasn't a transient cooldown.

    Why status returns logged in

    PROVIDER_REGISTRY["anthropic"].auth_type is api_key, so get_auth_status() (hermes_cli/auth.py:7293) dispatches to get_api_key_provider_status() (:7204), whose logged_in is derived purely from whether a non-empty string came back:

    # hermes_cli/auth.py:7259
    "logged_in": bool(api_key) or actual_local_noauth,  # compat with OAuth status shape

    The string comes from _resolve_api_key_provider_secret() (:723). Its credential-pool fallback asks peek() first — which correctly returns None here, because peek() goes through _available_entries() and honors STATUS_EXHAUSTED. But the code then iterates pool.entries() and returns the first syntactically valid token regardless of status:

    # hermes_cli/auth.py:768-782
    for extra in pool.entries():
        if extra is not None and all(extra is not c for c in candidates):
            candidates.append(extra)
    ...
    for entry in candidates:
        key = getattr(entry, "access_token", "") or getattr(entry, "runtime_api_key", "")
        key = str(key).strip()
        if not has_usable_secret(key):
            continue
        if not _secret_matches_declared_prefix(provider_id, key):
            _warn_malformed_secret(provider_id, f"credential_pool:{provider_id}")
            continue
        return key, f"credential_pool:{provider_id}"

    entries() is an unfiltered snapshot — it returns EXHAUSTED and DEAD rows alongside healthy ones:

    def entries(self) -> List[PooledCredential]:
        with self._lock:
            return list(self._entries)

    An exhausted entry still holds a well-formed sk-ant-… string, so has_usable_secret() passes, the prefix check passes, and logged_in: True is returned for a credential the pool itself refuses to select. The peek() result — the one that respected status — gets overridden by the loop beneath it.

    The part worth flagging: this is a fix for #40960 colliding with this issue

    That entries() loop is not an oversight. #40960 reported that when all pool entries are in cooldown, _resolve_api_key_provider_secret() returned ("", ""), and the empty key produced a misleading 401 instead of the real 429/402. PR #40961 (open, unmerged as of writing) proposes exactly this remedy:

    After pool.peek() returns None (all entries in cooldown), fall through to iterate pool._entries and return the first entry's key with a logger.warning. This ensures the upstream API returns the actual error code and message.

    Current v0.20.6 already behaves this way. So the two issues pull in opposite directions on the same lines:

    Both are right, and neither references the other. The conflict is only real because one function serves both callers. Resolving it as stated in either issue alone will regress the other.

    Suggested shape

    Separate the two concerns rather than changing the resolver's return value:

    1. Have _resolve_api_key_provider_secret() return the entry status alongside the key (or expose a status-only helper), keeping [Bug] credential pool exhaustion causes misleading 401 instead of real 429/402 #40960's behavior intact for the request path.
    2. Gate get_api_key_provider_status()'s logged_in on that status, so a benched credential reports something like logged in (credential exhausted — not usable) instead of a bare logged in.

    That satisfies point 2 of this issue without reintroducing the misleading 401 from #40960.

    On the live-probe ask

    Strong +1 to distinguishing "key present / endpoint reachable" from "an invocation can succeed" — with one field note. hermes -z was the only signal that told me the truth here, but on a subscription-OAuth credential a naive probe has a known trap: a 429 on an sk-ant-oat-* token frequently means malformed request, not quota, because the OAuth path requires the Claude Code system prompt as the first system block. Hermes injects it on the real path (agent/anthropic_adapter.py), so an internal probe is fine, but a hand-rolled curl check reads as a false rate-limit. https://api.anthropic.com/api/oauth/usage returns real five_hour / seven_day utilization and is a cleaner health signal for OAuth credentials specifically.

    Field impact

    The false logged in cost about 10 hours of undetected downtime. Because fallback_providers was configured, the gateway kept answering on the fallback model while an explicitly-pinned Desktop client failed, so the only visible symptom was on one surface — and the two cheapest checks (auth status, plus a working chat) both read healthy. hermes auth reset also reports success in this state and changes nothing, since it clears the exhaustion flag rather than the dead refresh token.

    Recovery required hermes auth remove before hermes auth add — a newly added credential lands behind the dead one at priority: 0 and stays shadowed otherwise.

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

    P2Medium — degraded but workaround existsarea/install-updateInstaller, updater, packaging, wheels, doctorcomp/cliCLI entry point, hermes_cli/, setup wizardprovider/anthropicAnthropic native Messages APItype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions