Tools, plugins, and hooks

Lesson 30 of 35 · Working with AI coding agents

An agent may already know how to reason about a task but lack a safe way to perform one particular operation. A tool gives it a callable operation with defined inputs and a result. A skill is usually reusable guidance, sometimes accompanied by supporting files; naming and loading differ among products. An agent is a configured worker that can follow instructions and may have its own tools and permissions. These categories overlap in real applications.

A plugin is an extension package that changes or adds application behavior. Depending on the host, it might register a tool, modify a tool’s description, or attach a hook: code invoked at a particular event, such as before or after a tool call. A transform of a definition and a hook on a live operation do different jobs. Exact extension APIs and event guarantees are product-specific; check the host’s current documentation rather than assuming every plugin system supports them.

Design a narrow tool

Imagine a read-only inventory lookup. Its conceptual contract is:

Input:  item identifier
Action: look up that item in an approved inventory
Result: matching name and availability, or a clear error

The identifier is validated, the returned fields are limited, and a missing item is reported as missing rather than invented. This is a design sketch, not executable code or a promise about any provider. It is easier to review than a tool that accepts arbitrary database commands. A tool description tells the model when to use it; the implementation and underlying permissions must enforce the actual boundary.

A schema describes the structured input the host expects, for example “item identifier: required text.” It does not perform the lookup. In a typical tool call, the host passes the supplied input to the implementation, which validates it, performs the permitted operation, and returns a result or error for the host to make available to the model. Validation and error handling still need implementation; an input schema alone does not prevent excessive access.

A plugin transform might change the lookup’s description to say “read only.” That wording can guide selection, but it does not remove a write operation from the implementation or service account. Enforce read-only access in the implementation and underlying service permissions, and verify it independently.

Combining tool calls in a program

Some hosts let an agent write or invoke a program that calls tools. For example, a program could request a read-only list of test inventory, filter for unavailable items, and return only identifiers and names to the model. This may reduce the material returned to the conversation, depending on the host. It can also omit relevant records or errors, so include limits and report failures rather than presenting a filtered result as complete.

The program and each called tool still run with their own permissions and can access or expose data before filtering. Local filtering does not undo that exposure or make executable code safe. Tool discovery, approvals, data handling, and any context savings depend on the product; inspect actual controls before enabling this pattern.

A hook might record that the lookup ran and whether it failed. Logging full inputs and outputs could expose personal data or secrets, so decide what is needed, who can read it, and how long it is retained. A failing hook may interrupt work, depending on the host; a log is not proof that every side effect was captured.

Extension trust

A generic lifecycle is to choose a trusted package and version, inspect its dependencies and intended personal or project scope, and determine when the host loads it. Enable it first in a disposable, restricted environment; restart or reload only if the host requires it. Check the host’s loaded-extension list if available and verify the registered capabilities with harmless data. When no longer needed, disable or remove it and revoke any separate credentials or grants. Exact discovery and removal behavior varies by host.

If publishing is in scope, check that the declared entry point matches a file actually present in the distributed package, including any built output required by the host. Source files in a repository are not necessarily what recipients install; compatibility depends on the host and runtime.

Installing a plugin can run third-party code with the application’s or process’s privileges. Review its origin, version, dependencies, requested permissions, and update mechanism. Project-level configuration may affect collaborators; personal configuration may affect unrelated projects. Neither location automatically makes an extension safe. Test with disposable data and restricted access, verify the exposed tool and its behavior, and remove or disable the extension when it is unnecessary. Publishing an extension also requires checking dependencies, documentation, licensing, and accidental inclusion of secrets.