LangChain, OpenAI function calling, AutoGen: wrapping tools
Frameworks that register tools as an object are protected by a single wrapper: guard() wraps one tool, guardAll() a whole registry. The mandate is checked before every call; if Mandact is unreachable, nothing is executed.
One line instead of every registration
guardAll(tools, mappings, cfg) assigns an action type to each tool (such as purchase.goods or data.share) and returns the protected registry — the caller changes one line.
Unprotected is reported, not hidden
Tools without a mapping stay unprotected and are reported explicitly. Letting them through silently would be more dangerous: the developer would believe everything is checked.
Fail-closed
If the service does not answer or answers unreadably, the wrapper throws MandactUnreachable — the action does not happen. An agent that acts anyway when the line is silent would be no control at all.
const { tools: guarded, ungeschuetzt } = guardAll(
tools,
{ order: { type: "purchase.goods" }, share: { type: "data.share" } },
cfg
);
// ungeschuetzt → ["search"] (reported on purpose)Status
Wrapper in the repository (lib/verify/agentGuard.ts); framework-independent for tool registries as an object.