refactor: mask secrets in code execution command output and increase truncation limit
- Import secrets helper module - Increase initial command truncation from 200 to 250 characters - Add secret masking to format_command_for_output using agent context's secrets manager - Apply masking before final truncation to prevent secret exposure in logs
frdel committed
Mar 22, 2026 at 16:57 UTC
6181ac9c204e27290608bbe83bf0ec0b20fe5f01
1 file changed
+3
-2
plugins/_code_execution/tools/code_execution_tool.py
+3
-2
@@ -5,7 +5,7 @@ import shlex
5
import time
6
7
from helpers.tool import Tool, Response
8
-from helpers import files, rfc_exchange, projects, runtime, settings
8
+from helpers import files, rfc_exchange, projects, runtime, secrets, settings
9
from helpers.print_style import PrintStyle
10
from helpers.strings import truncate_text as truncate_text_string
11
from helpers.messages import truncate_text as truncate_text_agent
@@ -200,8 +200,9 @@ class CodeExecution(Tool):
200
raise e
201
202
def format_command_for_output(self, command: str):
203
- short_cmd = command[:200]
203
+ short_cmd = command[:250]
204
short_cmd = " ".join(short_cmd.split())
205
+ short_cmd = secrets.get_secrets_manager(self.agent.context).mask_values(short_cmd)
206
short_cmd = truncate_text_string(short_cmd, 100)
207
return f"{short_cmd}"
208