InMemoryAgentFileStore.SearchAsync Method

Definition

Searches for files whose content matches a regular expression pattern.

public override System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Microsoft.Agents.AI.FileSearchResult>> SearchAsync(string directory, string regexPattern, string? globPattern = default, bool recursive = false, System.Threading.CancellationToken cancellationToken = default);
override this.SearchAsync : string * string * string * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Microsoft.Agents.AI.FileSearchResult>>
Public Overrides Function SearchAsync (directory As String, regexPattern As String, Optional globPattern As String = Nothing, Optional recursive As Boolean = false, Optional cancellationToken As CancellationToken = Nothing) As Task(Of IReadOnlyList(Of FileSearchResult))

Parameters

directory
String

The relative path of the directory to search. Use an empty string for the root.

regexPattern
String

A regular expression pattern to match against file contents. The pattern is matched case-insensitively. For example, "error|warning" matches lines containing "error" or "warning".

globPattern
String

An optional glob pattern to filter which files are searched (e.g., ".md", "research"). When null, all files are searched. Uses standard glob syntax from Matcher, matched against each file's path relative to directory. Use to match across subdirectories (e.g., "/*.md").

recursive
Boolean

When true, all descendant files of directory are searched. When false (default), only the direct children of directory are searched.

cancellationToken
CancellationToken

A token to cancel the operation.

Returns

A list of search results. Each result's FileName is the matching file's path relative to directory.

Applies to