From 8c4eeffb4c3ec2c84c4f14144ea0c6e1f1152b70 Mon Sep 17 00:00:00 2001 From: Alexazhu Date: Sat, 18 Apr 2026 15:37:29 +0800 Subject: [PATCH] fix(agent): preserve tracebacks in prompt_builder and trajectory warnings Two `except Exception as e:` warnings lose the traceback: - agent/prompt_builder.py: skill-file frontmatter parse failure - agent/trajectory.py: trajectory log append failure Add `exc_info=True` so the stack is preserved when a skill manifest is malformed or trajectory writes hit filesystem errors in production. --- agent/prompt_builder.py | 2 +- agent/trajectory.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/prompt_builder.py b/agent/prompt_builder.py index 3e042f65df..570ec069a5 100644 --- a/agent/prompt_builder.py +++ b/agent/prompt_builder.py @@ -545,7 +545,7 @@ def _parse_skill_file(skill_file: Path) -> tuple[bool, dict, str]: return True, frontmatter, extract_skill_description(frontmatter) except Exception as e: - logger.warning("Failed to parse skill file %s: %s", skill_file, e) + logger.warning("Failed to parse skill file %s: %s", skill_file, e, exc_info=True) return True, {}, "" diff --git a/agent/trajectory.py b/agent/trajectory.py index 90696eb8a3..1d2e943153 100644 --- a/agent/trajectory.py +++ b/agent/trajectory.py @@ -53,4 +53,4 @@ def save_trajectory(trajectory: List[Dict[str, Any]], model: str, f.write(json.dumps(entry, ensure_ascii=False) + "\n") logger.info("Trajectory saved to %s", filename) except Exception as e: - logger.warning("Failed to save trajectory: %s", e) + logger.warning("Failed to save trajectory: %s", e, exc_info=True)