Deployed Apps — one handle, attach by ID
Since the unified deployment model, every deployment is a DeployedApp — whether
you deployed a single Custodian or a CustodianSquad. A single Custodian is simply
a 1-member squad (routing_mode="single"). There is one concept, one ID space, one
kind of handle.
from custodian_labs import Custodian
# deploy() returns a DeployedApp — for a single Custodian this is a 1-member squad.
app = Custodian(
model="gpt-6-luna",
system_prompt="You are a helpful support assistant.",
name="SupportCustodian",
).deploy()
print(app.id) # e.g. "custodians_4f2a91c3e5b7"
print(app.chat_url) # shareable chat link
Attach to an existing deployment (no re-deploy)
deploy() is meant to run once — a setup script, a CI job, or the Dashboard. For
code that runs many times (servers, webhooks, bots), attach to an already-deployed
Custodian or squad by ID:
from custodian_labs import CustodianClient
client = CustodianClient()
# Works for BOTH a single Custodian and a squad — same unified handle.
app = client.deployed("custodians_4f2a91c3e5b7")
reply = app.chat("What's the status of my refund?")
print(reply.response)
Constructing the handle is pure: no network call, no credits, and deploy() is
never triggered. The backend route (/apps/* vs /team-apps/*) is resolved
automatically on the first chat() and cached, so a follow-up is a single request.
Kind hints (optional)
If you already know the type, pass kind to skip resolution:
client.deployed("custodians_4f2a91c3e5b7", kind="squad") # squad-backed
client.deployed("custodian_4f2a91c3e5b7", kind="app") # legacy single app
client.app("custodian_4f2a91c3e5b7") # explicit app kind
client.squad_app("custodians_4f2a91c3e5b7") # explicit squad kind
Backward compatibility
App and CustodianSquadApp remain as deprecated aliases of DeployedApp for one
release. Existing scripts that read .app_id, .squad_app_id, .share_link,
.session_id, or call .chat() / .reset_session() keep working unchanged.
Session continuity
The handle retains the server session_id and re-sends it on the next chat(), so
multi-turn context works automatically — also when re-attaching by ID:
app = client.deployed("custodians_4f2a91c3e5b7")
app.chat("Remember: my favorite color is teal.")
app.chat("What is my favorite color?") # the agent remembers