From 26dcea0c61dd373acba352bc9a2c203a10849569 Mon Sep 17 00:00:00 2001 From: analista Date: Wed, 1 Apr 2026 07:18:31 +0000 Subject: [PATCH] fix(cli): initialize ctx_len before compact banner path ctx_len was only assigned inside the else (non-compact) branch but referenced unconditionally after the if/else, causing an UnboundLocalError when the terminal is narrow or --compact is set. --- cli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli.py b/cli.py index b18e53077546b..2ebc7c0c505dd 100644 --- a/cli.py +++ b/cli.py @@ -2168,18 +2168,18 @@ def show_banner(self): term_width = shutil.get_terminal_size().columns use_compact = self.compact or term_width < 80 + ctx_len = None if use_compact: self.console.print(_build_compact_banner()) self._show_status() else: # Get tools for display tools = get_tool_definitions(enabled_toolsets=self.enabled_toolsets, quiet_mode=True) - + # Get terminal working directory (where commands will execute) cwd = os.getenv("TERMINAL_CWD", os.getcwd()) - + # Get context length for display - ctx_len = None if hasattr(self, 'agent') and self.agent and hasattr(self.agent, 'context_compressor'): ctx_len = self.agent.context_compressor.context_length