From fe04ad47c9abf843cb6f64176981325a5b05f074 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Thu, 4 Jun 2026 16:38:54 -0400 Subject: Add tests and fix research tools --- main.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index 96eb7ef..128339a 100644 --- a/main.py +++ b/main.py @@ -41,6 +41,7 @@ AGENT_TIMEOUT = int(os.environ.get("SLOPBOT_AGENT_TIMEOUT", "120")) AGENT_MODEL = os.environ.get("SLOPBOT_AGENT_MODEL", "parasail/kimi-k26") AGENT_BIN = os.environ.get("SLOPBOT_AGENT", "agent") AGENT_PATH = os.environ.get("SLOPBOT_AGENT_PATH", os.environ.get("PATH", "")) +AGENT_DEBUG = os.environ.get("SLOPBOT_AGENT_DEBUG", "").lower() in {"1", "true", "yes", "on"} WORKERS = int(os.environ.get("SLOPBOT_WORKERS", "4")) AGENT_WORKERS = int(os.environ.get("SLOPBOT_AGENT_WORKERS", "1")) HISTORY_LIMIT = int(os.environ.get("SLOPBOT_HISTORY_LIMIT", "20")) @@ -126,16 +127,24 @@ def _agent(prompt: str) -> tuple[int, str, str]: """Run agent once; return (returncode, stdout, stderr).""" env = os.environ.copy() env["PATH"] = AGENT_PATH + command = [ + AGENT_BIN, + "--model", AGENT_MODEL, + "--eval-cwd", str(BASE_DIR), + ] + if AGENT_DEBUG: + command.append("--debug") + command.append(prompt) + result = subprocess.run( - [ - AGENT_BIN, - "--model", AGENT_MODEL, - "--eval-cwd", str(BASE_DIR), - prompt, - ], - capture_output=True, text=True, timeout=AGENT_TIMEOUT, env=env, + command, + stdout=subprocess.PIPE, + stderr=None if AGENT_DEBUG else subprocess.PIPE, + text=True, + timeout=AGENT_TIMEOUT, + env=env, ) - return result.returncode, result.stdout.strip(), result.stderr.strip() + return result.returncode, result.stdout.strip(), (result.stderr or "").strip() def _unique_session_name(msg: dict) -> str: -- cgit v1.2.3