Skip to main content

Custodian Agent Class

Custodian configures one agent, then .deploy() returns a chat-ready DeployedApp. Since the unified deployment model, a single Custodian is deployed as a 1-member CustodianSquad (routing_mode="single").

from custodian_labs import Custodian

custodian = Custodian(
model="gpt-6-luna",
system_prompt="You are a helpful customer support assistant.",
privacy_enabled=True,
)
app = custodian.deploy()
reply = app.chat("How do I invite a teammate?")
print(reply.response)

Constructor​

ParameterTypeDefaultDescription
modelstr—Required.
system_promptstr—Required. Defines the agent's role and behavior.
name, descriptionstr—Metadata (description also feeds squad routing).
toolslist[str]—Built-in tools — see Built-in Tools.
exampleslist[dict]—Few-shot pairs with user / assistant keys.
input_schema, response_schemadict—JSON Schema for structured input / output.
privacy_enabledboolFalseMask PII before it reaches the model.
topicslist[str]—Squad routing keywords. See Multi-agent routing.
can_handoff_tolist[str]—Squad chain mode: agents this one hands off to.
priorityint0Squad routing head start, 0 to 100.
output_keystr—Squad workflow mode: label for this step's output.
api_key, base_urlstrenvSee Authentication.
timeoutfloat120.0Seconds.
max_retriesint2Retries on network / 5xx errors.

Methods​

MethodPurpose
.add_examples(examples)Add few-shot pairs.
.add_data_source_file(path)Attach a knowledge file — see Data Sources & RAG.
.deploy(name=, share_mode=, share_password=)Deploy → DeployedApp (attach later by id with CustodianClient.deployed).
.chat(message)Deploy and send one message.

Structured output​

response_schema makes the agent return JSON; the reply carries a structured_output field.

custodian = Custodian(
model="gpt-6-luna",
system_prompt="Assess the risk and reply as JSON.",
response_schema={
"type": "object",
"properties": {"verdict": {"type": "string"}, "confidence": {"type": "number"}},
"required": ["verdict", "confidence"],
},
)
reply = custodian.deploy().chat("Assess the risk for ACME Corp (low).")
print(reply.structured_output) # {"verdict": "low", "confidence": 0.95}

External connections​

Slack (list channels, read, post and reply in threads):

MethodPurpose
.with_slack_credential(bot_token=None, default_channel_id=None)Attach a Slack bot token (xoxb-…). Without arguments, reads CUSTODIAN_SLACK_BOT_TOKEN / CUSTODIAN_SLACK_DEFAULT_CHANNEL from the environment or .env. Sent and checked with Slack on .deploy().
.with_slack_tools()Add slack_list_channels, slack_read, slack_send, slack_reply to tools.
agent = Custodian(model="gpt-6-luna", system_prompt="Summarize Slack channels clearly.")
agent.with_slack_credential().with_slack_tools()
app = agent.deploy(share_mode="private")

See Connect Slack for creating the Slack app.

Gmail (read / send / reply from an agent) is coming soon.

Sharing​

Set at deploy time, not on the object:

custodian.deploy() # public (default)
custodian.deploy(share_mode="private")
custodian.deploy(share_mode="password", share_password="s3cret")

Next​

Builder API · Data Sources & RAG · Chat Sessions