From 868835ece8a2f09d2afe0d68ee675db46c9ceb68 Mon Sep 17 00:00:00 2001 From: AI Christianson Date: Thu, 26 Dec 2024 17:28:39 -0500 Subject: [PATCH] Fix logging on interrupt. --- CHANGELOG.md | 4 ++++ ra_aid/agent_utils.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08cdf1e..4386492 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +- Fix logging on interrupt. + ## [0.10.2] - 2024-12-26 - Add logging. diff --git a/ra_aid/agent_utils.py b/ra_aid/agent_utils.py index 82779ef..0d497b2 100644 --- a/ra_aid/agent_utils.py +++ b/ra_aid/agent_utils.py @@ -165,6 +165,8 @@ def run_research_agent( # Run agent with retry logic logger.debug("Research agent completed successfully") return run_agent_with_retry(agent, prompt, run_config) + except (KeyboardInterrupt, AgentInterrupt): + raise except Exception as e: logger.error("Research agent failed: %s", str(e), exc_info=True) raise @@ -258,6 +260,8 @@ def run_web_research_agent( # Run agent with retry logic logger.debug("Web research agent completed successfully") return run_agent_with_retry(agent, prompt, run_config) + except (KeyboardInterrupt, AgentInterrupt): + raise except Exception as e: logger.error("Web research agent failed: %s", str(e), exc_info=True) raise @@ -334,6 +338,8 @@ def run_planning_agent( print_stage_header("Planning Stage") logger.debug("Planning agent completed successfully") return run_agent_with_retry(agent, planning_prompt, run_config) + except (KeyboardInterrupt, AgentInterrupt): + raise except Exception as e: logger.error("Planning agent failed: %s", str(e), exc_info=True) raise