A reusable agent tool layer gives several projects the same reliable way to access capabilities while letting each project retain its own tasks, permissions, and account choices. Share transport, contract validation, provenance, and recovery. Keep product-specific decisions close to the application that owns them.
This is useful when Claude Code, a custom research agent, and an internal workflow all need similar external services. Copying provider adapters between them creates repeated setup and inconsistent failure behavior. A focused shared layer can remove that repetition without forcing every project into the same agent framework.
The design starts with domain contracts, then connects them to o11 or direct providers behind a small implementation boundary.
Start with a capability map
List the operations projects actually share. “Web access” is too broad; “retrieve a public page and retain source provenance” is a useful starting capability. “Media” is too broad; “generate one approved image and retrieve the completed asset” is more actionable.
For each capability, record inputs, acceptance criteria, side effects, account requirements, and lifecycle. This exposes which parts can be shared and which belong to a specific product.
For example, two projects can share page extraction and evidence validation. One may require only official documentation, while another researches company websites. Their allowed domains and editorial rules should remain separate configuration or application logic.
Do not begin by wrapping every provider operation. A shared package with a large speculative surface becomes another catalog to maintain. Build the capabilities needed by current workflows, then expand when a second real consumer benefits.
The tool-set selection guide helps distinguish useful coverage from unnecessary options.
Define a domain result contract
The model and application should not depend on every supplier’s raw response shape. Define the smallest result that preserves meaning, provenance, and uncertainty.
export type EvidenceResult =
| {
state: "complete";
invocationId: string;
sourceUrl: string;
retrievedAt: string;
text: string;
}
| {
state: "pending";
invocationId: string;
}
| {
state: "unavailable";
reason: string;
invocationId?: string;
}
| {
state: "review_required";
invocationId: string;
}; This is an application-owned example, not an o11 response schema. The review_required branch can represent an uncertain external outcome that must not be replaced automatically. The complete branch requires actual source information, not a guessed URL or timestamp.
Validate supplier data before constructing this result. A TypeScript type describes what code expects; it does not prove an untrusted response conforms. Keep missing fields visible and reject results that cannot meet the domain contract.
For structured inputs, JSON Schema’s object rules distinguish required fields and additional properties. Apply those constraints deliberately rather than treating a broad object as a meaningful contract. JSON Schema object reference.
Separate transport from provider mapping
The transport module handles authentication, operation paths, JSON encoding, and typed transport errors. It should not decide which company evidence is credible or which voice a customer is allowed to use.
The provider mapping translates a domain input into the inspected operation’s contract and translates its result into the domain output. It knows the selected tool identifier, supported options, and result projection.
The application policy decides whether the task is authorized, which account context applies, and what maximum is approved. Keeping these concerns separate makes a supplier change smaller and an authorization review clearer.
For o11, reuse the public HTTP adapter from the custom agent tutorial. The private repository SDK is not required for that interface. You can also keep a direct-provider implementation behind the same domain contract where it serves a legitimate need.
Avoid a universal adapter that hides all provider differences. If a capability requires special resource ownership or asynchronous handling, represent that explicitly. A little visible specificity is safer than a false common shape.
Make execution intent a shared primitive
Every external operation should begin with a durable intent. The intent binds the task, approved inputs, account mode, operation, maximum, and idempotency key. It is the record that survives retries and framework replays.
The shared layer can require an intent reference rather than generate one opportunistically. That prevents one project from using stable keys while another creates a fresh purchase every time a node reruns.
| Record | Shared responsibility | Application responsibility |
|---|---|---|
| Intent | Preserve immutable execution meaning | Obtain task authorization |
| Invocation | Store identifier and lifecycle | Decide when to continue the workflow |
| Result | Validate and retain provenance | Apply business acceptance criteria |
| Cost | Preserve estimate and settlement separately | Allocate budget and compare value |
| Recovery | Retrieve existing work safely | Escalate or authorize replacement |
This table can become a code-review checklist. A new consumer should show how each responsibility is fulfilled before it gains paid execution access.
Do not conflate an application request identifier with permission to repeat work. The execution service’s idempotency contract still governs how the original intent is recovered.
Share code without sharing authority
Each project should receive configuration appropriate to its task. The same package can run with different allowed tool identifiers, connections, and spending policies. It should not contain a global credential that silently makes every consumer equally powerful.
Resolve workspace and user access before selecting execution configuration. A client-supplied workspace identifier is not enough. The server must confirm the caller belongs to that workspace and may request the task.
Keep supplier secrets outside prompts, returned results, and durable model checkpoints. The shared layer should accept execution credentials through trusted runtime configuration and redact sensitive material from diagnostics.
Revocation needs a practical path. A compromised development credential should be replaceable without reconnecting every provider account or invalidating unrelated production agents. Separate credentials also improve attribution when reviewing unexpected usage.
The credential management guide covers the operational side of those choices.
Give each framework a thin adapter
The framework-facing code should describe the domain action and call the shared layer. It should not reproduce supplier input mapping, receipt parsing, or retry policy in every tool definition.
For an AI SDK agent, a tool’s input schema can expose a URL while its execute function calls the shared capability. For LangGraph, one node can submit the approved intent and another retrieve existing work. For a coding assistant, MCP can expose discovery and execution through a configured endpoint.
Keep framework versions visible in those thin adapters. A shared capability should not force every consumer to upgrade its agent framework merely because one project’s API changed.
Our AI SDK guide targets the installed version 6 API. The LangGraph guide follows its current JavaScript Graph API. Both preserve the same underlying execution-intent boundary.
This architecture lets teams reuse the difficult operational work while choosing the runtime that suits each application.
Treat recovery as part of the interface
A useful layer exposes status retrieval, pending work, and uncertainty directly. A function that only returns success or throws loses information the workflow needs after a supplier accepted work.
Keep invocation identifiers in domain results. A consumer can resume pending work without knowing the supplier’s internal job protocol. If an outcome is uncertain, return a state that blocks automatic replacement while preserving an operator path.
Do not centralize one universal retry loop. Retrying a status read, correcting invalid input, and replacing failed external work are different actions. The shared layer should make their semantics clear rather than conceal them behind exponential backoff.
Retain partial results at the application level. A generic layer can preserve completed extraction, but the product decides whether a brief is useful without narration. That judgment should remain visible to the user.
Use the failure recovery guide to design consumer behavior for every returned state.
Adopt with two real consumers
Start with one capability and two actual projects. Implement the domain contract, transport, mapping, and recovery once. Let each project supply its own policy and acceptance criteria.
Review the differences that appear. If the projects need different outputs, decide whether they share a lower-level capability or should remain separate. Do not enlarge the contract with speculative fields just to declare reuse.
Verify request shapes and controlled response cases locally. Then use authorized configured environments to validate discovery and, when ready, bounded supplier execution. Record which behavior is documented, locally checked, or live verified.
No paid supplier calls were performed for this article. The design is grounded in o11’s implemented contracts and application architecture. Supplier activation, pricing, and actual workload quality still need environment-specific verification.
Expand when the next consumer needs the same operational behavior. A successful shared layer makes new useful capabilities easier to adopt while leaving each application’s authority and product judgment clear.





