TechFabricTechFabricHarness
Building Agents

Tools

The model-callable functions that ship with TechFabric Harness, and how a tool call is bounded before it reaches your system.

Tools are functions the model can call during a session. TechFabric Harness ships a built-in toolbelt that mirrors the proven coding-agent pattern.

Built-in tools

Tools may declare timeoutMs (1 through 2,147,483,647 milliseconds). Local, recovery and Temporal activity execution pass a deadline-aware abort signal and stop waiting when it expires. Cancellation doesn't undo external effects, so tools must honor the signal and use stable idempotency keys. ToolTimeoutError distinguishes a tool deadline from parent cancellation.

A tool's context.policy is the effective capability policy the call was evaluated under (a prompt() policy over the session's over the agent's). That holds for calls the model makes during a prompt as well as for explicit toolCalls, on both the native and the Pi loop, so a prompt's policy gates and reaches every tool call in it, including a dynamic agent's calls after its turn refresh and a durable call recovered when the prompt resumes the session. A policy passed to agent.session() likewise outranks a dynamic agent's rendered policy after a refresh, and so does one carried into a session.task() child or a fork().attach() session. When a refresh leaves no policy at all, the next call runs with none rather than the previous turn's. With a durable session runtime, the call's policy, else the session's (else the agent's), is forwarded to the worker, and the worker enforces it. context.sandbox is the session's sandbox under that same effective policy, layered over the session's own, so a prompt's filesystem or commandPolicy rules narrow what a tool reaches through the sandbox. Built-in tools use context.sandbox too. Tools that reach the network or the filesystem themselves, rather than through the sandbox, must enforce it; web_fetch checks its network rules on every page request.

annotations preserves MCP hints such as readOnlyHint; annotations do not grant permissions or replace capability policy. Hook-authored tool definitions preserve both fields.

ToolPurpose
readRead a file from the sandbox.
writeWrite a file to the sandbox.
editApply a localized edit (find/replace) to a file.
bashExecute a shell command in the sandbox.
grepSearch file contents.
globMatch files by pattern.
taskSpawn a child task.

All built-ins are capability-aware: write and edit honor any filesystem write scope declared on the session, bash honors the configured commands allowlist.

The model-facing tools have stable output and concurrency limits. See Agent behavior for paging, truncation, timeout, exact-edit, and same-file serialization semantics.

Constructing the toolset

import { createBuiltinTools } from '@fabric-harness/sdk';

const sandbox = await session.sandbox;
const tools = createBuiltinTools(sandbox);

await session.prompt('Find and fix the failing test', { tools });

By default, session.prompt() uses the built-in tools. You typically only override this when you want to limit which tools are available or augment with custom ones.

Custom tools

Both defineTool and createBuiltinTools are also exported from @fabric-harness/sdk. Swap the import path when you want the minimal entrypoint.

import { defineTool, schema } from '@fabric-harness/sdk';

const fetchIssue = defineTool({
  name: 'fetch_issue',
  description: 'Fetch a GitHub issue by number.',
  input: schema.object({ number: schema.number() }),
  output: schema.object({ title: schema.string(), body: schema.string() }),
  run: async ({ data }) => {
    // data.number is validated against the input schema
    return { title, body };
  },
});

await session.prompt('Triage issue #42', { tools: [...tools, fetchIssue] });

Web search and web fetch

web_search and web_fetch come from @fabric-harness/cloudflare/web, backed by Cloudflare's Web Search API and Workers AI Markdown Conversion. They run in a Worker or from Node with an API token. See Cloudflare: Web search and web fetch.