Skip to content

fix(memory_manager): load schemas before mutating state in add_provider()#9997

Closed
zhouhe-xydt wants to merge 1 commit into
NousResearch:mainfrom
zhouhe-xydt:fix/9948-memory-manager-half-registered-provider
Closed

fix(memory_manager): load schemas before mutating state in add_provider()#9997
zhouhe-xydt wants to merge 1 commit into
NousResearch:mainfrom
zhouhe-xydt:fix/9948-memory-manager-half-registered-provider

Conversation

@zhouhe-xydt

Copy link
Copy Markdown

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 = True and appended the provider to _providers before calling provider.get_tool_schemas(). If get_tool_schemas() raised an exception, the manager was left in a poisoned state: the failed provider remained in _providers and subsequent external providers were rejected.

What changed

  1. Load and cache provider.get_tool_schemas() before mutating any internal state.
  2. Only set _has_external = True and append to _providers after schemas load successfully.
  3. Cache the schema list as list(...) so the logger doesn't accidentally consume a generator a second time.

Related issue

Fixes #9948

Testing

  • Verified Python syntax with py_compile
  • Logic validated with a standalone regression test confirming that a failed get_tool_schemas() no longer leaves the manager in a half-registered state.

…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
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have tool/memory Memory tool and memory providers labels Apr 26, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #13224 — same fix: defer _has_external and _providers mutation until after get_tool_schemas() succeeds in MemoryManager.add_provider(). Both fix #9948.

@zhouhe-xydt zhouhe-xydt closed this May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MemoryManager add_provider() leaves failed external provider half-registered

2 participants