diff --git a/.github/workflows/run_evals.yml b/.github/workflows/run_evals.yml index 914a0835..6e6f7143 100644 --- a/.github/workflows/run_evals.yml +++ b/.github/workflows/run_evals.yml @@ -114,7 +114,7 @@ jobs: # Start code sandbox npm install -g pm2 - npm run ci --prefix terrarium + NODE_ENV=production npm run ci --prefix terrarium # Wait for server to be ready timeout=120 diff --git a/src/khoj/processor/tools/run_code.py b/src/khoj/processor/tools/run_code.py index ac1463ab..62ffde74 100644 --- a/src/khoj/processor/tools/run_code.py +++ b/src/khoj/processor/tools/run_code.py @@ -100,7 +100,13 @@ async def run_code( logger.info(f"Executed Code\n----\n{code}\n----\nResult\n----\n{cleaned_result}\n----") yield {query: {"code": code, "results": result}} except asyncio.TimeoutError as e: - raise ValueError(f"Failed to run code for {query} with Timeout error: {e}") + # Call the sandbox_url/stop GET API endpoint to stop the code sandbox + error = f"Failed to run code for {query} with Timeout error: {e}" + try: + await aiohttp.ClientSession().get(f"{sandbox_url}/stop", timeout=5) + except Exception as e: + error += f"\n\nFailed to stop code sandbox with error: {e}" + raise ValueError(error) except Exception as e: raise ValueError(f"Failed to run code for {query} with error: {e}")