Tools and extensions
How tools reach the model, who may call them, how to write your own, and how hosted search and public-web tools work.
Ask Sysadmin how much memory the Pipal host has free. With a tool-capable model and the default extensions, the model can request system_overview, and Pipal can give it a fresh measurement. Read the call from both sides and you’ll see where the model hands the job to ordinary code, and where Pipal decides whether that code may run.
In this chapter
- Follow a tool from the host configuration into a model request.
- Tell what makes a tool visible and what makes its execution permissible.
- Read a small custom extension and find the built-in bundles.
- Follow a documentation lookup from Developer to the service that handles it.
One tool call crosses from a model to code
- Model
- Pi Durable
- Pipal core index.ts
- Clock clock.mjs
Pi Durable → Model · Offer tools
Pi describes the clock tool
The conversation’s saved extension selection includes
example.clock. Pi sends the tool’s name, description, and argument schema.Model → Pi Durable · Call
The model asks for the current time
It returns a call to
current_timewith an empty object for arguments.Pi Durable → Pi Durable · Record
Pi records the call
The tool has a task of its own. Pi commits its intent before running the handler.
Pi Durable → Pipal core · Execute
The wrapper checks the profile
Pipal looks up the chat’s profile and verifies that the currently loaded profile still grants
example.clock.Pipal core → Clock · Read time
The handler reads the host clock
The module’s JavaScript runs in the Pipal process and formats the time as a UTC string.
Clock → Pipal core · Output
The handler returns through the wrapper
The UTC string comes back as a text item in the tool output.
Pipal core → Pi Durable · Tool result
Pi records the tool result
The wrapper returns the handler’s output to Pi.
Pi Durable → Model · Tool result
The next model request includes the result
The model has the time it asked for and can put it into the reply.
Model → Pi Durable · Answer
The model writes an answer
The chat gets the model’s text. The measurement came from the host.
Pi Durable → Model
Pi describes the clock tool
The conversation’s saved extension selection includes example.clock. Pi sends the tool’s name, description, and argument schema.
A tool gives the model a named operation to request. It has a description, a JSON Schema that describes valid arguments, and the function execute() that does the work. The model gets the declaration. When it replies with a call, Pi coerces and validates the arguments, then runs the handler through Pipal’s check. README.md index.ts
A host extensionA named bundle the Pipal host can load to give a conversation tools, prompt sections, or other runtime behavior. is how the host bundles these operations. It can also supply sections of the model’s prompt. The clock example is one extension with one tool. Its whole handler fits on screen, which makes it a good place to see what the host owns. extensions.ts clock.mjs
export default { name: 'example.clock', tools: [{ name: 'current_time', description: 'Get the current UTC date and time.', parameters: { type: 'object', properties: {}, additionalProperties: false }, async execute() { return { output: [{ type: 'text', text: new Date().toISOString() }] }; } }]};The name example.clock is what the operator enables and the profile grants. The model asks for current_time. Its only valid arguments are an empty object, and its result is the UTC time as text. Pi gives the result back to the model so it can answer in the context of your question. clock.mjs README.md
The host loads a bundle and the profile grants it
Start at extensions.enabled in config.toml. Pipal supplies a default list when the field is absent. When you write the list yourself, it replaces the default list. For a custom name, [extensions.modules] points to a file relative to the configuration directory. At startup, the server imports the enabled modules and adds the available built-ins. config.ts main.ts
Now look at the conversation’s profile. Its extensions list requires each bundle. Its optional_extensions list selects names from the host’s enabled list. Core checks that the selected bundles loaded. The resolved selection goes into pi.agent as extension names. This is how the same host can offer the diagnostics to Sysadmin and omit them from Chat’s own tool list. profiles.ts index.ts
Developer’s project tools also need an open locationThe place a chat uses for project tools, either the Pipal host, an account reached over SSH, or a Docker project. and a matching workspace binding. Core’s grants() uses the chat’s pin to choose which project tools the model sees. The host registers one bundle per enabled project extension, even when multiple locations are open. When a tool runs, that registration sends the call to the chat’s location. Three ways to touch a project follows the tools to the directory where they run. index.ts workspace-locations.ts
Imagine you remove a profile grant and restart the host with the tool definition still installed. A parked call can wake, or a call interrupted in progress can be replayed. Pi can enter execute() again without repeating its earlier beforeTool hook. A check made when the model first asked would still reflect the old profile. Checking at the execution boundary lets a resumed call see the new one. index.ts README.md
Deep diveWhere the current policy rejects a saved call
Pi starts with an empty default selection. Pipal installs definitions in the registry, then selects the ones available to each conversation. Installed host tools pass through the wrapper, which logs tool_denied and throws when the current profile lacks the extension. Pi makes a thrown error available to the model as a tool result. Built-in runtime tools such as delegate use their own execution checks. For Developer’s project tools, the wrapper also checks the binding and whether the location supports the tool. read can run without approval. The other project tools need approval for that workspace or a matching YOLO grant. See Approvals and YOLO. index.ts README.md
grants() omits project extensions when the chat has no current binding. With a binding, it removes tools absent from that location’s toolNames and adds instructions naming the location for profiles granted project tools. On execution, Core supplies executionLocation and the project’s scope in developmentProject. The host’s route() rechecks the open location and scope, then calls that location’s implementation. The shared bash and git_clone definitions live in project-tool-definitions.ts. index.ts workspace-locations.ts project-tool-definitions.ts
When the process dies in the middle of a tool invocation, Pi reruns it on recovery if it is declared replay: 'safe', within its restart limit. An unmarked or replay-unsafe call produces an interrupted result. Repeated interruption of a replay-safe call can instead end with restart_limit. Follow the recoverable records in Durable by default. README.md
The built-ins cover different jobs
| Extension and package | Tools and availability |
|---|---|
pipal.delegate (core) |
delegate. Default on. Top-level Chat and Developer. |
pipal.system-diagnostics (server) |
system_overview, top_processes, service_status, listening_port, service_logs. Default on. Sysadmin. |
pipal.web-artifacts (core) |
publish_web_artifact, read_web_artifact. Default on. Chat and Developer. |
pipal.workspace (core) |
workspace_list, workspace_search, workspace_read. Default off. Developer and Code reviewer. |
pipal.project-read (server) |
read, ls, find, grep. Default off. Code reviewer. |
pipal.coding (server) |
read, edit, write, publish_file. In the default list. Developer with a current workspace binding. project-coding.ts |
pipal.bash (server) |
bash, plus git_clone for Docker if allow_git_clone is enabled. In the default list. Developer with a current workspace binding. |
pipal.web-search (core) |
Provider request hook. Default off. Chat and Developer, with a compatible model and request. |
pipal.public-web (server) |
search_public_web searches with Exa. read_url reads a page through Jina Reader. Default off. Developer can use both without a web-service API key. |
codemode (Pi Durable) |
codemode. Default off. Sysadmin. |
pipal.workers (core) |
start_worker, continue_worker, worker_status, wait_worker, stop_worker. Installed by core. Offered to top-level Chat and Developer with a current named project on This machine or SSH machine, when delegation is enabled and the chat’s profile or an allowed specialist has project tools. index.ts |
pipal.routines (core) |
Scheduler task. Installed by core. Available without a profile grant or an entry in extensions.enabled. routines.ts |
pipal.turn-budget (core) |
Model request and tool hooks. Installed by core. grants() attaches it when applying the conversation’s profile grants. It warns as tool rounds run low and reserves a final text answer. index.ts turn-budget.ts |
These defaults apply when you leave extensions.enabled out. The table names the bundled profiles eligible to use each extension. pipal.workspace needs extensions.workspace_root and pipal.project-read needs extensions.coding_root. Docker also needs [extensions.project_shell] and an explicit list granting pipal.coding or pipal.bash. A fresh installation starts with every location off. An upgrade without saved settings carries over a configured SSH or Docker grant. If an enabled location’s connection probe fails, the owner can use Retry connection in Settings → Workspace. config.ts workspace-locations.ts
publish_file passes through the workspace approval gate and attaches a copy of a project file to the chat. Files in, artifacts out follows project file downloads and web artifacts. Routines explains how the scheduler sends a prompt without a model tool call. index.ts project-coding.ts
Host diagnostics. system_overview reads from Node’s system APIs. The other probes start fixed executables, such as /bin/ps for the process list on macOS and Linux. The model can choose memory or CPU as the sort order. Inputs such as a port number or service name are bounded by the tool schema. Service status and service logs are available on macOS and Linux. system-diagnostics.ts
Deep diveHow the diagnostics keep inputs inside a probe
runDiagnosticCommand() uses execFile with an executable and an argument array. It supplies a reduced environment and a 5-second timeout, returns standard output, and reports command failures without raw stderr. An aborted call propagates cancellation. For a service lookup, the tool schema bounds the name and scope. The Linux probe requests four fixed systemd properties and puts the unit after --. On macOS the parser extracts selected status fields from launchctl output, which can also contain the service’s environment and command arguments. A few probes place validated values in fixed templates, such as an integer port in the Windows listener query. There is no arbitrary command field in the diagnostic tools. diagnostics-command.ts system-diagnostics.ts
Code Mode. For one measurement, Sysadmin’s instructions say to call the diagnostic tool directly. When you want memory usage and the busiest processes, codemode lets the model write a script that calls the available diagnostic tools and filters their results before returning them. Pi runs that JavaScript in a QuickJS sandbox and treats the calls it makes as nested tool calls. sysadmin.md README.md
The clock can be your first host module
Deep diveWhat the server expects from a module export
A module can default-export its extension object, as the clock does, or a function that returns the object. The loader calls a function export with { dataDir } pointing to extensions/<name>/ inside the private data directory. It checks the export’s shape, requires the exported name to match the TOML key, and reports the module and path on failure. Modules may supply prompt sections or an HTTP handler as well as tools. A module can also name a Code Mode namespace so scripts can discover its tools together. At startup the server registers HTTP handlers separately from the tools and prompt sections. A module with only an HTTP handler belongs to the server’s route table. Its route uses workspace authentication, independent of the chat’s tool grant. extensions.ts main.ts app.ts README.md
Hosted search happens inside the provider request
- Pipal core
- Pi
- Provider
- Hono app.ts
- Browser
Pi → Pipal core · Request hook
Pi has a provider request ready
Pi invokes the selected search extension’s hook. Pipal checks the current profile grant, then checks the model and request for search compatibility.
Pipal core → Pi · Add search
Pipal adds the provider’s search declaration
On a compatible OpenAI Responses request, the added type is
web_search. Any local function declarations stay in the request.Pi → Provider · Generate
The provider receives one generation request
The provider can decide to search while generating its answer.
Provider → Provider · Search
The provider handles the search
The search runs outside the Pipal host, within the provider’s generation.
Provider → Pi · Provider events
The provider streams progress
The search events belong to the same generation as the answer.
Pi → Pipal core · Observe event
An adapter observes the raw provider events
Pi’s provider stream calls Pipal’s observer, which tracks search status and collects URL citations.
Pipal core → Pi · Live metadata
Pi receives the activity on a partial message
Pipal’s stream wrapper can publish search activity before any answer text arrives.
Pipal core → Hono · Live view
Core projects the activity
Core reads Pi’s live message and exposes
liveSearcheson the conversation snapshot that Hono watches.Hono → Browser · Live activity
Hono streams the update
The browser can show the search activity before the answer text.
Pipal core → Pi · Final metadata
Search activity travels with the answer
Pipal attaches the observed searches and sources to the assistant message that Pi saves. Core includes the recorded sources when it projects the transcript again.
Pi → Pipal core
Pi has a provider request ready
Pi invokes the selected search extension’s hook. Pipal checks the current profile grant, then checks the model and request for search compatibility.
Ask Chat or Developer a question that needs current public information. With pipal.web-search enabled and a compatible model selected, Pipal can give the provider permission to search. A generation hook, code Pi runs on the way to the provider, adds the provider’s own search declaration to the request. That makes it hosted searchWeb search that the model provider runs while generating an answer.. The search takes place while the provider is producing the answer, so there’s no local tool handler to return a result. developer.md hosted-search.ts
While the answer streams, Pipal reads the provider’s progress and citations. It attaches searches and sources to the assistant message as metadata, information about the answer that travels with it. You can see search activity before the first words and find the cited sources when you reopen the chat. hosted-search.ts view.ts
Deep diveWhen adapters add search and what they record
The generation hook checks the current profile grant even for a recovered request. The adapter is chosen by provider, transport and model ID. OpenAI Responses uses an allowlist and adds web_search. It skips minimal reasoning effort and preserves existing search declarations, including preview variants. DeepSeek’s Chat Completions adapter adds deepseek_web_search for deepseek-flash when the request is compatible. Both skip adding search when tool_choice is set to anything other than auto. Compaction, Pi’s pass to summarize earlier context, runs without the search grant. hosted-search.ts hosted-search-capabilities.ts responses-search.ts deepseek-search.ts responses-search.test.ts
OpenAI reports search items and annotations in its event stream or terminal response. DeepSeek reports hosted activity in choice events and deltas. The adapters collect activity separately from local function calls and deduplicate parseable HTTP and HTTPS citation URLs. search-metadata.ts writes the versioned pipal field on the assistant message and also reads the older top-level fields. When a saved answer contains a search whose last status was running, the transcript shows it as interrupted. responses-search.ts deepseek-search.ts hosted-search-adapter.ts search-metadata.ts view.ts
The host can look up a public page
Ask Developer to read https://nodejs.org/api/fs.html. With pipal.public-web granted, read_url sends that URL from the host to Jina Reader and returns the extracted Markdown. To find a page, search_public_web sends a query to Exa and returns titles, URLs and excerpts. public-web.ts
Developer requests both web extensions in optional_extensions. Enable either or both in extensions.enabled and restart Pipal. The host tools need a tool-capable model and no separate API keys. Developer’s instructions favor provider-hosted search, suggest Exa as a fallback, and ask the model to keep private details out of requests. developer.md config.example.toml
Either web extension can work in a Docker chat. Bash and ordinary file calls still run offline. Both Settings → Workspace and Runtime show “Shell commands run without network access.” The separately gated git_clone uses its own networked stage to bring a repository into the Docker project. project-shell.ts workspace-choice.ts
Deep diveWhat Exa and Jina Reader receive
search_public_web accepts a nonblank query of up to 400 UTF-16 code units. The host trims it and calls Exa’s web_search_exa tool with a JSON-RPC POST to https://mcp.exa.ai/mcp. Exa can reply with JSON or a stream of events. Pipal takes the matching reply, checks the URLs in the first five hits and drops hits that fail validation. Each title is capped at 256 code units and each excerpt at 1,500. public-web.ts
read_url accepts one HTTPS URL of up to 4,096 code units. It requires a DNS name, rejects embedded credentials and local-style domain endings, and drops the fragment. The host appends that URL to https://r.jina.ai/ and sends a GET. The tool returns the normalized URL, up to 24,000 code units of page content and a truncated flag. public-web.ts
Both requests omit credentials, reject redirects and use a 30-second deadline. The host stops reading with an error if the response exceeds 1 MiB. Both tools declare replay: 'unsafe' because another lookup consumes provider quota. public-web.ts
The clock’s handler returns a text item without waiting on another task. What if the tool has to wait for another conversation to produce an answer? Delegation follows the delegate call from handoff to wake-up.
Recap
- The host loads extensions. The conversation’s profile selects the bundles the model can use, and Pipal checks the grant at execution.
- A chat’s workspace binding determines which project tools it gets and where their calls run.
- A custom module supplies host code. Code Mode scripts can call tools made available to them.
- Hosted search can leave activity and sources on the answer. Exa search and Jina Reader return ordinary tool results through the host.
- You remove an extension grant while a call is parked, keep its definition installed, and restart before it wakes. Which check sees the change?
- The original tool declaration
- The wrapper when Pi re-enters execute()
- The clock module when it formats its result
Answer and explanation
The wrapper when Pi re-enters execute()
The wrapper checks the current profile at the point of execution. Pi can enter it again without running the earlier hook.
- You add example.clock under extensions.modules but leave extensions.enabled at its default. What happens to the custom module?
- Pipal imports it because its path is known
- Pipal imports it when the first chat asks for time
- Pipal leaves it unloaded
Answer and explanation
Pipal leaves it unloaded
The path tells Pipal where to find an enabled module. The enabled list determines what Pipal imports at startup.
- Developer uses read_url in a Docker chat. Which process sends the page URL to Jina Reader?
- The Pipal host running the granted tool
- The model provider during generation
- Bash inside the Docker project
Answer and explanation
The Pipal host running the granted tool
read_url runs in the Pipal host. That request leaves the Docker shell offline. Hosted search runs separately during model generation.
You remove an extension grant while a call is parked, keep its definition installed, and restart before it wakes. Which check sees the change?
You add example.clock under extensions.modules but leave extensions.enabled at its default. What happens to the custom module?
Developer uses read_url in a Docker chat. Which process sends the page URL to Jina Reader?