fix(logging): address code review feedback for TaskLogCollector robustness

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-11 09:15:44 +00:00
parent dfa4b16776
commit 3e78ee4c27
2 changed files with 22 additions and 2 deletions
+2 -2
View File
@@ -25,7 +25,7 @@ class TaskLogCollector(logging.Handler):
try:
msg = self.format(record)
# Extract task_id from messages formatted as "[task_id] ..."
if msg and "[" in msg:
if msg and "[" in msg and "]" in msg:
start = msg.index("[")
end = msg.index("]", start)
task_id = msg[start + 1 : end].strip()
@@ -76,7 +76,7 @@ def log_task_progress(task_id, step_name, status, message=None, file_id=None, de
If not provided, buffered logger output is used automatically.
"""
# Auto-capture buffered log output when no explicit detail is given
if detail is None and task_id:
if not detail and task_id:
_ensure_collector_installed()
collected = _collector.drain(task_id)
if collected: