Skip to content

tdfs4ds.agentops.client

tdfs4ds.agentops.client

Thin REST client for the AgentOps Core API.

Deliberately no orchestration: one method per endpoint, so the pipeline in :mod:tdfs4ds.agentops.deploy can be tested against a stub without a cluster.

Three details cost a real deployment cycle each to discover, and are encoded here rather than left to the caller:

  • the multipart upload must not set Content-Type — requests derives the boundary, and supplying the header without one produces a request the API cannot parse;
  • the payload is rejected outright for any field the schema does not define (422 extra_forbidden), so nothing decorative may be added to it;
  • deployment progress is reported as status + current_step + steps_remaining, which is what to poll — a fixed sleep either returns before the pod is up or wastes minutes after it is.

The token is used and never logged, echoed, or returned.

logger module-attribute

logger = getLogger('tdfs4ds.agentops')

_DEFAULT_BASE_URL module-attribute

_DEFAULT_BASE_URL = 'http://agentops-core.agentops.svc.cluster.local:8080/agentops-core/api/v1'

_DEFINITION_TERMINAL module-attribute

_DEFINITION_TERMINAL = ('published', 'failed')

_DEPLOYMENT_TERMINAL module-attribute

_DEPLOYMENT_TERMINAL = ('active', 'failed', 'error')

_UUID_RE module-attribute

_UUID_RE = compile('^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$')

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.

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.

get_logs

get_logs(agent_id, tail_lines=200)

Pod logs. Never raises — a missing log must not mask the real error.

_body

_body(response)

Response body, trimmed. A 422 names the offending field here.

_short

_short(exc, limit=300)

_emit

_emit(progress, message)

Report a step. Mirrors migration/executor.py's _emit.