From d41416b4d707ff249a5b986c27a8d65e5f1d8fd6 Mon Sep 17 00:00:00 2001 From: AI Christianson Date: Sun, 2 Mar 2025 14:52:11 -0500 Subject: [PATCH] run gc in db ctx --- ra_aid/__main__.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/ra_aid/__main__.py b/ra_aid/__main__.py index ce34b6a..8d211e1 100644 --- a/ra_aid/__main__.py +++ b/ra_aid/__main__.py @@ -610,6 +610,9 @@ def main(): memory=planning_memory, config=config, ) + + # Run cleanup tasks before exiting database context + run_cleanup() except (KeyboardInterrupt, AgentInterrupt): print() @@ -624,21 +627,11 @@ def run_cleanup(): # Import the key facts cleaner agent from ra_aid.agents.key_facts_gc_agent import run_key_facts_gc_agent - # Get the count of key facts - from ra_aid.database.repositories.key_fact_repository import KeyFactRepository - key_fact_repository = KeyFactRepository() - - # Only run the cleaner if we have more than 30 facts - facts = key_fact_repository.get_all() - if len(facts) > 30: - run_key_facts_gc_agent() + # Run the key facts garbage collection agent regardless of the number of facts + run_key_facts_gc_agent() except Exception as e: logger.error(f"Failed to run cleanup tasks: {str(e)}") if __name__ == "__main__": - try: - main() - finally: - # Run cleanup tasks at program exit - run_cleanup() \ No newline at end of file + main() \ No newline at end of file