provrun.tools.grep

grep_file: search one file in the sandbox with ripgrep.

grep_file

source

async grep_file(ctx: RunContext[RunDeps], path: str, pattern: str, context_lines: int = 2, regex: bool = False) -> str

Search a file for lines that match a pattern, without case.

Args: path: The path of the file in the sandbox, for example /input/report.txt. pattern: The text to find. It is a literal unless regex is true. context_lines: The number of lines to show before and after each match. regex: Treat the pattern as a regular expression.

Parameter Type Default Description
ctx RunContext[RunDeps] required PydanticAI’s run context; ctx.deps holds the sandbox
path str required The path of the file in the sandbox, for example /input/report.txt
pattern str required The text to find; a literal unless regex is true
context_lines int 2 The number of lines to show before and after each match
regex bool False Treat the pattern as a regular expression
returns str The matching lines with their numbers, or a sentence that says why there are none