Expand description
Tools the agent can call.
A Tool is a named capability with a JSON-Schema input and an async
execute. The ToolRegistry holds the set offered to a model; built-ins
cover file read/write/edit, directory listing, glob, content search, and
shell execution. Every tool can be disabled or re-described per
crate::Config, so the capability surface is entirely yours to shape.
Modules§
- clock
- BP-3 (catalog row “Clock / sleep tools”, cc§1
ScheduleWakeupvariant / cx§1clock+sleepfeatures): the two tools that let a model read the wall clock and pace itself. - context_
budget - BP-3 (catalog row “Context-budget tools”, cx§1’s
token_budgetfeature):get_context_remainingandnew_context, the MODEL’s doors onto two mechanisms the agent already owns. - convert
- BP-2: document conversion for the read and web tools — the “returns it in a form the model can actually use” half of three catalog rows:
- image_
gen - BP-3 (catalog row “Image generation tool”, cx§1’s
image_genfeature): a client-issued call to the PROVIDER’s image endpoint. - plan_
mode - BP-3 (§2 module 8
plan_mode, catalog rows “Plan-mode enter/exit tools” and “Plan mode (read-only research phase)”): the model-invocable restriction mode. - question
- BP-3 (§2 module 6
tools.question, catalog row “Structured user-question tool”): the tool a model uses to ask the USER a multiple-choice or free-text question mid-run, and wait for the answer.
Structs§
- Apply
Patch Tool - Apply a Codex-style
apply_patchenvelope — Codex’s primary edit mechanism, richer thanedit_file’s single string replace. SupportsAdd File,Delete File, andUpdate File(with-/+/context hunks and an optional*** Move to:rename) in one atomic-ish call. - AskUser
Tool - The structured user-question tool.
nameis the registered spelling —ASK_USERundercc-parity, additionallyREQUEST_USER_INPUTundercx-parity. - Bash
Tool - Run a shell command via
sh -c. - Context
Budget - The shared context accounting the two tools read and write.
- Current
Time Tool current_time— the wall clock, ISO-8601 plus timezone.- Edit
File Tool - Replace an exact substring in a file.
- Enter
Plan Mode Tool enter_plan_mode— start the read-only research phase.- Exit
Plan Mode Tool exit_plan_mode— present the plan for approval and, if approved, leave the read-only phase.- GetContext
Remaining Tool get_context_remaining— how much of the context window is left.- Glob
Tool - Match files by glob pattern.
- Image
GenTool image_gen— generate an image through the session’s own provider.- List
DirTool - List directory entries.
- Network
Policy - P4c (S2 module 5
tools.web, S2.1 dep “network sandbox rules”, S17): the network-domain policy a caller (SDK embedder) may install on aToolContextsocrate::tools::WebFetchTool/crate::tools::WebSearchToolrespect it — seeToolContext::check_network.Noneon the context (the default) means no policy is configured, matching today’s honest gap (no P5capabilities.permissions.sandbox.networkengine exists yet, C3 — tracked, not hidden). - NewContext
Request - One parked fresh-window request, as the model stated it. The fields are
exactly
Agent::new_context’s parameters — this type carries a request across the tool/agent boundary, it does not add semantics of its own. - NewContext
Tool new_context— continue in a fresh window seeded with an objective and the curated recent tail.- Persistent
Shell Tool - A long-lived shell whose state (working directory, environment variables,
shell functions) persists across calls — unlike the one-shot
BashTool. Also supportswrite_stdinto feed raw input to the shell, for driving interactive programs. This is the analog of Codex’s persistent exec session. - Plan
Mode State - The shared plan-mode state: whether the read-only research phase is active, and the plan accumulated so far.
- Question
- One question in an
AskUserToolcall. - Question
Option - One selectable answer.
- Read
File Tool - Read a UTF-8 text file.
- Search
Tool - Regex search file contents (respecting .gitignore).
- Skill
Tool - Load a discovered skill package’s body on demand.
- Sleep
Tool sleep— pause this turn for a bounded number of seconds.- Tool
Approval Handler - BP-3: an approval handler reachable from inside a
Tool::execute(today,exit_plan_mode’s plan approval). A newtype purely soToolContextcan stayDebug— the same shape, and the same reason, ascrate::sandbox::SandboxApprovalHandler. - Tool
Context - Ambient context passed to every tool invocation.
- Tool
Registry - An ordered set of tools offered to the model.
- Update
Plan Tool - A simple plan / task tracker. The model calls it to record or update a
checklist of steps (the analog of Codex
update_plan/ Claude’s plan mode). - User
Question Handler - The handler
ask_userasks through, wrapped soToolContextcan stayDebug— the same newtype shape (and the same reason) ascrate::tools::ToolApprovalHandler. - View
Image Tool - P4c (S1.2
view_image, SPLIT CX rowview_image, catalog:28): a dedicated image-input tool, distinct fromread_file’smultimodalmode — needed as an image pathway whenread_fileitself is disabled (cx-parity, S12). NOT registered by default; only reachable as the optional fifth name in[core.tools] enabled(seeToolRegistry::from_config). - WebFetch
Tool - P4c (S2 module 5
tools.web, S4a “trivially addable… single tool each, no loop changes”): fetch a URL and return it AS MARKDOWN (BP-2, catalog:44 “Fetch a URL, convert to markdown, return to model”), served from an on-disk cache within [WEB_FETCH_TTL_SECS] of the last fetch — CC’s WebFetch is markdown-converting and cached, and a model that re-fetches the same page mid-task should not pay for it twice. NOT registered by default — only reached via[capabilities.tools_web](module 5), off by default (§3.1). SECURITY (S2.1 S17): honorsToolContext::network_policywhen one is configured (seeToolContext::check_network) — a caller (SDK embedder) that has set up a sandbox/network policy on the context gets it enforced here too; with no policy configured (today’s honest default), the fetch is unrestricted, same posture as every other network-capable path in this crate today (C3). - WebSearch
Tool - P4c (S2 module 5
tools.web): perform a web search. - Write
File Tool - Create or overwrite a file.
- Write
Observer Chain - P5-11 (§2 modules 28/29, D-5 “shared write-path interception seam”): an
ORDERED chain of
WriteObservers installed as a singleToolContext::write_observer, so the ONE seam P5-9 built keeps supporting exactly one call site per tool while now composing multiple concerns. Order is caller-determined (crate::agent::build_tool_contextbuilds itcheckpoint → formatters → lsp, design’s own required ordering: checkpoint must capture the PRE-image before anything mutates the file; formatters must run before lsp so diagnostics reflect the FINAL, formatted file, not the model’s pre-format draft).before_writeruns every observer in order;after_writeruns every observer in order too and joins any non-empty annotations with a blank line, so a formatter’s diff-back and an LSP diagnostics block can both appear in one tool result without one silently discarding the other.
Enums§
- Read
State - BP-2 (catalog:32 “Edit refuses unless file was read (and unchanged)
this conversation”): how a path stands relative to the model’s own most
recent read of it — see
ToolContext::read_state. - Sandbox
Policy - Filesystem confinement applied to write-capable tools — the analog of
Codex’s
read-only/workspace-write/danger-full-accesssandbox modes. - Schema
Tier - How verbose an advertised tool schema is.
Fullis today’s behavior — byte-identical to the tool’s owndescription()/parameters(). Builtins default toFull(small, load-bearing); the win target is fat activated MCP tools (set via the global knob or a per-tool override, seecrate::Config::tool_schema_tier/crate::config::ToolOverride::schema_tier).
Constants§
- ASK_
USER - Registered name of the question tool (Claude Code’s
AskUserQuestion). - CURRENT_
TIME - Registered name of the clock tool.
- DEFAULT_
WEB_ SEARCH_ URL - BP-2: the backend used when no operator endpoint is configured.
- ENTER_
PLAN_ MODE - Registered name of the enter tool (Claude Code’s
EnterPlanMode). - EXIT_
PLAN_ MODE - Registered name of the exit tool (Claude Code’s
ExitPlanMode). - GET_
CONTEXT_ REMAINING - Registered name of the remaining-budget tool.
- IMAGE_
EXTENSIONS - P4c (S1.2
core.tools.read_file.multimodal/view_image): recognized image file extensions (lowercase, no dot) — the same set CC/pi treat as “images” for multimodal read (catalog D1 row 2’s✓*/✓*variants). - IMAGE_
GEN - Registered name of the image tool (Codex’s own spelling).
- MAX_
SLEEP_ SECS - The longest a single
sleepcall may pause the turn: four hours, the “pause up to hours” the catalog row describes, with a hard ceiling so a runaway loop cannot park a session forever. - MULTIMODAL_
IMAGE_ MARKER - P4c (COMPOSABLE-HARNESS-DESIGN.md S1.2/S3.1
core.tools.read_file multimodal, S1.2view_image): the sentinel prefix a tool’s plainStringresult carries when it is actually an image data URL rather than ordinary text —Agent::run_loopdetects this prefix (beforecap_tool_outputever sees it) and builds acontent_partsimage block instead of a plain-text tool result. Using a control character (\u{1}, SOH) as part of the marker keeps a false-positive collision with real tool output astronomically unlikely without requiring a newTool::executereturn type across all ten built-ins (an L-sized trait-signature change this S-sized catalog item does not call for). - NEW_
CONTEXT - Registered name of the fresh-window tool.
- NOTEBOOK_
EXTENSION - P4c (S1.2
core.tools.edit_file.notebook_aware): the extension that gatesEditFileTool’s Jupyter cell-surgery branch. - REQUEST_
USER_ INPUT - Codex’s experimental spelling for the same capability (cx§1
request_user_input), registered as an alias undercx-parity. - SKILL_
TOOL - The registered name of the skill-invocation tool.
- SLEEP
- Registered name of the sleep tool.
- WEB_
CACHE_ DIR_ ENV - BP-2: directory override for the fetch cache (tests, and an operator who wants it somewhere specific).
- WEB_
SEARCH_ URL_ ENV - Environment variable naming the search endpoint
WebSearchToolqueries.
Traits§
- Tool
- A callable capability.
- Write
Observer - P5-9 (design §2 module 20
checkpoint, §2.1 D-5 “write-path interception seam shared withformatters”): the ONE well-defined interception point around every file-mutating built-in tool (write_file/edit_file/apply_patch) — installed onToolContext::write_observer,Noneby default. Both hooks fire AFTERToolContext::check_writehas already approved the call (so an observer never sees a write the sandbox itself refused) and BEFORE/AFTER the actual mutation:
Functions§
- image_
mime_ for - The
image/<subtype>MIME type for a recognized image extension, for thedata:URL — falls back topngfor anythingis_image_pathdidn’t already gate (defensive; never actually hit throughis_image_path’s own extension list). - is_
image_ path - Whether
path’s extension is a recognized image type (case-insensitive). - minify_
tool_ schema - Apply
tierto a tool’s advertiseddescription/parameters, returning the (possibly) minified pair. Deterministic and LLM-free: the same inputs always produce the same output. - shell_
sandbox_ unenforceable - True when the requested sandbox policy cannot be enforced for shell
subprocesses: a confining policy, a platform without an OS sandbox
primitive wired up (only macOS/seatbelt is, via
sandbox-exec), and at least one shell tool ("bash"or"shell") enabled.