fix: use lazy logging with %s formatting in logger calls
Replace f-string interpolation in logger calls with lazy %-style formatting across 10 files (38 instances). This follows Python logging best practices — the message is only formatted if the log level is enabled, avoiding unnecessary string concatenation overhead. Files changed: - trajectory_compressor.py (6) - mini_swe_runner.py (2) - agent/tool_executor.py (1) - agent/model_metadata.py (1) - agent/agent_runtime_helpers.py (3) - agent/chat_completion_helpers.py (3) - agent/conversation_loop.py (8) - tools/skills_hub.py (2) - tools/environments/docker.py (10) - gateway/kanban_watchers.py (2)
This commit is contained in:
@@ -663,7 +663,7 @@ Write only the summary, starting with "[CONTEXT SUMMARY]:" prefix."""
|
||||
|
||||
except Exception as e:
|
||||
metrics.summarization_errors += 1
|
||||
self.logger.warning(f"Summarization attempt {attempt + 1} failed: {e}")
|
||||
self.logger.warning("Summarization attempt %d failed: %s", attempt + 1, e)
|
||||
|
||||
if attempt < self.config.max_retries - 1:
|
||||
time.sleep(jittered_backoff(attempt + 1, base_delay=self.config.retry_delay, max_delay=30.0))
|
||||
@@ -732,7 +732,7 @@ Write only the summary, starting with "[CONTEXT SUMMARY]:" prefix."""
|
||||
|
||||
except Exception as e:
|
||||
metrics.summarization_errors += 1
|
||||
self.logger.warning(f"Summarization attempt {attempt + 1} failed: {e}")
|
||||
self.logger.warning("Summarization attempt %d failed: %s", attempt + 1, e)
|
||||
|
||||
if attempt < self.config.max_retries - 1:
|
||||
await asyncio.sleep(jittered_backoff(attempt + 1, base_delay=self.config.retry_delay, max_delay=30.0))
|
||||
@@ -1087,7 +1087,7 @@ Write only the summary, starting with "[CONTEXT SUMMARY]:" prefix."""
|
||||
jsonl_files = sorted(input_dir.glob("*.jsonl"))
|
||||
|
||||
if not jsonl_files:
|
||||
self.logger.warning(f"No JSONL files found in {input_dir}")
|
||||
self.logger.warning("No JSONL files found in %s", input_dir)
|
||||
return
|
||||
|
||||
# Load ALL entries from all files
|
||||
@@ -1103,7 +1103,7 @@ Write only the summary, starting with "[CONTEXT SUMMARY]:" prefix."""
|
||||
entry = json.loads(line)
|
||||
all_entries.append((file_path, line_num, entry))
|
||||
except json.JSONDecodeError as e:
|
||||
self.logger.warning(f"Skipping invalid JSON at {file_path}:{line_num}: {e}")
|
||||
self.logger.warning("Skipping invalid JSON at %s:%s: %s", file_path, line_num, e)
|
||||
|
||||
total_entries = len(all_entries)
|
||||
|
||||
@@ -1172,7 +1172,7 @@ Write only the summary, starting with "[CONTEXT SUMMARY]:" prefix."""
|
||||
)
|
||||
|
||||
except asyncio.TimeoutError:
|
||||
self.logger.warning(f"Timeout processing entry from {file_path}:{entry_idx} (>{self.config.per_trajectory_timeout}s)")
|
||||
self.logger.warning("Timeout processing entry from %s:%s (>%ss)", file_path, entry_idx, self.config.per_trajectory_timeout)
|
||||
|
||||
async with progress_lock:
|
||||
self.aggregate_metrics.trajectories_failed += 1
|
||||
@@ -1188,7 +1188,7 @@ Write only the summary, starting with "[CONTEXT SUMMARY]:" prefix."""
|
||||
results[file_path][entry_idx] = None
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(f"Error processing entry from {file_path}:{entry_idx}: {e}")
|
||||
self.logger.error("Error processing entry from %s:%s: %s", file_path, entry_idx, e)
|
||||
|
||||
async with progress_lock:
|
||||
self.aggregate_metrics.trajectories_failed += 1
|
||||
|
||||
Reference in New Issue
Block a user