Skip to content

feat(memory): allow disabling built-in memory toolfeat(memory): allow disabling built-in memory tool - #39531

Closed
MyQiongbao wants to merge 1 commit into
NousResearch:mainfrom
MyQiongbao:feat/disable-builtin-memory-tool
Closed

MyQiongbao wants to merge 1 commit into
NousResearch:mainfrom
MyQiongbao:feat/disable-builtin-memory-tool

Conversation

@MyQiongbao

Copy link
Copy Markdown

Closes #39492

What does this PR do?

Adds memory.builtin_tool.enabled to allow deployments to hide the built-in global memory tool while keeping external memory providers enabled.

memory:
  builtin_tool:
    enabled: false

Default behavior remains unchanged: the built-in memory tool is still exposed unless this option is explicitly set to false.

This is useful for multi-user API/gateway deployments where external memory providers can scope memory per session/user, but the built-in tool writes to
global MEMORY.md and USER.md.

## Related Issue

Closes #39492

## Type of Change

- [ ] 🐛 Bug fix (non-breaking change that fixes an issue)
- [x] ✨ New feature (non-breaking change that adds functionality)
- [ ] 🔒 Security fix
- [x] 📝 Documentation update
- [x] ✅ Tests (adding or improving test coverage)
- [ ] ♻️ Refactor (no behavior change)
- [ ] 🎯 New skill (bundled or hub)

## Changes Made

- agent/memory_config.py: add helper for reading memory.builtin_tool.enabled
- model_tools.py: filter the built-in memory tool from tool definitions when disabled
- agent/agent_init.py: record the built-in memory tool config on the agent
- hermes_cli/config.py: add the default config value
- cli-config.yaml.example: document the new config key
- website/docs/user-guide/configuration.md: document the new config key
- website/docs/user-guide/features/memory.md: document the new config key
- tests/test_model_tools.py: add coverage for default enabled and explicit disabled behavior
- tests/run_agent/test_memory_provider_init.py: verify disabling the built-in tool does not disable external provider tools

## How to Test

1. Run targeted model/tool initialization tests:

uv run --extra dev python -m pytest tests/test_model_tools.py tests/run_agent/test_memory_provider_init.py tests/tools/test_memory_tool_schema.py -q -o
addopts=

2. Run memory provider tests:

uv run --extra dev python -m pytest tests/agent/test_memory_provider.py -q -o addopts=

3. Run lint/checks:

uv run --extra dev ruff check agent/memory_config.py model_tools.py agent/agent_init.py tests/test_model_tools.py tests/run_agent/
test_memory_provider_init.py
git diff --check

## Checklist

### Code

- [x] I've read the Contributing Guide (https://github.com/NousResearch/hermes-agent/blob/main/CONTRIBUTING.md)
- [x] My commit messages follow Conventional Commits (https://www.conventionalcommits.org/) (fix(scope):, feat(scope):, etc.)
- [x] I searched for existing PRs (https://github.com/NousResearch/hermes-agent/pulls) to make sure this isn't a duplicate
- [x] My PR contains only changes related to this fix/feature (no unrelated commits)
- [ ] I've run pytest tests/ -q and all tests pass
- [x] I've added tests for my changes (required for bug fixes, strongly encouraged for features)
- [x] I've tested on my platform: Linux container

### Documentation & Housekeeping

- [x] I've updated relevant documentation (README, docs/, docstrings) — or N/A
- [x] I've updated cli-config.yaml.example if I added/changed config keys — or N/A
- [x] I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
- [x] I've considered cross-platform impact (Windows, macOS) per the compatibility guide
  (https://github.com/NousResearch/hermes-agent/blob/main/CONTRIBUTING.md#cross-platform-compatibility) — or N/A

- [x] I've updated tool descriptions/schemas if I changed tool behavior — or N/A

## Screenshots / Logs

N/A

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have tool/memory Memory tool and memory providers comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard type/docs Documentation improvements labels Jun 5, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for isolating the built-in schema from external provider tools. The request remains relevant on current main, but the current patch needs a scope decision before salvage.

Problems

  • The schema filter does not stop the global built-in store from reaching the model. Current main loads it when memory_enabled or user_profile_enabled is true (agent/agent_init.py:1363-1375) and injects its MEMORY.md / USER.md snapshots independently of tool availability (agent/system_prompt.py:460-469). That leaves the multi-user isolation rationale incomplete.
  • agent._builtin_memory_tool_enabled is assigned in the proposed agent/agent_init.py:1065, but the proposed filter independently reloads config in model_tools.py; the stored value has no reader.
  • The new provider test omits the built-in-memory enable flags and does not test prompt injection, so it misses the deployment state described in the PR.

Suggested changes

  • Decide whether this flag is schema-only or disables the built-in memory subsystem; if it is for isolation, gate the global-store prompt path too while preserving provider tools.
  • Add a temp-HERMES_HOME integration test covering provider tools, built-in schema visibility, and built-in prompt blocks.

Automated hermes-sweeper review.

Comment thread model_tools.py

# Ask the registry for schemas (only returns tools whose check_fn passes)
filtered_tools = registry.get_definitions(tools_to_include, quiet=quiet_mode)
filtered_tools = _filter_builtin_memory_tool(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes only the API schema. With memory_enabled or user_profile_enabled still true, current main loads the global store in agent/agent_init.py:1363-1375 and injects its snapshots in agent/system_prompt.py:460-469; that does not fully address the multi-user isolation rationale. Please define whether this flag is schema-only or must also gate built-in prompt/store behavior.

Comment thread agent/agent_init.py
@@ -1064,6 +1065,7 @@ def init_agent(
agent._memory_store = None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This attribute is not read by this PR: the schema path independently reloads config in model_tools.py. Please remove it or use one shared decision path so the new configuration cannot silently diverge between agent state and tool construction.

@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 14, 2026
@teknium1 teknium1 added the area/memory Memory subsystem: store, providers, sync, background reviews label Jul 19, 2026
@teknium1

Copy link
Copy Markdown
Collaborator

Fixed on main via #90559 (salvage of #90413). You were among the earliest (Jun 5) to propose hiding the built-in memory tool while keeping external providers — thank you, credited here. The landed approach gates via the existing check_fn on the store flags (memory_enabled / user_profile_enabled) rather than a new builtin_tool.enabled key, so no new config surface was needed. Closing as covered on main.

@teknium1 teknium1 closed this Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/memory Memory subsystem: store, providers, sync, background reviews comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data tool/memory Memory tool and memory providers type/docs Documentation improvements type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add config option to disable the built-in memory tool while keeping memory providers enabled

3 participants