Merge pull request #5166 from QlikChrister/fix/tool-rag-timeout-keyword-fallback

fix(agent): fall back to keyword tool selection when retrieval times out
This commit is contained in:
Boody
2026-07-04 23:16:52 +03:00
committed by GitHub
+8 -2
View File
@@ -2532,11 +2532,17 @@ async def stream_agent_loop(
) )
logger.info(f"[tool-rag] Retrieved tools for query: {sorted(_relevant_tools - ALWAYS_AVAILABLE)}") logger.info(f"[tool-rag] Retrieved tools for query: {sorted(_relevant_tools - ALWAYS_AVAILABLE)}")
except asyncio.TimeoutError: except asyncio.TimeoutError:
# Leave _relevant_tools unset so the keyword fallback
# below still runs. Hard-coding ALWAYS_AVAILABLE here
# skipped the deterministic keyword hints whenever the
# embedding backend was slow (e.g. a remote endpoint
# cold-loading its model), silently stripping email/
# calendar tools from queries that named them outright.
logger.warning( logger.warning(
"[tool-rag] Retrieval exceeded %.1fs; falling back to always-available tools", "[tool-rag] Retrieval exceeded %.1fs; falling back to keyword tool selection",
_TOOL_SELECTION_TIMEOUT_SECONDS, _TOOL_SELECTION_TIMEOUT_SECONDS,
) )
_relevant_tools = set(ALWAYS_AVAILABLE) _relevant_tools = None
except Exception as e: except Exception as e:
logger.warning(f"[tool-rag] Retrieval failed, using keyword fallback: {e}") logger.warning(f"[tool-rag] Retrieval failed, using keyword fallback: {e}")
_relevant_tools = None _relevant_tools = None