Repository navigation
claude-subscription-directsdk: land 15 reviewed contributor fixes (#426 #382 #406 #421 #422 #423 #427 #425 #419 #416 #412 #404 #408 #410 #387) - #445
Merged
Conversation
… host The missing-CLI discovery tests pass only on hosts with no claude in a system prefix: _resolve falls back to /opt/homebrew/bin and /usr/local/bin, so a host with Claude Code installed there finds the real binary and the 'no claude' assertions fail. Patch _SYSTEM_PREFIXES empty on both the flat and package-relative directsdk_setup copies, and add a positive test that the prefix stays a fallback that never overrides an explicit command. The no-uid workspace case deletes os.getuid. In an environment without USER, _with_login_identity then falls back to pwd.getpwuid(os.getuid()) and raises AttributeError before the workspace branch under test runs. Give that case a synthetic USER.
Hermes core's plugin re-discovery evicts the plugin package from sys.modules; the registered profile survives, but its methods did a lazy relative import at call time. After eviction that fails as "No module named 'directsdk'", surfaced to gateway-served surfaces (mobile/desktop) as "Failed to initialize OpenAI client". Import directsdk and directsdk_setup once at module load and reference them from create_client/setup_status/discover_models/ fetch_account_usage, so no import runs at call time. tests/test_sysmodules_eviction.py: red on main (4 failed), green on this change (4 passed); full suite passes.
Hermes core can pass an OpenRouter-style canonical id such as anthropic/claude-sonnet-5 even when the config names claude-sonnet-5. _route_base only stripped a leading claude-, so the vendor prefix reached the native CLI, which 404s. A 404 is not an auth error, so the admission guard denied every retry and the turn silently fell back to another provider. Strip anthropic/ and openrouter/ before routing; leave other namespaces alone. Fixes #377
…laude A systemd service PATH can put an old Claude Code install ahead of the current one. With 2.1.148 the tool payload is dropped from the request and the model answers as a title generator. When the bare claude found on PATH is below the supported minimum, look for a newer executable in the install prefixes first. An explicit command override is never second-guessed. Fixes #380
… CLIs through which() _resolve runs on every turn, so the version check spawned `claude --version` before every request. Cache it per (realpath, mtime, size), so `claude update` is noticed and a transient failure is retried. The prefix scan used a bare os.path.join(prefix, 'claude'), which misses claude.exe / claude.cmd on Windows; use shutil.which per prefix and skip the PATH hit itself. Test fakes are named claude.cmd on Windows. CHANGELOG line for #380.
Hermes' auxiliary client cache closes a client bound to another live event loop. Client.close() cancelled every in-flight request on it, so two tool calls running in parallel (two vision_analyze calls in one step) could fail with 'Claude request cancelled' or 'Claude client is closed'. Each request owns and reaps its own native process, so closing needs no cleanup; Stream.close() and cancel() remain the explicit per-request stop paths. Fixes #378
…-contract test on the stream's own close Client.close() no longer cancels running requests (#378), so the _closed flag only made a cached client refuse every later call with 'Claude client is closed', the second symptom in the issue. Drop it. test_fail_closed_and_cancellation relied on Client.close() finalizing an unstarted stream; it now closes that stream itself. CHANGELOG line for the fix.
A 200 cut short raised ClaudeAPIError with status_code=None and the transport label only inside the prose, so core's message-based classifier saw an unknown error: no same-provider retry, no fallback chain, and no compression network-failure guard. Append the canonical wording core already matches (server disconnected, connection reset by peer, ...) for known relay failures, keeping the original label for reports. Unknown failures are unchanged. Fixes #396
…-close wording 'server disconnected' / 'connection reset by peer' / 'incomplete chunked read' are core's _SERVER_DISCONNECT_PATTERNS, which a large session on a non-reasoning model (claude-haiku-4-5, haiku-5-5) classifies as context_overflow with should_compress=True, so a dropped stream would have compressed the conversation. Use core's premature-close / connection-reset wording instead, which is always a connection timeout retry. The test now runs the wrapped error through core's real classify_api_error for both a non-reasoning and a reasoning model (red on the previous mapping: 4 Haiku cases compress). CHANGELOG line for #396.
…illed request The request that first crosses a plan limit is already billed; ask/stop only act on the next one. Add extra_usage_reserve_percent (e.g. 97): under ask/stop, refuse once an account-wide plan window reaches that percent, using the same zero-inference get_usage probe. Unset or invalid keeps 100, so existing installs are unchanged. notify/allow never probe. Refs #398
…imit_event; declare and document it The reserve only took effect on a get_usage probe, which runs only with no current answer. After any turn the process holds the turn's own rate_limit_event answer (using_overage false below 100%) for up to 15 minutes, so a running gateway kept sending past the reserve until the plan wall: the setting worked only on a fresh process. The event summary now carries the fuller account-wide window's utilization (unifiedWindows five_hour/seven_day), and under ask/stop with permitted overage a window at the reserve counts as spilling. The refusal says it was the reserve. The setting is declared in plugin.yaml (Desktop settings form) and documented in the README; CHANGELOG line under Added.
…hread per replayed frame Every replayed frame is one stdin write, and each write started a threading.Timer (one thread) as its stall guard: 602 thread starts for a 300-round history. One watchdog thread per request now guards every write. A write records when it began; the thread never sleeps past the timeout, so it wakes before the deadline of any write that began while it slept, then sleeps until exactly that deadline. Plugin CPU per call (4 vCPU Linux, Claude Code 2.1.327, loopback upstream): 100 rounds 0.19 -> 0.10 s, 300 rounds 0.42 -> 0.23 s. Claude Code's own CPU is unchanged.
… at 5m, not 1h Core clamps a delegated child to the 5m cache tier (_apply_child_cache_ttl: a subagent calls every few seconds for minutes and is gone, so the 2x write buys retention it never collects). Core can only clamp the cache_control markers it builds. On this route native places them, and a `claude -p` turn is Claude Code's main-conversation bucket, which asks for the one-hour tier on a subscription within plan usage. Every child request therefore wrote at 1h: 2x the input rate instead of 1.25x. The profile hook reads the cache scope core stamps on a child (sub_<hash>, prompt_cache_scope.is_sibling_cache_scope) and returns hermes_cache_ttl=5m; the spawn then starts native with CLAUDE_CODE_PROMPT_CACHE_TTL=5m (documented, Claude Code 2.1.242+). A tier the user exported wins. Every other request keeps native's default. CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL is deliberately not used: it governs requests outside the main bucket, and a -p turn is inside it.
…ss, not every call
…r loop's next 50 ms poll
…, as a real step does
…r a connection that is gone
…ts start, not later in its thread
…n three Claude Code versions
…riting under its temporary HOME at cleanup
… after its deadline or its cancellation
…er's deadline, inside a long poll
Native's limit message names a clock time ("resets 3:45pm") that core
cannot parse, so core never knew when a used-up window reopens. The
relay now keeps the reset of a 429 whose unified status is "rejected",
and the error carries it as body["resets_at"], the field core reads for
its fallback bench and limit notice.
This was referenced Nov 19, 2026
[claude-subscription-directsdk] test: keep missing-CLI and no-uid tests independent of the host
#426
Closed
Closed
Closed
metahacker
added a commit
to metahacker/hermes-official-plugins
that referenced
this pull request
Nov 19, 2026
…ession-steer: main's fixes carried onto the kept process NousResearch#445 lands 15 fixes on main. Where a kept process takes the same path, it gets the same fix: close() no longer refuses or cancels a call, it ends the kept process (NousResearch#378); a delegated child's 5m cache tier is in the launch env and so in what a kept process is matched on (NousResearch#416); an incomplete upstream answer keeps its transport phrase and plan-window reset (NousResearch#396, NousResearch#387); and one stdin watchdog per request serves a kept step's frames too (NousResearch#419). The watchdog ends with its step, so a kept process between steps holds neither a thread nor its client. One-shots mount no MCP server here, so the frozen-copy test checks that a one-shot names none instead of the inert helper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fifteen Claude subscription plugin fixes from contributors, landed together. Each one fixes something users hit, for example model ids like
anthropic/claude-sonnet-5failing, parallel calls cancelling each other, or a dropped connection compressing your conversation. Every commit keeps its author. This PR only stacks them on current main and resolves the CHANGELOG line each one adds.Every PR below was reviewed: its premise was checked on main, and its new tests fail on main's code and pass on its head. Where we changed a PR, our commits sit on top of the contributor's, authored Teknium.
__init__.py)anthropic/claude-sonnet-5) work instead of 404 + admission refusal on every retryclaudeearly on PATH is skipped for a supported one;--versionasked once per binary (our fix); Windows.exe/.cmdlookuprate_limit_event(our fix)max_concurrentslot never starts after its deadline or cancellationevals/ci.shalso runs on Windows (CI only)Conflict resolutions:
CHANGELOG.md### Fixed: kept both sides at each step. Every added line from every PR is present, which was checked line by line.__init__.py([claude-subscription-directsdk] fix(directsdk): survive deletion of core's frozen import copy #406 over fix(directsdk): resolve directsdk imports at module load (fixes #381) #382): kept fix(directsdk): resolve directsdk imports at module load (fixes #381) #382's call-time import fix, as the review called for.directsdk.py(fix(directsdk): tell Hermes when a used-up plan window reopens #387 over fix(claude-directsdk): keep a relay transport failure classifiable #427): both edit the sameraise ClaudeAPIError(...)for an incomplete upstream response. The result keeps fix(claude-directsdk): keep a relay transport failure classifiable #427's classifiable message and passes fix(directsdk): tell Hermes when a used-up plan window reopens #387'sresets_at=admission.reset_at.Tests: full plugin suite on the stacked head against hermes-agent main
502009cc+: 655 passed, 9 subtests passed. No merge commits (git rev-list --merges origin/main..HEADis empty).Not covered: no live subscription turns were run. Everything is offline tests with a real Claude Code 2.1.292 binary, plus code reading.
Fixes #381, fixes #377, fixes #380, fixes #378, fixes #396. Part of #398 (item 1).
Supersedes #426, #382, #406, #421, #422, #423, #427, #425, #419, #416, #412, #404, #408, #410, #387. Each of those will be closed with a credit comment naming its landed commits.