Skip to content

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.

_GONE module-attribute

_GONE = ('terminated', 'deleted', 'removed')

logger module-attribute

logger = getLogger('tdfs4ds.agentops')

_POLL module-attribute

_POLL = 5

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

base_url = rstrip('/')

timeout instance-attribute

timeout = timeout

__init__

__init__(base_url=None, token=None, timeout=60)

register_definition

register_definition(zip_path, name, description='', framework='LangGraph', tags=None)

Upload the zip and register an agent definition. Returns its id.

get_definition

get_definition(definition_id)

wait_definition_published

wait_definition_published(definition_id, timeout=600, interval=10, progress=None)

Poll until the definition leaves creating. Returns its status.

create_deployment

create_deployment(payload)

POST the deployment payload. Returns the full response body.

The payload is sent verbatim; see the module docstring on extra_forbidden.

get_agent

get_agent(agent_id)

wait_deployment_active

wait_deployment_active(agent_id, timeout=1800, interval=15, progress=None)

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.

list_agents

list_agents()

Every deployment the caller can see (GET /agents), as a list.

stop_agent

stop_agent(agent_id)

POST /agents/{id}/stop. Returns the response body (may be empty).

delete_agent

delete_agent(agent_id)

DELETE /agents/{id}: removes the deployment (pod, route, service).

delete_definition

delete_definition(definition_id)

DELETE /agent_definitions/{id}: removes the registry entry.

get_logs

get_logs(agent_id, tail_lines=200)

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.

_describe

_describe(dep)

_is_gone

_is_gone(dep)

resolve_agent

resolve_agent(agents, 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.

_short

_short(exc, limit=300)

_emit

_emit(progress, message, level='info')

_wait_gone

_wait_gone(client, agent_id, timeout)

Poll the deployment until it is gone or terminated. Returns the last status.

_caller

_caller(token)

The user a token was issued to (its Teradata username claim), or None.

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). 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", "steps", "error"}. Never raises for an API refusal: the full response is in error and logged at ERROR.