Agents
Knowledge-grounded assistants with deterministic rules and HTTP tools.
An agent grounds answers on attached Knowledge bases, applies deterministic rules, and can call HTTP tools via a function-calling loop.
Create and attach knowledge
import { createAgentClient } from "@libra-memory/sdk";
const agents = createAgentClient({ apiKey: process.env.LIBRA_API_KEY });
await agents.createAgent({
name: "support",
instructions: "Answer from knowledge; use tools for orders.",
knowledge: ["support-docs"],
});
const agent = agents.agent("support");Rules
Rules are evaluated deterministically around the LLM:
escalation— a keyword match short-circuits the LLM and returns the fallback message.forbidden/required— injected as prompt constraints.
await agent.addRule({ type: "escalation", condition: "chargeback,dispute" });Tools
Register an HTTP endpoint the agent may call. The model fills the parameters; the result is fed back into the answer.
await agent.addTool({
name: "lookup_order",
description: "Look up an order by id.",
http: { url: "https://api.example.com/orders", method: "POST" },
parameters: { type: "object", properties: { order_id: { type: "string" } }, required: ["order_id"] },
});Chat
const res = await agent.chat([{ role: "user", content: "Status of order A123?" }]);
console.log(res.message.content);
console.log(res.escalated, res.trace.tool_calls); // rule + tool trace