When to use this
Use this guide when your agent already exposes LangChain tools and you want toolAdapter to preserve name, description and schema while guarding the invoke / ToolCall executor. Prefer it after the quickstart. Batch and stream execution have not been qualified.
How to wrap tools
Illustrative offline tool. Install agindow@0.1.0-beta.1, await ready, then wrap the tool collection you already own. toolAdapter preserves name, description and schema and guards the invoke / ToolCall executor. This is the integration point, not the business-logic validation layer.
import { DynamicStructuredTool } from '@langchain/core/tools';
import { createAgindow } from 'agindow';
const sdk = createAgindow({ mode: 'observe' });
await sdk.ready;
const existing = new DynamicStructuredTool({
name: 'search',
description: 'Offline search fixture',
schema: { type: 'object', properties: { query: { type: 'string' } }, required: ['query'] },
func: async ({ query }) => ({ query, provider: 'fixture' }),
});
const tools = sdk.toolAdapter([existing]);
const search = tools[0];
if (search === undefined) throw Error('missing tool');
console.log(await search.invoke({ type: 'tool_call', id: 'call_fixture', name: 'search', args: { query: 'fixture' } }));Customer lookup field drift example
The AGWINDOW integration sits at the call boundary, while the application keeps its own request validation. This example shows a real customer lookup flow: the vendor response changes while the app still expects the prior contract. The detector is configured separately from the tool wrapper; without a supported selection and comparable baseline/live windows, AGINDOW does not manufacture a finding. Missing request arguments are not drift detection, and they should not be used to simulate a vendor response change.
import { DynamicStructuredTool } from '@langchain/core/tools';
import { createAgindow } from 'agindow';
const customerApi = {
async getCustomer(customer_id: string) {
const response = await fetch(`https://api.vendor.example/customers/${customer_id}`);
if (!response.ok) throw new Error(`customer lookup failed: ${response.status}`);
return (await response.json()) as {
customer_id: string;
status: string;
account_balance_cents: number;
};
},
};
const sdk = createAgindow({
mode: 'observe',
selection: {
tenant: 'ops',
connection: 'vendor',
vendor: 'customer-api',
operation: 'customer.lookup',
segment: 'default',
fields: [{
side: 'response',
path: '/customer_id',
baseline: ['{"customer_id":"c_100"}'],
live: ['{"customer_id":"c_100"}'],
enumeration: false,
}],
},
});
await sdk.ready;
const lookupCustomer = new DynamicStructuredTool({
name: 'lookupCustomer',
description: 'Fetch customer details by customer_id.',
schema: {
type: 'object',
properties: { customer_id: { type: 'string' } },
required: ['customer_id'],
},
func: async ({ customer_id }) => {
const body = await customerApi.getCustomer(customer_id);
return {
customer_id: body.customer_id,
status: body.status,
account_balance_cents: body.account_balance_cents,
};
},
});
const [tool] = sdk.toolAdapter([lookupCustomer]);
if (tool === undefined) throw new Error('missing tool');
const result = await tool.invoke({
type: 'tool_call',
id: 'call_customer_lookup',
name: 'lookupCustomer',
args: { customer_id: 'c_100' },
});
console.log(result);
console.log(sdk.recent().map((event) => event.type));Critical drift versus noncritical drift
AGINDOW separates drift evidence from business-criticality. The detection layer reports path, compatibility and verdict details for the operation; it does not infer that a field is more important than another business field. Declared requiredness, request/response direction, statistical significance and application criticality are independent concerns. compareOperation is an explicit advisory comparison utility for baseline/current JSON declarations or observations; it returns coverage, gaps, requiredness and findings, but it does not feed new findings into guard policy or authorize repair. The application remains responsible for deciding whether a drift is tolerable, blocking or requires a retry or human review.
Handling downstream agent outcomes
AGINDOW describes what happened at the API boundary; it does not confirm that a downstream business workflow succeeded. Different states are not interchangeable: a request may be dispatched, accepted by the vendor, returned with a response, judged by a drift verdict, or followed by a later idempotent reconciliation. Observe mode preserves the original result and upstream exception; repair mode may replace a response or halt a request; strict mode can block execution when configured. An accepted upstream write is still a business action that must be reconciled separately with idempotency keys, receipts and application-level success checks. In other words, AGINDOW is not a general agent success validator.
What to expect
Observe mode preserves original payloads, results and upstream exceptions. Statistical detection requires an explicit selection with comparable baseline/live JSON windows; without it the SDK does not learn or refresh a baseline. An empty recent() history is not a clean verdict. Selective repair stays off by default and needs reviewed rename rules plus independent verification. Python remains callable-only for this platform.
Reference
Use the Node reference for adapter signatures and the matrix for other framework shapes. The public LangChain page summarizes surface limits without replacing this how-to.