Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: code executor timeout (#9671)

Yongteng Lei035e8ed0f77d
diff --git a/agent/tools/code_exec.py b/agent/tools/code_exec.py
index 1457a28475..866a523ab6 100644
--- a/agent/tools/code_exec.py
+++ b/agent/tools/code_exec.py
@@ -79,7 +79,7 @@ def main() -> dict:
return {
"result": fibonacci_recursive(100),
}
-
+
Here's a code example for Javascript(`main` function MUST be included and exported):
const axios = require('axios');
async function main(args) {
@@ -156,7 +156,7 @@ class CodeExec(ToolBase, ABC):
self.set_output("_ERROR", "construct code request error: " + str(e))
try:
- resp = requests.post(url=f"http://{settings.SANDBOX_HOST}:9385/run", json=code_req, timeout=10)
+ resp = requests.post(url=f"http://{settings.SANDBOX_HOST}:9385/run", json=code_req, timeout=os.environ.get("COMPONENT_EXEC_TIMEOUT", 10*60))
logging.info(f"http://{settings.SANDBOX_HOST}:9385/run", code_req, resp.status_code)
if resp.status_code != 200:
resp.raise_for_status()
diff --git a/sandbox/executor_manager/core/config.py b/sandbox/executor_manager/core/config.py
index 962b3f0bfb..332fdefbeb 100644
--- a/sandbox/executor_manager/core/config.py
+++ b/sandbox/executor_manager/core/config.py
@@ -22,7 +22,7 @@ from util import format_timeout_duration, parse_timeout_duration
from core.container import init_containers, teardown_containers
from core.logger import logger
-TIMEOUT = 10
+TIMEOUT = parse_timeout_duration(os.getenv("SANDBOX_TIMEOUT", "10s"))
@asynccontextmanager
@@ -39,6 +39,5 @@ async def _lifespan(app: FastAPI):
def init():
- TIMEOUT = parse_timeout_duration(os.getenv("SANDBOX_TIMEOUT"))
logger.info(f"Global timeout: {format_timeout_duration(TIMEOUT)}")
return _lifespan