fix(search_v2): use existence check for strict_date_filter boolean override

Replace 'context_value or yaml_value' with an existence-based check so
that a runtime-injected False can explicitly disable a YAML-true
strict_date_filter flag, consistent with the read_step_format_session fix.
This commit is contained in:
sa-buc 2026-08-05 18:49:44 +08:00
parent 82a4acdc9c
commit 8a1aeef580
2 changed files with 13 additions and 8 deletions

View file

@ -158,9 +158,12 @@ class SearchStep(BaseStep):
expand_links_enabled: bool = bool(self.kwargs.get("expand_links", True))
max_links_per_direction: int = int(self.kwargs.get("max_links_per_direction", 10))
tool_context_id: str = (self.context.get("tool_context_id", "") or "").strip()
strict_date_filter: bool = bool(
self.context.get("strict_date_filter") or self.kwargs.get("strict_date_filter", False),
)
# Injected value takes precedence over YAML kwargs; check existence
# (not truthiness) so an explicit False can disable a YAML-true flag.
_strict_date_filter = self.context.get("strict_date_filter")
if _strict_date_filter is None:
_strict_date_filter = self.kwargs.get("strict_date_filter", False)
strict_date_filter: bool = bool(_strict_date_filter)
if not query:
self.context.response.success = False

View file

@ -118,9 +118,12 @@ class SearchV2Step(_ToolContextDedupMixin, BaseStep):
expand_links_enabled: bool = bool(self.kwargs.get("expand_links", True))
max_links_per_direction: int = int(self.kwargs.get("max_links_per_direction", 10))
tool_context_id: str = (self.context.get("tool_context_id", "") or "").strip()
strict_date_filter: bool = bool(
self.context.get("strict_date_filter") or self.kwargs.get("strict_date_filter", False),
)
# Injected value takes precedence over YAML kwargs; check existence
# (not truthiness) so an explicit False can disable a YAML-true flag.
_strict_date_filter = self.context.get("strict_date_filter")
if _strict_date_filter is None:
_strict_date_filter = self.kwargs.get("strict_date_filter", False)
strict_date_filter: bool = bool(_strict_date_filter)
if not query:
self.context.response.success = False
@ -302,8 +305,7 @@ class SearchV2Step(_ToolContextDedupMixin, BaseStep):
response = await self.run_job("compressor", text=body, queries=queries)
except Exception as exc: # pylint: disable=broad-except
self.logger.warning(
f"[{self.name}] session body compression raised path={path!r} "
f"error={exc!r}; keeping original",
f"[{self.name}] session body compression raised path={path!r} " f"error={exc!r}; keeping original",
)
return
compressed = str(response.answer or "").strip()