Verify the active API
- Read the installed Pi package documentation and relevant neighbouring tools before implementation. Do not tune a legacy surface as if it were current.
- Extensions register tools with
pi.registerTool({...}). Standalone definitions may usedefineTool({...})where the active SDK supports it. - Prefer
@earendil-works/pi-schemabuilders and validators. Declare it as a direct runtime dependency. - Keep
type: "string"on string enums for provider compatibility. - Keep obsolete public aliases out of the schema. A safe
prepareArguments()normalisation may remain when current model calls justify it.
If legacy markers are present, migrate them before wording or token optimisation. When migration is outside the authorised scope, report the exact blocker rather than certifying the old contract.
Inspect what Pi sends
Trace the complete call path:
name,description,parameters,promptSnippet, andpromptGuidelines- activation and conditional tool exposure
prepareArguments()andexecute()- returned
content, thrown errors, updates, and truncation - provider serialization and system-prompt additions
label, renderers, and most details are user, state, and presentation surfaces. Put every fact the model needs to continue in model-visible content. For locally composed tools, inspect the actual nested return conversion instead of assuming the top-level Pi contract.
Keep prompt metadata narrow
- Use
promptSnippetonly when the tool belongs in Pi's compact inventory. Write one capability fragment without cosmetic punctuation. - Use
promptGuidelinesonly for non-obvious selection, sequencing, timing, or safety. Pi flattens guideline bullets, so name the tool in every line. - Do not repeat schema facts in snippets or guidelines.
- Measure the exact emitted prompt and serialized schemas for each active mode and conditional tool set. Source lines are not the payload.
Return the correct state
- Throw when execution fails. Returning error-shaped success content does not set Pi's tool error state.
- For partial mutation, mark the call as failed while stating what succeeded, what failed, and what must be reread before retrying.
- Include the path, identity, state, output, or continuation handle needed next in
content. - Make cancellation, truncation, empty output, running work, and completed work distinct when the next action differs.
- Keep sensitive or render-only state in
details, but never hide recovery information there.
After implementation, inspect representative provider payloads and run the repository's applicable checks.