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
| Parameter | Type | Default | Description |
|---|---|---|---|
model | str | — | Required. |
system_prompt | str | — | Required. Defines the agent's role and behavior. |
name, description | str | — | Metadata (description also feeds squad routing). |
tools | list[str] | — | Built-in tools — see Built-in Tools. |
examples | list[dict] | — | Few-shot pairs with user / assistant keys. |
input_schema, response_schema | dict | — | JSON Schema for structured input / output. |
privacy_enabled | bool | False | Mask PII before it reaches the model. |
topics | list[str] | — | Squad routing keywords. See Multi-agent routing. |
can_handoff_to | list[str] | — | Squad chain mode: agents this one hands off to. |
priority | int | 0 | Squad routing head start, 0 to 100. |
output_key | str | — | Squad workflow mode: label for this step's output. |
api_key, base_url | str | env | See Authentication. |
timeout | float | 120.0 | Seconds. |
max_retries | int | 2 | Retries on network / 5xx errors. |
Methods
| Method | Purpose |
|---|---|
.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):
| Method | Purpose |
|---|---|
.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")