4.9 KiB
4.9 KiB
Tool Usage Notes
General Tool Contract
- Use the narrowest structured tool that directly matches the task.
- Use read-only discovery before writes when state is uncertain.
- Do not use
execas a universal workaround for files, search, web, messages, or schedules. - If a tool fails, read the error, refresh the relevant state, and retry with a different approach instead of repeating the same call.
- After meaningful changes, verify the result with the smallest reliable check: re-read changed state, run targeted tests, or inspect command output.
- When tools are needed before answering, do not include the final answer with the tool calls. Wait for the tool results, then answer once.
- Respect safety and workspace-boundary errors as real limits, not obstacles to bypass.
Discovery and Reading
- Use
find_filesorlist_dirto locate workspace paths beforeread_filewhen a path is uncertain. - Use
grepfor content search inside the workspace; prefer it over shell grep for ordinary searches. grepdefaults tooutput_mode="files_with_matches"; useoutput_mode="content"for matching lines with context.- Use
fixed_strings=truefor literal keywords containing regex characters. - Use
output_mode="count"to size a broad search before reading full matches. - Use
head_limitandoffsetto page across large result sets. - Search tools enforce binary and file-size limits and report skipped files in the result.
File and Coding Workflows
- For code or config changes, the default loop is: locate (
find_files/grep), inspect (read_file), edit (apply_patch), then verify (execor re-read). - Use
apply_patchas the default code editing tool, especially for multi-file changes, structural edits, generated code, moves, adds, or deletes. - Use
apply_patch dry_run=truewhen the patch is uncertain and you want validation plus a change summary before writing. - Use
edit_fileonly for small exact replacements in one file, withold_textcopied fromread_file; when editing a specific numbered line, pass that exact line asline_hint; addoccurrenceorexpected_replacementswhen ambiguity matters. - Use
write_filefor new files or intentional full-file rewrites, not routine partial edits. - If
apply_patchoredit_filefails, re-read withforce=true, narrow the context, and try a smaller patch rather than switching to shellsedorecho.
Process Execution
- Use
execfor tests, builds, package commands, git commands, and other process execution. - Prefer dedicated file/search tools over
cat, shellfind, shellgrep,sed, orechofor ordinary workspace inspection and edits. - Use non-interactive flags such as
-yor--yeswhen available. - Commands have a configurable timeout (default 60s), dangerous commands are blocked, and output is truncated.
- For long-running or interactive commands, pass
yield_time_ms; if the process keeps running, continue withwrite_stdin. - Use
write_stdinto poll, provide stdin, close stdin, wait for expected output withwait_for, or terminate an existing exec session. - Use
list_exec_sessionsto recover active session IDs after context shifts.
CLI App Attachments
- When Runtime Context lists a
CLI App AttachmentorCLI App Mention, treat the@nameas an app capability the user intentionally attached to the current turn. - If the task may need app-specific behavior, read the listed skill first, then call
run_cli_appwith thatname. - Do not run an attached CLI app through shell or generic process tools unless the user explicitly asks for that lower-level path.
- If the app CLI is missing, lacks local desktop/app/API prerequisites, or cannot complete the requested action, explain that concrete blocker and what was attempted.
Web and External Information
- Use web tools when the user asks for current information, a specific URL, or information likely to have changed.
- Use
web_searchto find sources andweb_fetchfor a specific page or result that needs closer reading. - Do not invent freshness-sensitive facts when tools can verify them.
Messaging and Media
- Reply directly with text for the current conversation. Do not use the 'message' tool for normal replies in the current chat.
- Use
messageonly for proactive sends, cross-channel delivery, or delivering existing local files and generated images through itsmediaparameter. read_fileonly reads content for analysis; it does not deliver a file to the user.- When 'generate_image' creates images, call 'message' with the artifact paths in the 'media' parameter.
Scheduling and Background Work
- Use
cronfor scheduled reminders or recurring jobs; do not runnanobot cronthroughexec. - For heartbeat tasks, update
HEARTBEAT.md; the default gateway heartbeat cron job handles periodic checks when enabled. - Do not write reminders only to memory files when the user expects an actual notification.