Add a new Brain tool
Status: Ready
Article ID: 108
Truth label: Current
Audience: Brain contributor
Reader outcome: Place retrieval and side effects behind explicit boundaries.
Related articles: 021, 068, 110
Target week: 43
Last verified: 2026-09-13
Technical reviewer: Codex extension source audit
Editorial reviewer: Codex editorial audit
Define the contract
Specify typed inputs, bounded output, error states, timeouts, cost or resource limits, and whether the operation only reads or also changes external state. Reject ambiguous or oversized requests before calling the dependency.
Enforce trust at the boundary
Resolve project and client scope through the approved gateway. Treat retrieved text and tool output as untrusted evidence. Require explicit operator authority for sensitive reads or side effects.
Minimize the capability
Give the tool only the network, filesystem, credential, route, and collection access it needs. Return provenance and a structured error without exposing raw secrets or content-bearing traces.
Test the failure surface
Cover valid input, validation rejection, timeout, dependency outage, scope denial, malformed response, repeated call, and side-effect idempotency. Add a negative two-scope test for any retrieval path.
Current limits
Not every current Brain retrieval path shares one complete scope gateway. Adding a new direct store call can widen that gap. Tool registration also does not make provider output trustworthy or deterministic.
Next lesson
Continue with Add a new chat provider adapter.
Derivative map
- Weekly package: WEEK-43
- Long video: VIDEO-W43-LONG
- Shorts: SHORT-W43-PROBLEM, SHORT-W43-MECHANISM, SHORT-W43-WARNING
- Email: EMAIL-W43
- LinkedIn: LI-W43-A, LI-W43-B
- X: X-W43-A, X-W43-B
- Visual: VISUAL-W43
Review record
- Input, output, errors, timeout, resources, and mutation class defined.
- Scope, trust, authority, and minimal capability stay at the boundary.
- Outage, denial, malformed, retry, and idempotency tests included.
- Current scope-gateway gap remains explicit.
Review completed: 2026-08-27
Re-audited against the running product: 2026-09-13