@@ -238,13 +238,43 @@ def main():
238238 )
239239
240240 while True :
241+ # Inner loop logic to handle prompt input vs command execution
241242 try :
242- # Styled prompt — uses plain input to keep cursor on same line
243243 user_input = Prompt .ask (
244244 "\n [bold bright_yellow] You[/bold bright_yellow]" ,
245245 console = console ,
246246 )
247+ except KeyboardInterrupt :
248+ console .print ()
249+ # Show session token summary before quitting
250+ if agent .token_usage .total > 0 :
251+ console .print (
252+ Panel (
253+ Text .assemble (
254+ ("Session token usage\n " , "bold white" ),
255+ (" Prompt (in): " , "dim" ),
256+ (f"{ agent .token_usage .prompt :>10,} \n " , "cyan" ),
257+ (" Completion (out): " , "dim" ),
258+ (f"{ agent .token_usage .completion :>10,} \n " , "cyan" ),
259+ (" Total: " , "dim" ),
260+ (f"{ agent .token_usage .total :>10,} " , "bold cyan" ),
261+ ),
262+ border_style = "cyan" ,
263+ box = box .ROUNDED ,
264+ title = "[bold cyan]⚡ Token Summary[/bold cyan]" ,
265+ title_align = "left" ,
266+ )
267+ )
268+ console .print (
269+ Panel (
270+ "[bold cyan]Goodbye! Lambda signing off.[/bold cyan]" ,
271+ border_style = "cyan" ,
272+ box = box .ROUNDED ,
273+ )
274+ )
275+ break
247276
277+ try :
248278 if user_input .lower () in ["exit" , "quit" ]:
249279 console .print ()
250280 # Show session token summary before quitting
@@ -300,9 +330,10 @@ def main():
300330 print_token_stats (turn_usage , agent .token_usage )
301331
302332 except KeyboardInterrupt :
303- console .print ()
304- console .print ("[bold cyan]\n Goodbye![/bold cyan]" )
305- break
333+ console .print (
334+ "\n [bold yellow]⚠ Action cancelled by user.[/bold yellow]"
335+ )
336+ continue
306337
307338 except Exception as e :
308339 console .print (
0 commit comments