From c713d01e722d05de7a4e0ad8e9d8b7a420610e0b Mon Sep 17 00:00:00 2001 From: teknium1 Date: Tue, 17 Mar 2026 03:43:21 -0700 Subject: [PATCH] fix(core): move RedactingFormatter import before conditional block RedactingFormatter was imported inside 'if not has_errors_log_handler:' (line 461) but also used unconditionally in the verbose_logging block (line 479). When the error log handler already exists (e.g. second AIAgent in the same process) AND verbose_logging=True, the import was skipped and line 479 raised NameError. Fix: Move the import one level up so it's always available regardless of whether the error log handler already exists. --- run_agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_agent.py b/run_agent.py index e8bf35c47..8cf980b97 100644 --- a/run_agent.py +++ b/run_agent.py @@ -457,8 +457,8 @@ class AIAgent: and Path(getattr(handler, "baseFilename", "")).resolve() == resolved_error_log_path for handler in root_logger.handlers ) + from agent.redact import RedactingFormatter if not has_errors_log_handler: - from agent.redact import RedactingFormatter error_log_dir.mkdir(parents=True, exist_ok=True) error_file_handler = RotatingFileHandler( error_log_path, maxBytes=2 * 1024 * 1024, backupCount=2,