fix: _is_openai_client_closed false positive with openai SDK method-style is_closed#4378
Open
saulmc wants to merge 1 commit intoNousResearch:mainfrom
Open
fix: _is_openai_client_closed false positive with openai SDK method-style is_closed#4378saulmc wants to merge 1 commit intoNousResearch:mainfrom
saulmc wants to merge 1 commit intoNousResearch:mainfrom
Conversation
a76c791 to
9262fef
Compare
…tyle is_closed The openai SDK (>=2.21.0) exposes is_closed as a method, not a property. bool(getattr(client, "is_closed", False)) returns True for the bound method object itself, causing every API call to falsely detect the shared client as closed and recreate it — adding ~2 extra TCP+TLS round trips per call. Call is_closed() when callable; check the return value otherwise. Handles both method-style (openai SDK) and attribute-style (CopilotACPClient, test fakes). Fixes NousResearch#4377
9262fef to
340cb04
Compare
saulmc
added a commit
to xmtplabs/convos-assistants
that referenced
this pull request
Apr 1, 2026
…ith upstream PR
- Use (cfg.get("agent") or {}) to handle null values so the
HERMES_REASONING_EFFORT env var fallback still works
- Align monkey-patch with the version submitted upstream
(NousResearch/hermes-agent#4378)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
saulmc
added a commit
to xmtplabs/convos-assistants
that referenced
this pull request
Apr 1, 2026
…ith upstream PR
- Use (cfg.get("agent") or {}) to handle null values so the
HERMES_REASONING_EFFORT env var fallback still works
- Align monkey-patch with the version submitted upstream
(NousResearch/hermes-agent#4378)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
saulmc
added a commit
to xmtplabs/convos-assistants
that referenced
this pull request
Apr 1, 2026
…ed false positive (#809) * fix(hermes): wire config.yaml through to AIAgent + fix client is_closed false positive AgentRunner bypassed several config.yaml sections that the upstream Hermes gateway/cli properly pass to AIAgent: - provider_routing (only, ignore, order, sort, require_parameters, data_collection) - fallback_providers / fallback_model - agent.reasoning_effort This meant our provider_routing.only restriction was dead config — OpenRouter could route to any provider. Also monkey-patches _is_openai_client_closed to fix an upstream bug where openai SDK's is_closed (a method) is checked via bool(getattr(client, "is_closed", False)) — the bound method is always truthy, so every API call falsely detects the shared client as closed and recreates it, adding ~2 unnecessary TCP+TLS round trips per call. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(hermes): handle agent: null in config.yaml + align monkey-patch with upstream PR - Use (cfg.get("agent") or {}) to handle null values so the HERMES_REASONING_EFFORT env var fallback still works - Align monkey-patch with the version submitted upstream (NousResearch/hermes-agent#4378) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore(hermes): replace [all] with specific extras for hermes-agent .[all] installs every optional dependency (Matrix, Telegram, Discord, Slack, SMS, DingTalk, voice, Modal, etc.) — most of which we don't use. The matrix extra in particular requires python-olm which needs cmake and C++ compilation, breaking local dev on macOS. Install only the extras we actually use: cron, honcho, mcp, pty. Applied to both Dockerfile and install-deps.sh. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore(hermes): remove unused honcho session key from AIAgent init We don't use honcho and just removed the dependency. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(hermes): remove @staticmethod from monkey-patch function staticmethod descriptor assigned to an instance attribute isn't callable — would raise TypeError at runtime. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
_is_openai_client_closedto callis_closed()when it's callable instead of checking truthiness of the bound method objectis_closedclientWhy
The openai SDK (
>=2.21.0) exposesis_closedas a method, not a property:The current check
bool(getattr(client, "is_closed", False))returnsTruefor the bound method object itself (all callables are truthy), so every API call falsely detects the shared client as closed and recreates it — adding an unnecessary TCP+TLS round trip per call to replace a healthy client.Existing tests don't catch this because
FakeRequestClientdoesn't defineis_closed, sogetattrreturns theFalsedefault and falls through to the_client.is_closedcheck which works correctly.Fixes #4377