-
Notifications
You must be signed in to change notification settings - Fork 2
Pre Tools
Pre-tools inject data into a step's prompt before the LLM runs. They execute in order and make their results available as {inject_as} variables.
steps:
- id: my_step
pre_tools:
- type: web_search
query: "AI trends 2026"
inject_as: trends
- type: current_datetime
inject_as: now
prompt: |
Current date: {now}
Trends data: {trends}
Analyze the above trends.
output_var: analysisPre-tools are not LLM calls — they run in-process and cost zero tokens (except web_search which uses Claude's built-in search).
Search the web using Claude's built-in web search tool.
- type: web_search
query: "latest {input.topic} research papers 2026"
inject_as: search_resultsThe query field supports {variable} interpolation.
Fetch data from any URL.
- type: http_fetch
url: "https://api.example.com/data?q={input.query}"
inject_as: api_data- Supports
{variable}interpolation in the URL - Response truncated to 50KB
- Timeout: 30 seconds
- Returns response body as text
Read a file from disk.
- type: read_file
path: "/path/to/context.md"
inject_as: context- Supports
{variable}interpolation in the path - Returns file contents as UTF-8 text
Write content to a file.
- type: write_file
path: "/tmp/output.json"
content: "{previous_step_output}"
inject_as: write_result- Supports
{variable}interpolation in bothpathandcontent - Creates parent directories if needed
- Returns "OK" on success
Execute a shell command.
- type: bash
command: "git log --oneline -5"
inject_as: recent_commits- Supports
{variable}interpolation in the command - Timeout: 30 seconds
- Max output: 10MB
- Returns stdout as text
Read an environment variable.
- type: env_var
var_name: "API_KEY"
inject_as: key- Returns the value of the environment variable
- Returns empty string if not set
Get the current date and time.
- type: current_datetime
inject_as: now- Returns ISO 8601 format:
2026-03-29T14:30:00.000Z - Useful for time-aware prompts
If a pre-tool fails, the error is injected as the variable value:
[PRE-TOOL ERROR: command not found]
The step continues with this error string in the prompt. Design your prompts to handle this gracefully, or use condition to skip steps when pre-tools fail.
Pre-tools execute in order. Later pre-tools can reference results from earlier ones:
pre_tools:
- type: bash
command: "cat package.json"
inject_as: pkg
- type: bash
command: "echo {pkg} | jq '.dependencies | keys[]'"
inject_as: deps- Chain Format — Full YAML reference
- Step Types — How steps use pre-tool data
- Token Optimization — Pre-tools reduce LLM token usage