Skip to content

Conversation

@abrookins
Copy link
Collaborator

@abrookins abrookins commented Dec 10, 2025

Summary

Fixes #85

The MCP server's search_long_term_memory tool was failing with:

search_long_term_memory() missing 1 required positional argument: 'background_tasks'

Root Cause

The core API function search_long_term_memory in api.py requires a HybridBackgroundTasks parameter, but the MCP function was not passing it when calling core_search_long_term_memory.

Fix

Create a HybridBackgroundTasks instance and pass it to the core function, following the same pattern already used by other MCP functions like memory_prompt and create_long_term_memory.

Changes

  • agent_memory_server/mcp.py: Added HybridBackgroundTasks instance creation and pass it to core_search_long_term_memory
  • tests/test_mcp.py: Added regression test test_search_long_term_memory_passes_background_tasks to ensure background_tasks is always passed; also updated existing test mock signature

Testing

  • New regression test specifically verifies background_tasks is passed correctly

The MCP server's search_long_term_memory tool was failing with:
'search_long_term_memory() missing 1 required positional argument: background_tasks'

The core API function requires a HybridBackgroundTasks parameter, but the MCP
function was not passing it. This fix creates a HybridBackgroundTasks instance
and passes it to the core function, following the same pattern used by other
MCP functions like memory_prompt.

Also adds a regression test to ensure background_tasks is always passed.

Fixes #85
Copilot AI review requested due to automatic review settings December 10, 2025 17:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in the MCP server's search_long_term_memory tool where it was missing the required background_tasks parameter when calling the core API function core_search_long_term_memory. This was causing runtime failures with a "missing 1 required positional argument: 'background_tasks'" error. The fix properly creates a HybridBackgroundTasks instance and passes it to the core function, following the established pattern used by other MCP tools like memory_prompt.

Key Changes

  • Added HybridBackgroundTasks instantiation in the MCP search_long_term_memory tool and passed it to the core API function
  • Updated existing test mock signature to include the background_tasks parameter
  • Added comprehensive regression test to ensure background_tasks is always passed correctly

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

File Description
agent_memory_server/mcp.py Fixed search_long_term_memory by creating and passing HybridBackgroundTasks instance to core function (lines 524-529)
tests/test_mcp.py Updated mock signature in test_default_namespace_injection to include background_tasks parameter (line 183), and added new regression test test_search_long_term_memory_passes_background_tasks (lines 594-628)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Andrew Brookins added 2 commits December 10, 2025 09:52
The parse_datetime function was failing when receiving Unix timestamps
as strings (e.g., '1765388915.12') because it tried to parse them as
ISO format strings. This fix tries to parse string values as floats
first before falling back to ISO format parsing.
@abrookins abrookins merged commit eb46380 into main Dec 10, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP stdio: search_long_term_memory() missing required positional argument 'background_tasks'

2 participants