Skip to main content

Custodian Agent Class

The Custodian class configures and deploys a single Custodian Agent. Use it when you want to add examples, attach knowledge files, set tools, or reuse a configuration before deploying.

Create and deploy​

import { Custodian } from "@custodianlabs/sdk";

const custodian = new Custodian({
model: "gpt-6-luna",
systemPrompt: "You are a helpful support assistant.",
privacyEnabled: true,
});

const app = await custodian.deploy();
const reply = await app.chat("How do I reset my password?");
console.log(reply?.response);

Constructor options​

OptionTypeNotes
modelstringRequired.
systemPromptstringRequired.
privacyEnabledbooleanDefault false. Masks PII in messages before the LLM sees them. See Guardian Layer.
namestringMetadata for the assistant.
descriptionstringMetadata for the assistant.
toolsstring[]Built-in tools: "web_search", "scrape_url", "parse_document". See Built-in Tools.
inputSchemaobjectJSON Schema constraining structured input.
responseSchemaobjectJSON Schema constraining structured output.
apiKeystringOverrides CUSTODIAN_SDK_API_KEY.
baseUrlstringOverrides CUSTODIAN_SDK_BASE_URL.
timeoutnumberRequest timeout in seconds. Default 30.
maxRetriesnumberRetries on network / 5xx errors. Default 2.

Configuration is local until deploy()​

addExamples() and addDataSourceFile() only stage data on the object. Every network call happens inside .deploy() — assistant creation, example upload, file upload, and deployment, in that order.

const custodian = new Custodian({ model: "gpt-6-luna", systemPrompt: "Answer from the docs." })
.addExamples([{ user: "Who are you?", assistant: "I am your assistant." }])
.addDataSourceFile("./docs/manual.pdf");

// No requests have been made yet.
const app = await custodian.deploy(); // all requests happen here

Methods​

MethodPurpose
addExamples(pairs)Stage few-shot examples. Each pair needs non-empty user and assistant. Returns this.
addDataSourceFile(file)Stage a RAG file (path or in-memory bytes). Returns this.
deploy(options?)Create, configure, and deploy. Returns App.
chat(message?, options?)Deploy, then send one message (or start interactive chat).
withSlackCredential(options?)Stage a Slack bot token: { botToken?, defaultChannelId? }. Falls back to CUSTODIAN_SLACK_BOT_TOKEN / CUSTODIAN_SLACK_DEFAULT_CHANNEL in Node. Sent during deploy(). Returns this.
withSlackTools()Add slack_list_channels, slack_read, slack_send, slack_reply to tools. Returns this.

Slack​

const agent = new Custodian({ model: "gpt-6-luna", systemPrompt: "Summarize Slack channels clearly." })
.withSlackCredential({ botToken: process.env.SLACK_BOT_TOKEN })
.withSlackTools();

const app = await agent.deploy({ shareMode: "private" });

Agent (squad member) has the same two methods; only the agent that calls them gets Slack. See Connect Slack for creating the Slack app.

Deploy options​

await custodian.deploy({
name: "billing-bot", // display name for the deployment
shareMode: "password", // "public" (default) | "private" | "password"
sharePassword: "let-me-in", // required when shareMode is "password"
});

Structured input and output​

const custodian = new Custodian({
model: "gpt-6-luna",
systemPrompt: "Classify the support ticket.",
responseSchema: {
type: "object",
properties: { category: { type: "string" }, urgency: { type: "string" } },
required: ["category", "urgency"],
},
});

Next steps​