fix(memory_manager): load schemas before mutating state in add_provider()#9997
Closed
zhouhe-xydt wants to merge 1 commit into
Closed
Conversation
…er() add_provider() previously set _has_external=True and appended the provider to _providers before calling provider.get_tool_schemas(). If get_tool_schemas() raised an exception, the failed provider remained half-registered and blocked all future external providers. Load and cache schemas first, then mutate state only after success. Also cache the schema list to avoid consuming a generator twice. Fixes NousResearch#9948
This was referenced Apr 22, 2026
Collaborator
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
Fixes a bug where
MemoryManager.add_provider()could leave a failed external provider half-registered, blocking all future external providers.Root cause
add_provider()set_has_external = Trueand appended the provider to_providersbefore callingprovider.get_tool_schemas(). Ifget_tool_schemas()raised an exception, the manager was left in a poisoned state: the failed provider remained in_providersand subsequent external providers were rejected.What changed
provider.get_tool_schemas()before mutating any internal state._has_external = Trueand append to_providersafter schemas load successfully.list(...)so the logger doesn't accidentally consume a generator a second time.Related issue
Fixes #9948
Testing
py_compileget_tool_schemas()no longer leaves the manager in a half-registered state.