Skip to main content

Module tools

Module tools 

Source
Expand description

Built-in tool implementations.

Pi provides 7 built-in tools: read, bash, edit, write, grep, find, ls.

Tools are exposed to the model via JSON Schema (see crate::provider::ToolDef) and executed locally by the agent loop. Each tool returns structured ContentBlock output suitable for rendering in the TUI and for inclusion in provider messages as tool results.

Structs§

BashRunResult
BashTool
EditTool
FindTool
GrepTool
LsTool
ProcessedFiles
Result of processing @file CLI arguments.
ReadTool
ToolOutput
Tool execution output.
ToolRegistry
Registry of enabled tools for a Pi run.
ToolUpdate
Incremental update during tool execution.
TruncationResult
Result of truncation operation.
WriteTool

Enums§

TruncatedBy

Constants§

DEFAULT_BASH_TIMEOUT_SECS
Default timeout (in seconds) for bash tool execution.
DEFAULT_FIND_LIMIT
Default find result limit.
DEFAULT_GREP_LIMIT
Default grep result limit.
DEFAULT_LS_LIMIT
Default ls result limit.
DEFAULT_MAX_BYTES
Default maximum bytes for truncation.
DEFAULT_MAX_LINES
Default maximum lines for truncation.
GREP_MAX_LINE_LENGTH
Maximum line length for grep results.
IMAGE_MAX_BYTES
Maximum size for an image to be sent to the API (4.5MB).
LS_SCAN_HARD_LIMIT
Hard limit for directory scanning in ls tool to prevent OOM/hangs.
READ_TOOL_MAX_BYTES
Hard limit for read tool file size (100MB) to prevent OOM.
WRITE_TOOL_MAX_BYTES
Hard limit for write/edit tool file size (100MB) to prevent OOM.

Traits§

Tool
A tool that can be executed by the agent.

Functions§

cleanup_temp_files
Clean up old temporary files created by the bash tool.
kill_process_tree
process_file_arguments
Process @file arguments into a single text prefix and image attachments.
truncate_head
Truncate from the beginning (keep first N lines).
truncate_tail
Truncate from the end (keep last N lines).