integrable-firewall
v0.1.3
Published
Connect an AI agent built in code (Vercel AI SDK, LangChain, OpenAI Agents SDK) to its Integrable firewall: every user message, tool call and tool result is screened, and nothing passes when the firewall cannot be reached.
Maintainers
Readme
integrable-firewall
Connect an AI agent you build in code to its Integrable firewall. The firewall screens every message from the agent's user before the model reads it, every tool call before it runs, and every tool result before the model reads it. A stopped step is never a wait: the model is told why, in place of the step, and tells its user.
The full guide is on your firewall at /docs/agents.html (for example
https://<your-firewall>.cloudfront.net/docs/agents.html).
Sources for each adapter, read 2026-11-09 through fetched summaries and checked against the installed packages: AI SDK middleware, tools, agents, 7.0 migration; LangChain custom middleware, guardrails, runtime; OpenAI Agents guardrails, running agents.
Install
npm install integrable-firewallNode 18 or later, no dependencies of its own. Each adapter uses the framework
you already have: ai 5 to 7, langchain 1.3 or later, @openai/agents 0.4
or later.
Settings
| Setting | Read from, first found wins |
|---|---|
| Address | the url option, then FIREWALL_URL |
| Key | the key option, then FIREWALL_KEY_<AGENT> (support-widget reads FIREWALL_KEY_SUPPORT_WIDGET), then FIREWALL_KEY |
| What it is for, what it may do | the goals and permissions options, in plain words |
Your firewall's setup prompt has your coding agent write both into the code,
as the url and key options. That key is made to be committed, like an
error tracker's DSN: it only lets that one agent send its own steps to your
firewall and read the answers, and it belongs to the first agent name it is
used with. To keep a key out of the code, leave the options out and put the
two settings where the agent runs. A key belongs to one agent name
(fwa_<64 hex>_<agent name>): a key for another name throws when the adapter
is created. The key is never logged and never sent anywhere but the
Authorization header to your firewall. One adapter protects one agent.
goals and permissions say what the agent is for and what it may do, the
way you would on its page in your dashboard. The setup prompt has your coding
agent write them from the agent's own instructions and tools, for example:
const fw = firewall({
agent: "support-widget",
goals: "Answers our customers' questions about their orders and their account.",
permissions: "May look up customers and their orders and hand a conversation to our team. Leave refunds, email address changes and account deletions to our team. Never reveal one customer's details to another.",
});They become the agent's rules the first time its key connects, unless someone has already set them on the dashboard, and the dashboard is where to change them after that: the firewall does not take them again from a later deploy. A sentence beginning "Leave" names what is left to a person (that step is stopped, and the model is told a person has to do it); one beginning "Never" is something it must not do.
Vercel AI SDK
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { firewall, FirewallBlockedError } from "integrable-firewall/ai-sdk";
const fw = firewall({ agent: "support-widget" });
try {
const { text } = await generateText({
model: fw.model(openai("gpt-5")),
tools: fw.tools(tools),
messages,
providerOptions: { firewall: { sessionId: chatId } }, // optional: your conversation id
});
} catch (error) {
if (!(error instanceof FirewallBlockedError)) throw error;
// The message never reached the model: answer your user (error.reason says why).
}streamText and new ToolLoopAgent({ model: fw.model(...), tools: fw.tools(...) })
work the same; with streamText a blocked message arrives through onError.
The newest user message is screened once per run. A stopped tool call does not
run: the model reads the firewall's reason as the tool's error and the run goes
on. A cleaned result replaces the original. Tools without execute (run in the
browser) and tools the provider runs are not screened, and only the newest
message is: keep the conversation history on your server rather than trusting
the one the browser sends.
LangChain
import { createAgent } from "langchain";
import { firewallMiddleware, firewallRefusal } from "integrable-firewall/langchain";
const agent = createAgent({
model,
tools,
middleware: [firewallMiddleware({ agent: "support-widget" })], // first in the list
checkpointer,
});
const result = await agent.invoke(
{ messages: [{ role: "user", content: text }] },
{ configurable: { thread_id: chatId } },
);
const refusal = firewallRefusal(result.messages.at(-1)); // { reason } when the message was blockedA blocked message ends the run with an AIMessage whose content is the reason,
and its own text is replaced in the thread, so it never reaches the model on a
later turn either. A stopped tool call returns an error ToolMessage with the
reason, without running. Put the middleware first so it wraps every other one.
LangChain makes a tool's own exception end the run once any wrapToolCall
middleware is present; on langchain 1.6 or later, add
toolErrorMiddleware({ onError }) after the firewall to hand the error to the
model instead (the firewall screens that text too).
OpenAI Agents SDK
import { Agent, Runner, InputGuardrailTripwireTriggered } from "@openai/agents";
import { firewall } from "integrable-firewall/openai-agents";
const fw = firewall({ agent: "support-widget" });
const agent = new Agent({
name: "Support",
instructions: "Help customers with their orders.",
tools: fw.tools([lookupOrder, issueRefund]),
inputGuardrails: [fw.inputGuardrail],
});
try {
const result = await new Runner({ groupId: chatId }).run(agent, text);
} catch (error) {
if (!(error instanceof InputGuardrailTripwireTriggered)) throw error;
// The message never reached the model: error.result.output.outputInfo.reason says why.
}The input guardrail blocks the run until it decides, so a blocked message never
reaches the model. A stopped tool call is skipped and the model reads the
reason in place of its result (rejectContent); the run goes on. For your own
tool({...}) or an MCP server, attach fw.toolInputGuardrail and
fw.toolOutputGuardrail yourself (toolInputGuardrails,
toolOutputGuardrails on the server). Hosted tools are not screened. One
adapter protects one SDK agent (by its name): give a handoff target its own
firewall agent. A tool with an outputSchema needs an errorFunction for a
stopped call to reach the model; a cleaned or withheld result of such a tool
ends the run.
When the firewall cannot be reached
Nothing passes on the strength of a silence. With no address, a network error, no answer within 9.5 seconds, a refused key or any other error, the message is blocked ("Firewall: the firewall could not be reached, so this message was not processed."), the tool does not run ("... so this step did not run.") and a result is withheld ("... so this result was withheld."). Your agent stops when its firewall does; there is no switch to fail open. The adapter logs a warning saying why (never with the key).
Your own integration
import { firewall } from "integrable-firewall";
const fw = firewall({ agent: "support-widget" });
const verdict = await fw.screenToolCall({ toolName: "issue_refund", input: { amount: 30 }, sessionId });
// { action: "pass" } | { action: "block", reason } ; screenToolResult can also return { action: "replace", value }