diff --git a/hindsight-api-slim/hindsight_api/mcp_tools.py b/hindsight-api-slim/hindsight_api/mcp_tools.py index 24dfc7339..036cd0360 100644 --- a/hindsight-api-slim/hindsight_api/mcp_tools.py +++ b/hindsight-api-slim/hindsight_api/mcp_tools.py @@ -644,6 +644,7 @@ async def retain( result = await memory.submit_async_retain( bank_id=target_bank, contents=[content_dict], + strategy=content_dict.pop("strategy", None), request_context=request_context, ) return { @@ -698,6 +699,7 @@ async def retain( result = await memory.submit_async_retain( bank_id=target_bank, contents=[content_dict], + strategy=content_dict.pop("strategy", None), request_context=request_context, ) return { diff --git a/hindsight-api-slim/tests/test_mcp_tools.py b/hindsight-api-slim/tests/test_mcp_tools.py index 17aa2bb0f..fa9b76d03 100644 --- a/hindsight-api-slim/tests/test_mcp_tools.py +++ b/hindsight-api-slim/tests/test_mcp_tools.py @@ -1062,6 +1062,25 @@ async def test_retain_with_document_id(self, mock_memory): contents = call_args.kwargs["contents"] assert contents[0]["document_id"] == "doc-1" + async def test_retain_passes_strategy_to_the_worker(self, mock_memory): + """The strategy must travel as the submit argument, not inside the content item. + + ``submit_async_retain`` only puts a strategy into the task payload when it + is passed as the keyword; a strategy left inside the content dict never + reaches the worker, so every strategy override silently falls back to the + bank configuration. + """ + mcp = _make_mcp_server(mock_memory, {"retain"}, include_bank_id=True) + await _tools(mcp)["retain"].fn(content="test", strategy="documents") + call_args = mock_memory.submit_async_retain.call_args + assert call_args.kwargs["strategy"] == "documents" + + async def test_retain_passes_strategy_single_bank(self, mock_memory): + mcp = _make_mcp_server(mock_memory, {"retain"}, include_bank_id=False) + await _tools(mcp)["retain"].fn(content="test", strategy="documents") + call_args = mock_memory.submit_async_retain.call_args + assert call_args.kwargs["strategy"] == "documents" + async def test_retain_without_new_params_backward_compat(self, mock_memory): """Existing behavior preserved when new params not provided.""" mcp = _make_mcp_server(mock_memory, {"retain"})