88
99from ..models .shared .settings import CachedExecutionToolSettings
1010from ..models .shared .tools import Tool , ToolCollection
11+ from ..utils .cache_parameter_handler import CacheParameterHandler
1112from ..utils .caching .cache_execution_manager import CacheExecutionManager
1213from ..utils .caching .cache_manager import CacheManager
1314from ..utils .caching .cache_writer import CacheWriter
14- from ..utils .placeholder_handler import PlaceholderHandler
1515
1616if TYPE_CHECKING :
1717 from ..models .shared .agent_message_param import ToolUseBlockParam
@@ -149,14 +149,14 @@ def __init__(
149149 "trajectory files are available\n "
150150 "2. Select the appropriate trajectory file path from the "
151151 "returned list\n "
152- "3. If the trajectory contains placeholders (e.g., "
152+ "3. If the trajectory contains parameters (e.g., "
153153 "{{current_date}}), provide values for them in the "
154- "placeholder_values parameter\n "
154+ "parameter_values parameter\n "
155155 "4. Pass the full file path to this tool\n \n "
156- "Placeholders allow dynamic values to be injected during "
156+ "Cache parameters allow dynamic values to be injected during "
157157 "execution. For example, if a trajectory types "
158158 "'{{current_date}}', you must provide "
159- "placeholder_values ={'current_date': '2025-12-11'}.\n \n "
159+ "parameter_values ={'current_date': '2025-12-11'}.\n \n "
160160 "To continue from a specific step (e.g., after manually "
161161 "handling a non-cacheable step), use the start_from_step_index "
162162 "parameter. By default, execution starts from the beginning "
@@ -188,12 +188,12 @@ def __init__(
188188 ),
189189 "default" : 0 ,
190190 },
191- "placeholder_values " : {
191+ "parameter_values " : {
192192 "type" : "object" ,
193193 "description" : (
194- "Optional dictionary mapping placeholder names to "
194+ "Optional dictionary mapping parameter names to "
195195 "their values. Required if the trajectory contains "
196- "placeholders like {{variable}}. Example: "
196+ "parameters like {{variable}}. Example: "
197197 "{'current_date': '2025-12-11', 'user_name': 'Alice'}"
198198 ),
199199 "additionalProperties" : {"type" : "string" },
@@ -265,33 +265,33 @@ def _validate_step_index(
265265 return error_msg
266266 return None
267267
268- def _validate_placeholders (
268+ def _validate_parameters (
269269 self ,
270270 trajectory : list ["ToolUseBlockParam" ],
271- placeholder_values : dict [str , str ],
272- cache_placeholders : dict [str , str ],
271+ parameter_values : dict [str , str ],
272+ cache_parameters : dict [str , str ],
273273 ) -> str | None :
274- """Validate placeholder values.
274+ """Validate parameter values.
275275
276276 Args:
277277 trajectory: The cached trajectory
278- placeholder_values : User-provided placeholder values
279- cache_placeholders: Placeholders defined in cache file
278+ parameter_values : User-provided parameter values
279+ cache_parameters: Parameters defined in cache file
280280
281281 Returns:
282282 Error message if validation fails, None otherwise
283283 """
284- logger .debug ("Validating placeholder values" )
285- is_valid , missing = PlaceholderHandler . validate_placeholders (
286- trajectory , placeholder_values
284+ logger .debug ("Validating parameter values" )
285+ is_valid , missing = CacheParameterHandler . validate_parameters (
286+ trajectory , parameter_values
287287 )
288288 if not is_valid :
289289 error_msg = (
290- f"Missing required placeholder values: { ', ' .join (missing )} \n "
291- f"The trajectory contains the following placeholders : "
292- f"{ ', ' .join (cache_placeholders .keys ())} \n "
293- f"Please provide values for all placeholders in the "
294- f"placeholder_values parameter."
290+ f"Missing required parameter values: { ', ' .join (missing )} \n "
291+ f"The trajectory contains the following parameters : "
292+ f"{ ', ' .join (cache_parameters .keys ())} \n "
293+ f"Please provide values for all parameters in the "
294+ f"parameter_values parameter."
295295 )
296296 logger .error (error_msg )
297297 return error_msg
@@ -300,14 +300,14 @@ def _validate_placeholders(
300300 def _create_executor (
301301 self ,
302302 cache_file : "CacheFile" ,
303- placeholder_values : dict [str , str ],
303+ parameter_values : dict [str , str ],
304304 start_from_step_index : int ,
305305 ) -> "TrajectoryExecutor" :
306306 """Create and configure trajectory executor.
307307
308308 Args:
309309 cache_file: The cache file to execute
310- placeholder_values: Placeholder values to use
310+ parameter_values: Parameter values to use
311311 start_from_step_index: Index to start execution from
312312
313313 Returns:
@@ -324,7 +324,7 @@ def _create_executor(
324324 executor = TrajectoryExecutor (
325325 trajectory = cache_file .trajectory ,
326326 toolbox = self ._toolbox ,
327- placeholder_values = placeholder_values ,
327+ parameter_values = parameter_values ,
328328 delay_time = self ._settings .delay_time_between_action ,
329329 )
330330
@@ -342,15 +342,15 @@ def _format_success_message(
342342 trajectory_file : str ,
343343 trajectory_length : int ,
344344 start_from_step_index : int ,
345- placeholder_count : int ,
345+ parameter_count : int ,
346346 ) -> str :
347347 """Format success message.
348348
349349 Args:
350350 trajectory_file: Path to trajectory file
351351 trajectory_length: Total steps in trajectory
352352 start_from_step_index: Starting step index
353- placeholder_count : Number of placeholders used
353+ parameter_count : Number of parameters used
354354
355355 Returns:
356356 Formatted success message
@@ -369,8 +369,8 @@ def _format_success_message(
369369 f"Will execute { remaining_steps } remaining cached steps."
370370 )
371371
372- if placeholder_count > 0 :
373- success_msg += f" Using { placeholder_count } placeholder value(s)."
372+ if parameter_count > 0 :
373+ success_msg += f" Using { parameter_count } parameter value(s)."
374374
375375 return success_msg
376376
@@ -380,7 +380,7 @@ def __call__(
380380 self ,
381381 trajectory_file : str ,
382382 start_from_step_index : int = 0 ,
383- placeholder_values : dict [str , str ] | None = None ,
383+ parameter_values : dict [str , str ] | None = None ,
384384 ) -> str :
385385 """Activate cache execution mode for the agent.
386386
@@ -390,8 +390,8 @@ def __call__(
390390 Returns:
391391 Success message indicating cache mode has been activated
392392 """
393- if placeholder_values is None :
394- placeholder_values = {}
393+ if parameter_values is None :
394+ parameter_values = {}
395395
396396 logger .info (
397397 "Activating cache execution mode: %s (start_from_step=%d)" ,
@@ -417,9 +417,9 @@ def __call__(
417417 cache_file = CacheWriter .read_cache_file (Path (trajectory_file ))
418418
419419 logger .debug (
420- "Cache loaded: %d steps, %d placeholders , valid=%s" ,
420+ "Cache loaded: %d steps, %d parameters , valid=%s" ,
421421 len (cache_file .trajectory ),
422- len (cache_file .placeholders ),
422+ len (cache_file .cache_parameters ),
423423 cache_file .metadata .is_valid ,
424424 )
425425
@@ -439,15 +439,15 @@ def __call__(
439439 ):
440440 return error
441441
442- # Validate placeholders
443- if error := self ._validate_placeholders (
444- cache_file .trajectory , placeholder_values , cache_file .placeholders
442+ # Validate parameters
443+ if error := self ._validate_parameters (
444+ cache_file .trajectory , parameter_values , cache_file .cache_parameters
445445 ):
446446 return error
447447
448448 # Create and configure executor
449449 executor = self ._create_executor (
450- cache_file , placeholder_values , start_from_step_index
450+ cache_file , parameter_values , start_from_step_index
451451 )
452452
453453 # Store executor and cache info in agent state
@@ -462,7 +462,7 @@ def __call__(
462462 trajectory_file ,
463463 len (cache_file .trajectory ),
464464 start_from_step_index ,
465- len (placeholder_values ),
465+ len (parameter_values ),
466466 )
467467 logger .info (success_msg )
468468 return success_msg
@@ -483,7 +483,7 @@ def __init__(self) -> None:
483483 "- Execution statistics (attempts, last execution time)\n "
484484 "- Validity status and invalidation reason (if invalid)\n "
485485 "- Failure history with timestamps and error messages\n "
486- "- Placeholders and trajectory step count\n \n "
486+ "- Parameters and trajectory step count\n \n "
487487 "Use this tool to debug cache issues or understand why a cache "
488488 "might be failing or invalidated."
489489 ),
@@ -556,10 +556,10 @@ def __call__(self, trajectory_file: str) -> str:
556556 lines .append ("" )
557557 lines .append ("--- Trajectory Info ---" )
558558 lines .append (f"Total Steps: { len (cache_file .trajectory )} " )
559- lines .append (f"Placeholders : { len (cache_file .placeholders )} " )
560- if cache_file .placeholders :
559+ lines .append (f"Parameters : { len (cache_file .cache_parameters )} " )
560+ if cache_file .cache_parameters :
561561 lines .append (
562- f"Placeholder Names: { ', ' .join (cache_file .placeholders .keys ())} "
562+ f"Parameter Names: { ', ' .join (cache_file .cache_parameters .keys ())} "
563563 )
564564
565565 if metadata .failures :
0 commit comments