toolkits
Build an agent's tool list by combining the bundles it needs. Construct lists inside a function when they include searchTools, so API-key selection happens at call time. Bundle membership describes the tools available; the caller's handlers still decide their interrupts.
import { readOnlyFileTools, webTools } from "std::agents/lib/toolkits"
node main() {
const tools = [...readOnlyFileTools(), ...webTools()]
const answer: string = llm("Summarize README.md", { tools: tools })
print(answer)
}No bundle has a status tool. An agent whose prompt includes PROGRESS_NOTE reports progress in a sentence it writes beside each tool call, and nothing prints that sentence by default. To show it, register an onLLMCallEnd callback. agency agent does this in its trace.
callback("onLLMCallEnd") as data {
const calls = data.result.toolCalls ?? []
if (calls.length > 0 && data.result.output != null && data.result.output != "") {
print(data.result.output)
}
}Constants
CODING_RULES
The opening of a system prompt for an agent that offers codingFileAndShellTools(): one sentence, and a rule for each tool. The first rule sends listing and searching to bash, because the bundle has no tool for either.
/** The opening of a system prompt for an agent that offers
`codingFileAndShellTools()`: one sentence, and a rule for each tool. The
first rule sends listing and searching to `bash`, because the bundle has no
tool for either. */
export static const CODING_RULES = """You are a coding assistant. Help users inspect files, run commands, and modify code.
- Use bash for file operations like ls, grep, find.
- Use read to examine files instead of cat or sed.
- Use edit for targeted changes. Batch changes to one file in a single call.
- Use write only for new files or complete rewrites.
- Be concise in your responses.
"""(source)
PROGRESS_NOTE
export static const PROGRESS_NOTE = "- When you call a tool, write one short sentence in the same response saying what you are doing. That sentence is how the user follows your progress."(source)
SAVE_DRAFT_HINT
export static const SAVE_DRAFT_HINT = "\n\nIf you might run low on time or budget, call `saveDraft` with your best answer so far as you work, and update it as you improve. If the run is cut short, the last draft you saved is what the user receives — a run that saved nothing returns nothing."(source)
Functions
readOnlyFileTools
readOnlyFileTools(): any[]Return file inspection tools rooted in the agent's working directory.
ls, glob, and grep always respect .gitignore. The setting is bound so the model cannot include ignored files by changing an argument. The model can still search an ignored folder by naming it as the folder to search.
Returns: any[]
(source)
writableFileTools
writableFileTools(): any[]Return file inspection, write, and edit tools.
Returns: any[]
(source)
shellTools
shellTools(): any[]Return command execution tools for the agent's working directory.
safeBash parses pipelines and raises effects for recognized operations. exec runs one binary with arguments. Both use the agent's working directory. Output too long to return inline is saved, and its notice gives a path that safeBash reads like any file, so the bundle has no separate readers.
Returns: any[]
(source)
codingFileAndShellTools
codingFileAndShellTools(commandJudge: CommandJudge | null = null): any[]Return the file and shell tools for a coding agent.
The four tools a model needs to work on code: read, bash, edit, and write. Output too long to return inline is saved, and its notice gives a path that read and bash both read. Three are shaped for a model: read returns at most 2,000 lines when the model gives no limit, write always overwrites, and safeBash is offered as bash with its cwd bound to the agent's working directory. There is no ls, glob, grep, or exec: bash does the listing, searching, and running, and every tool definition is sent with every request. An agent that uses this bundle tells the model so with CODING_RULES.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
| commandJudge | CommandJudge | null | null | A decision model that may refuse a bash command too complex to review, or null for none |
Returns: any[]
(source)
jobTools
jobTools(commandJudge: CommandJudge | null = null): any[]Return the tools for running a shell command as a background job.
Start a shell command in the background, read its output, and stop it. Not part of shellTools(): an agent that exits when its turn ends would stop its jobs before they finish.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
| commandJudge | CommandJudge | null | null | A decision model that may refuse a command too complex to review, or null for none |
Returns: any[]
(source)
spillTools
spillTools(): any[]Return tools for reading and searching saved tool output.
Add these when an agent enables spillToolResultsOver and has neither read nor a shell tool, so it can read a saved tool result by its path.
Returns: any[]
(source)
readOnlyGitTools
readOnlyGitTools(): any[]Return Git repository inspection tools.
Use gitIsRepo to detect a repository from a package subdirectory. Git finds the repository root even when .git is in a parent directory.
Returns: any[]
(source)
gitTools
gitTools(): any[]Return Git repository inspection and modification tools.
Repository modifications raise approval interrupts. The inspection tools are also available separately from readOnlyGitTools.
Returns: any[]
(source)
githubReadTools
githubReadTools(): any[]Return tools for reading GitHub pull requests, issues, and their comments.
The tools resolve the repository from the origin remote under the agent's working directory. They read remote data and cannot post reviews or comments.
Returns: any[]
(source)
githubTools
githubTools(): any[]Return GitHub lookup, review, comment, and issue-management tools.
Each remote write raises an approval interrupt. Pull-request approval has its own effect, so policies can permit comments while refusing approvals.
Returns: any[]
(source)
fetchTools
fetchTools(): any[]Return the HTTP tool, which returns HTML as Markdown and other bodies as received.
For an agent that reads a page it was given the address of, and does not look things up. webTools() is this plus the Wikipedia tools.
Returns: any[]
(source)
webTools
webTools(): any[]Return HTTP and Wikipedia lookup tools for named sources.
Add search tools when an agent must discover sources before fetching them. The HTTP tool returns HTML as Markdown and other bodies as received. Its refresh argument is bound to false to reuse a page within a conversation.
Returns: any[]
(source)
agencyDocTools
agencyDocTools(): any[]Return the five packaged Agency documentation tools.
The bundles cover the guide, CLI, diagnostics, stdlib, and agent docs. Reads through these tools still raise std::read.
Returns: any[]
(source)
agencyDocToolsBrief
agencyDocToolsBrief(): any[]Return packaged documentation tools with compact page listings.
Use compact listings when the prompt already teaches the language. Offer this bundle or agencyDocTools: both use the same tool names.
Returns: any[]
(source)
agencyCodeTools
agencyCodeTools(): any[]Return Agency parsing, typechecking, and test-harness tools.
testFile runs a saved .test.json harness in a subprocess. Use parse and typecheck for source text that has not been saved.
Returns: any[]
(source)
memoryTools
memoryTools(): any[]Return fact storage and retrieval tools for enabled memory.
Returns: any[]
(source)
draftTools
draftTools(offer: boolean): any[]Return the saveDraft tool, or no tools when offer is false.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
| offer | boolean | Whether a caller reads the agent's draft when its budget runs out. |
Returns: any[]
(source)