From 185cda575e56c0d5f9a3ec8ec92976e52ee9c6ac Mon Sep 17 00:00:00 2001 From: ansible Date: Tue, 7 Apr 2026 21:01:39 +0000 Subject: [PATCH] =?UTF-8?q?Add=20file=20logging=20to=20agent=20=E2=80=94?= =?UTF-8?q?=20writes=20to=20/workspace/agent.log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/agent.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/agent/agent.py b/agent/agent.py index 11aa5b4..3e7e02a 100644 --- a/agent/agent.py +++ b/agent/agent.py @@ -217,8 +217,18 @@ def execute_skill(script_path, args): TOOLS, SKILL_SCRIPTS = discover_skills() +LOG_FILE = f"{WORKSPACE}/agent.log" if os.path.isdir(WORKSPACE) else None + + def log(msg): - print(f"[agent:{NICK}] {msg}", flush=True) + line = f"[{time.strftime('%H:%M:%S')}] {msg}" + print(f"[agent:{NICK}] {line}", flush=True) + if LOG_FILE: + try: + with open(LOG_FILE, "a") as f: + f.write(line + "\n") + except Exception: + pass log(f"Loaded {len(TOOLS)} skills: {', '.join(SKILL_SCRIPTS.keys())}")