prompttrail.agent.tools package

Submodules

prompttrail.agent.tools.builtin module

pydantic model prompttrail.agent.tools.builtin.CreateOrOverwriteFile

Bases: Tool

Fields:
field arguments: Dict[str, ToolArgument[Any]] = {'content': ToolArgument(name='content', description='Content to write to the file', value_type=<class 'str'>, required=True), 'path': ToolArgument(name='path', description='Path where to create/overwrite the file', value_type=<class 'str'>, required=True)}
field description: str = 'Create a new file or overwrite an existing one'
field name: str = 'create_or_overwrite_file'
pydantic model prompttrail.agent.tools.builtin.EditFile

Bases: Tool

Fields:
field arguments: Dict[str, ToolArgument[Any]] = {'diff': ToolArgument(name='diff', description='Diff content in format: SEARCH/REPLACE blocks', value_type=<class 'str'>, required=True), 'path': ToolArgument(name='path', description='Path to the file to edit', value_type=<class 'str'>, required=True)}
field description: str = 'Edit a file by applying a diff in SEARCH/REPLACE block format'
field name: str = 'edit_file'
block_anchor_fallback_match(original_content: str, search_content: str, start_index: int) Tuple[int, int] | bool

Try fallback matching using first and last lines of block as anchors. Only applies to blocks with 3 or more lines.

construct_new_file_content(diff_content: str, original_content: str, is_final: bool = True) str

Apply diff content to original file content to construct new file content.

line_trimmed_fallback_match(original_content: str, search_content: str, start_index: int) Tuple[int, int] | bool

Try line-by-line trimmed fallback matching. Compare lines ignoring whitespace at the beginning and end.

pydantic model prompttrail.agent.tools.builtin.EndConversationTool

Bases: Tool

Fields:
field arguments: Dict[str, ToolArgument[Any]] = {'message': ToolArgument(name='message', description='Optional farewell message', value_type=<class 'str'>, required=False)}
field description: str = 'End the current conversation'
field name: str = 'end_conversation'
pydantic model prompttrail.agent.tools.builtin.ExecuteCommand

Bases: Tool

Fields:
field arguments: Dict[str, ToolArgument[Any]] = {'command': ToolArgument(name='command', description='Command to run.', value_type=<class 'str'>, required=False)}
field description: str = 'You can run any linux command with arguments like: ls, git status, git commit --amend --no-edit. Dangerous operation is reviewed by user.'
field name: str = 'execute_command'
pydantic model prompttrail.agent.tools.builtin.ReadFile

Bases: Tool

Fields:
field arguments: Dict[str, ToolArgument[Any]] = {'path': ToolArgument(name='path', description='Path to the file to read', value_type=<class 'str'>, required=True)}
field description: str = 'Read content of a specific file'
field name: str = 'read_file'
pydantic model prompttrail.agent.tools.builtin.TreeDirectory

Bases: Tool

Fields:
field arguments: Dict[str, ToolArgument[Any]] = {'max_depth': ToolArgument(name='max_depth', description='Maximum depth of directory traversal', value_type=<class 'int'>, required=False), 'root_dir': ToolArgument(name='root_dir', description='Root directory to display. Deafult is current working directory. Respect .gitignore if it exists in the root directory.', value_type=<class 'str'>, required=False)}
field description: str = 'Display directory structure from cwd in a tree-like format'
field name: str = 'tree_directory'
run_command(max_depth: int | None, root_dir: str | None) str

Get ignore patterns from .gitignore file.

Module contents

Tools package for PromptTrail agent.

pydantic model prompttrail.agent.tools.SubroutineTool

Bases: Tool

Tool for executing templates as subroutines.

This tool wraps a template in a SubroutineTemplate and executes it with the provided session initialization and message handling strategies.

Parameters:
  • name – Name of the tool

  • description – Description of the tool’s functionality

  • template – The template to execute as a subroutine

  • session_init_strategy – Strategy for initializing the subroutine session

  • squash_strategy – Strategy for handling messages after subroutine execution

  • before_transform – Transformers to apply before execution

  • after_transform – Transformers to apply after execution

Fields:
  • subroutine (prompttrail.agent.subroutine._base.SubroutineTemplate | None)

field subroutine: SubroutineTemplate | None = None
__init__(name: str, description: str, template: Template, session_init_strategy: SessionInitStrategy | None = None, squash_strategy: SquashStrategy | None = None, before_transform: List[SessionTransformer] | SessionTransformer | None = None, after_transform: List[SessionTransformer] | SessionTransformer | None = None)

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

pydantic model prompttrail.agent.tools.Tool

Bases: BaseModel, Debuggable

Base class for implementing tools that can be called by LLMs.

Provides argument validation and schema generation for function calling APIs. Subclasses should implement the _execute() method.

Fields:
  • arguments (Dict[str, prompttrail.agent.tools._base.ToolArgument[Any]])

  • description (str)

  • enable_logging (bool)

  • logger (logging.Logger)

  • name (str)

field arguments: Dict[str, ToolArgument[Any]] [Required]
field description: str [Required]
field enable_logging: bool = True
field logger: Logger = None
field name: str [Required]
execute(**kwargs) ToolResult

Execute the tool after validating arguments.

model_post_init(*args, **kwargs)

Configure logging after initialization.

to_schema() Dict[str, Any]

Generate function calling schema for this tool.

validate_arguments(args: Dict[str, Any], allow_redundant=False) None

Validate that all required arguments are present and have correct types.

pydantic model prompttrail.agent.tools.ToolArgument

Bases: BaseModel, Generic[T]

Tool argument definition with name, description, type and required flag.

Fields:
  • description (str)

  • name (str)

  • required (bool)

  • value_type (type)

field description: str [Required]
field name: str [Required]
field required: bool = True
field value_type: type [Required]
validate_value(value: Any) bool

Validate if the given value matches the argument’s type.

pydantic model prompttrail.agent.tools.ToolResult

Bases: BaseModel

Container for a tool’s execution result and optional metadata.

Fields:
  • content (Any)

  • metadata (Dict[str, Any])

field content: Any = None
field metadata: Dict[str, Any] [Optional]