From 66c3ae171dc33db46c1eeb0bfe4d40e96fcd9223 Mon Sep 17 00:00:00 2001 From: rzv <51793648+RazviAlex@users.noreply.github.com> Date: Tue, 6 Jan 2026 13:27:10 +0100 Subject: [PATCH] Fix function call cli_print_tool_call with kwargs support Updated cli_print_tool_call to accept additional parameters for backwards compatibility. When running CAI with memory system enabled, the template code (system_master_template.md) has outdate function call. Warning received from CAI when running with memory: "Warning: Failed to render system master template: cli_print_tool_call() got an unexpected keyword argument 'tool_args'" --- src/cai/util.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cai/util.py b/src/cai/util.py index b5acca68..010ea7ee 100644 --- a/src/cai/util.py +++ b/src/cai/util.py @@ -1414,11 +1414,20 @@ def fix_message_list(messages): # pylint: disable=R0914,R0915,R0912 return processed_messages -def cli_print_tool_call(tool_name="", args="", output="", prefix=" "): - """Print a tool call with pretty formatting""" +def cli_print_tool_call(tool_name="", args="", output="", prefix=" ", **kwargs): + """Print a tool call with pretty formatting + Args: + tool_name: Name of the tool being called + output: Output from the tool execution + **kwargs: Accept additional parameters for backwards compatibility""" if not tool_name: return + if not args and 'tool_args' in kwargs: + args = kwargs['tool_args'] + if not output and 'tool_output' in kwargs: + output = kwargs['tool_output'] + print(f"{prefix}{color('Tool Call:', fg='cyan')}") print(f"{prefix}{color('Name:', fg='cyan')} {tool_name}") if args: @@ -1426,7 +1435,6 @@ def cli_print_tool_call(tool_name="", args="", output="", prefix=" "): if output: print(f"{prefix}{color('Output:', fg='cyan')} {output}") - def get_model_input_tokens(model): """ Get the number of input tokens for