Documentation
¶
Overview ¶
Package regextool provides regular expression tools for agents. LLMs are notoriously unreliable at generating and reasoning about regex patterns — this tool lets them test, match, extract, and replace using Go's regexp engine for precise results.
Problem: Agents need to parse structured text (log files, configs, code) and LLMs cannot reliably execute regex operations mentally. This package provides a deterministic regex engine the agent can call.
Safety guards:
- Input capped at 1 MB to prevent excessive processing
- Pattern length capped at 10,000 chars
- Output truncated at 32 KB to limit LLM context consumption
- Go's RE2 engine guarantees linear-time matching (no catastrophic backtracking)
Dependencies:
- Go stdlib only (regexp uses RE2 — guaranteed linear-time, no backtracking)
- No external system dependencies
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ToolProvider ¶
type ToolProvider struct{}
ToolProvider wraps the regex tool and satisfies the tools.ToolProviders interface.
func NewToolProvider ¶
func NewToolProvider() *ToolProvider
NewToolProvider creates a ToolProvider for the regex tool.
func (*ToolProvider) GetTools ¶
func (p *ToolProvider) GetTools() []tool.Tool
GetTools returns the regex tool.