Skip to content

fix(auth): honor --no-browser for Anthropic OAuth - #72416

Open
lgy1027 wants to merge 2 commits into
NousResearch:mainfrom
lgy1027:fix/anthropic-no-browser
Open

lgy1027 wants to merge 2 commits into
NousResearch:mainfrom
lgy1027:fix/anthropic-no-browser

Conversation

@lgy1027

@lgy1027 lgy1027 commented Jul 27, 2026

Copy link
Copy Markdown

Summary

  • thread the existing --no-browser preference into the Anthropic OAuth flow
  • skip automatic browser launch when the flag is set while continuing to print the authorization URL and accept a pasted code
  • cover both CLI argument forwarding and the browser-launch guard with regression tests

Root cause

The Anthropic auth branch called run_hermes_oauth_login_pure() without forwarding args.no_browser, and the OAuth helper had no caller-controlled browser option. This made the CLI flag ineffective for Anthropic even though sibling OAuth providers honor it.

Testing

  • python -m pytest tests/agent/test_anthropic_oauth_pkce.py tests/hermes_cli/test_auth_commands.py -q (58 passed)
  • python -m ruff check .
  • git diff --check

Closes #72393

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard provider/anthropic Anthropic native Messages API area/auth Authentication, OAuth, credential pools sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Jul 27, 2026
@teknium1

Copy link
Copy Markdown
Collaborator

Thanks for the focused fix. Current main still defines --no-browser in hermes_cli/subcommands/auth.py:38-42, but the Anthropic path calls the PKCE helper without forwarding it (hermes_cli/auth_commands.py:224-227). The helper then calls webbrowser.open() when a GUI is available (agent/anthropic_adapter.py:1520-1523), while retaining the URL and pasted-code flow at agent/anthropic_adapter.py:1509-1512 and 1528-1531.

Suggested changes

  • During maintainer salvage, relocate the auth-command forwarding regression assertion because the original target test was removed from current main; GitHub reports this branch as dirty.

Automated hermes-sweeper review.

@teknium1 teknium1 added the sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users label Jul 30, 2026
@lgy1027
lgy1027 force-pushed the fix/anthropic-no-browser branch from 6ab2ba5 to 5e2e254 Compare July 31, 2026 02:09
@lgy1027

lgy1027 commented Jul 31, 2026

Copy link
Copy Markdown
Author

Addressed in 5e2e25488. The auth-command forwarding regression assertion now lives in the current tests/hermes_cli/test_auth_commands.py structure, without restoring the removed legacy tests. The Anthropic adapter test separately verifies that open_browser=False suppresses webbrowser.open() while preserving the printed URL and pasted-code flow. The focused suite passes (22 tests), along with Ruff, compileall, and git diff --check;

@GottZ

GottZ commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Summary

One PR addresses #72393. #72416 fixes both confirmed failure points by forwarding the CLI’s --no-browser preference to the Anthropic OAuth helper and gating automatic browser launch on that preference while preserving the existing default behavior.

Related pull requests

  • fix(auth): honor --no-browser for Anthropic OAuth #72416 best fix — (+60/-3) — best fix; keep open with a salvage path: The diff passes open_browser=False from the Anthropic CLI path, requires both caller permission and GUI availability before invoking webbrowser.open(), and tests both seams. Consistent with the keep-open review on fix(auth): honor --no-browser for Anthropic OAuth #72416, the updated diff now places the forwarding regression assertion in the current tests/hermes_cli/test_auth_commands.py structure, addressing the review’s stated salvage requirement.

Suggested consolidation

Keep #72416 open with a salvage path: retain its focused two-seam implementation and current regression tests, which match the contributor-verified root cause and preserve open_browser=True for existing callers. It is the only PR in this complex, so there are no competing PRs to close as duplicates.

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
    I72393(["issue #72393 (open)"])
    P72416["PR #72416 (open)"]
    P72416 -->|best fix| I72393
    class I72393 open
    class P72416 open
    class P72416 best
    class P72416 target
    click I72393 "https://github.com/NousResearch/hermes-agent/issues/72393"
    click P72416 "https://github.com/NousResearch/hermes-agent/pull/72416"
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 (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: 4 kB of PR diffs, 6 kB of issue/PR text, 2 kB of discussion (2 comments), 2 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

@lgy1027

lgy1027 commented Aug 11, 2026

Copy link
Copy Markdown
Author

Hi, this is still waiting for approval to run the fork workflows. When you get a chance, could a maintainer approve the CI run? Thanks.

@lgy1027
lgy1027 force-pushed the fix/anthropic-no-browser branch from 5e2e254 to 12d876e Compare August 24, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists provider/anthropic Anthropic native Messages API sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hermes auth add anthropic: --no-browser is structurally unreachable, so unattended OAuth leaks a browser tab per retry

4 participants