From d618f2d65021c1a427e6636d2611a68b54d64c1b Mon Sep 17 00:00:00 2001 From: Debanjum Date: Tue, 3 Jun 2025 21:43:42 -0700 Subject: [PATCH] Raise value error if research pick next tool isn't a dictionary This will give a better error message with response content than the failed to get errors from non dictionary response we were getting earlier. --- src/khoj/routers/research.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/khoj/routers/research.py b/src/khoj/routers/research.py index 494a01b6..e72b25a5 100644 --- a/src/khoj/routers/research.py +++ b/src/khoj/routers/research.py @@ -198,6 +198,8 @@ async def apick_next_tool( try: response = load_complex_json(response) + if not isinstance(response, dict): + raise ValueError(f"Expected dict response, got {type(response).__name__}: {response}") selected_tool = response.get("tool", None) generated_query = response.get("query", None) scratchpad = response.get("scratchpad", None)