@@ -320,23 +320,21 @@ def create_tool_schemas(self) -> List["ToolDefinition"]:
320320 )
321321
322322 @property
323- def default_requires_instance (self ) -> Optional [ bool ] :
324- """Default ``requires_instance`` flag for this provider's tools.
323+ def requires_redis_instance (self ) -> bool :
324+ """Whether this provider's tools require a Redis instance .
325325
326- Returns:
327- * ``True`` if tools always require a Redis instance.
328- * ``False`` if tools never require a Redis instance.
329- * ``None`` (default) to derive from whether ``redis_instance`` was provided.
326+ Returns ``True`` if the provider was initialized with a ``redis_instance``.
327+ Subclasses can override to always return ``True`` or ``False`` regardless
328+ of initialization.
330329 """
331-
332- return None
330+ return self .redis_instance is not None
333331
334332 def tools (self ) -> List ["Tool" ]:
335333 """Return the concrete tools exposed by this provider.
336334
337335 The default implementation builds :class:`Tool` objects from
338336 :meth:`create_tool_schemas`, using the ``capability`` on each
339- :class:`ToolDefinition` and :attr:`default_requires_instance ` to
337+ :class:`ToolDefinition` and :attr:`requires_redis_instance ` to
340338 populate :class:`ToolMetadata`.
341339
342340 Each tool's :pyattr:`Tool.invoke` closure is wired directly to the
@@ -351,14 +349,6 @@ def tools(self) -> List["Tool"]:
351349 # ignore :meth:`create_tool_schemas` entirely.
352350 schemas : List [ToolDefinition ] = self .create_tool_schemas ()
353351
354- # Determine default requires_instance. ``None`` means derive from the
355- # presence of ``redis_instance``.
356- requires_instance = (
357- bool (self .redis_instance )
358- if self .default_requires_instance is None
359- else bool (self .default_requires_instance )
360- )
361-
362352 tools : List ["Tool" ] = []
363353 for schema in schemas :
364354 capability = schema .capability
@@ -373,7 +363,7 @@ def tools(self) -> List["Tool"]:
373363 description = schema .description ,
374364 capability = capability ,
375365 provider_name = self .provider_name ,
376- requires_instance = requires_instance ,
366+ requires_instance = self . requires_redis_instance ,
377367 )
378368
379369 # Derive operation name and look up the corresponding method.
0 commit comments