Skip to content

tdfs4ds.agentops.agents

tdfs4ds.agentops.agents

Find a deployed agent in AgentOps by id, short id or name, and read its endpoint.

The Playground shows an agent as 85f752e - <name> - Version 1. Any of those forms names it here: the full UUID, a prefix of it (6+ characters), or the deployment name. A name reused by a terminated deployment resolves to the live one; a reference matching several live deployments is refused with the candidates listed, never guessed.

GONE module-attribute

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

_UUID module-attribute

_UUID = compile('^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$')

_PREFIX module-attribute

_PREFIX = compile('^[0-9a-f-]{6,36}$')

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.

_names

_names(dep)

is_gone

is_gone(dep)

describe

describe(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.

find_agent

find_agent(agent, *, token=None, base_url=None, client=None)

The one deployment agent names, as returned by GET /agents.

Raises LookupError when nothing or several deployments match.

agent_endpoint

agent_endpoint(agent, *, invoke=False, token=None, base_url=None, client=None)

The URL of a deployed agent, found by name, id or short id.

Parameters

agent : str Deployment name (e.g. 'tdfs4ds-propensity-demo'), UUID, or the short id the Playground shows. invoke : bool, default False False: the agent's base URL, what deploy_to_agentops reports as agent_url and check_deployed_agent takes. True: the /invoke route a client POSTs a question to. token, base_url As for :class:AgentOpsClient (in an AI Studio notebook, %gen_token).

Raises

LookupError No deployment, several, or the deployment is not active (no URL to call).