From 4943d433dc1485492fe6a01c1ff4dc6cc35763fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mayoral=20Vilches?= Date: Sun, 1 Jun 2025 14:29:09 +0000 Subject: [PATCH] Add symbolic link capability, now creates logs/last MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: VĂ­ctor Mayoral Vilches --- src/cai/cli.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/cai/cli.py b/src/cai/cli.py index 3820a8aa..1725b4ee 100644 --- a/src/cai/cli.py +++ b/src/cai/cli.py @@ -558,6 +558,10 @@ def run_cai_cli(starting_agent, context_variables=None, max_turns=float('inf'), if session_logger: session_logger.log_session_end() + # Create symlink to the last log file + if session_logger and hasattr(session_logger, 'filename'): + create_last_log_symlink(session_logger.filename) + # Prevent duplicate cost display from the COST_TRACKER exit handler os.environ["CAI_COST_DISPLAYED"] = "true" @@ -904,6 +908,38 @@ def run_cai_cli(starting_agent, context_variables=None, max_turns=float('inf'), stop_active_timer() start_idle_timer() +def create_last_log_symlink(log_filename): + """ + Create a symbolic link 'logs/last' pointing to the current log file. + + Args: + log_filename: Path to the current log file + """ + try: + import os + from pathlib import Path + + if not log_filename: + return + + log_path = Path(log_filename) + if not log_path.exists(): + return + + # Create the symlink path + symlink_path = Path("logs/last") + + # Remove existing symlink if it exists + if symlink_path.exists() or symlink_path.is_symlink(): + symlink_path.unlink() + + # Create new symlink pointing to just the filename (relative path within logs dir) + symlink_path.symlink_to(log_path.name) + + except Exception: + # Silently ignore errors to avoid disrupting the main flow + pass + def main(): # Apply litellm patch to fix the __annotations__ error patch_applied = fix_litellm_transcription_annotations()