Skip to content

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.

ts
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.

ts
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.

ts
/** 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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
writableFileTools(): any[]

Return file inspection, write, and edit tools.

Returns: any[]

(source)

shellTools ​

ts
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 ​

ts
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:

NameTypeDefaultDescription
commandJudgeCommandJudge | nullnullA decision model that may refuse a bash command too complex to review, or null for none

Returns: any[]

(source)

jobTools ​

ts
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:

NameTypeDefaultDescription
commandJudgeCommandJudge | nullnullA decision model that may refuse a command too complex to review, or null for none

Returns: any[]

(source)

spillTools ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
memoryTools(): any[]

Return fact storage and retrieval tools for enabled memory.

Returns: any[]

(source)

draftTools ​

ts
draftTools(offer: boolean): any[]

Return the saveDraft tool, or no tools when offer is false.

Parameters:

NameTypeDefaultDescription
offerbooleanWhether a caller reads the agent's draft when its budget runs out.

Returns: any[]

(source)