tdfs4ds.agentops.remove¶
tdfs4ds.agentops.remove
¶
Remove a deployed agent from AgentOps: its deployment, then its definition.
The Playground shows an agent as 85f752e - <name> - Version 1: a short id,
the deployment name, a version. :func:remove_agent accepts any of those forms
(full UUID, a prefix of it, or the name), finds the deployment with
GET /agents, deletes it, waits until the platform reports it gone, and then
deletes the registered definition unless another live deployment still uses it.
Nothing is guessed: a reference matching several deployments is refused with the
candidates listed, and dry_run=True shows what would be removed.
AgentOpsClient
¶
Minimal client for the endpoints a deployment needs.
Parameters¶
base_url : str, optional
Defaults to TD_AGENTOPS_BASE_URL, then the in-cluster service URL.
token : str, optional
JWT bearer token. Defaults to TDFS4DS_AGENTOPS_TOKEN. In an AI
Studio notebook this is the user_token produced by %gen_token.
base_url
instance-attribute
¶
register_definition
¶
Upload the zip and register an agent definition. Returns its id.
wait_definition_published
¶
Poll until the definition leaves creating. Returns its status.
create_deployment
¶
POST the deployment payload. Returns the full response body.
The payload is sent verbatim; see the module docstring on
extra_forbidden.
wait_deployment_active
¶
Poll the deployment until it settles. Returns the last body.
Emits current_step transitions rather than every poll, so a long
build reads as building -> pushing -> deploying instead of forty
identical lines.
delete_agent
¶
DELETE /agents/{id}: removes the deployment (pod, route, service).
delete_definition
¶
DELETE /agent_definitions/{id}: removes the registry entry.
list_definitions
¶
Agent definitions of the workspace (GET /agent_definitions), all pages.
name is a substring filter on the platform side: callers compare exactly. Archived definitions are included by default because they keep their name.
update_definition
¶
PATCH /agent_definitions/{id}: name, description, tags, status...
On an archived definition a new name frees the old one (there is no
hard delete).
get_logs
¶
Pod logs. Never raises — a missing log must not mask the real error.
AgentOpsError
¶
Bases: RuntimeError
An AgentOps API call failed. Carries the response body, which is where the useful detail lives — a 422 names the offending field.
resolve_agent
¶
The deployments of agents that agent names (pure).
Order: exact UUID, UUID prefix (6+ hex characters, the Playground's short id), then the deployment / definition / Kubernetes name, live deployments first. One item when the reference is unambiguous.
_wait_gone
¶
Poll the deployment until it is gone or terminated. Returns the last status.
_release_name
¶
An archived definition keeps its name (a new deployment of it is a 409);
the API has no hard delete, so rename it. Sets name_free in the report.
remove_agent
¶
remove_agent(agent, *, delete_definition=True, dry_run=False, others=False, token=None, base_url=None, timeout=300, progress=None, client=None)
Remove a deployed agent from AgentOps.
Parameters¶
agent : str
The deployment's UUID, a prefix of it (the short id the Playground shows,
e.g. '85f752e'), or its deployment name.
delete_definition : bool, default True
Also delete the registered agent definition, unless another deployment
that is not terminated still uses it (then it is kept and the report says
which). The platform only archives a definition and an archived one keeps
its name, so the definition is also renamed <name>-archived-<id8>;
name_free in the report says whether the name can be deployed again.
dry_run : bool, default False
Resolve and report what would be removed; send nothing.
others : bool, default False
GET /agents lists the whole workspace, so a name can belong to another
user's agent. By default a deployment whose created_by is not the
token's user is refused; True removes it anyway (if the platform allows).
token, base_url
As for :class:AgentOpsClient (in an AI Studio notebook, the token from
%gen_token).
timeout : int, default 300
Seconds to wait for the platform to report the deployment gone.
progress : callable, optional
Called with a status line per step.
Returns¶
dict
{"ok", "dry_run", "agent_id", "name", "definition_id", "status_before",
"status_after", "definition", "name_free", "steps", "error"}
(name_free: True, False, or None when not asked / not verified). Never raises for an
API refusal: the full response is in error and logged at ERROR.