Skip to content

tdfs4ds.agentops.package

tdfs4ds.agentops.package

Render, and optionally write, the AgentOps deployment package.

Follows the repo's generate/write idiom (scheduling/script.py, migration/script.py): :func:generate_agentops_package returns the artifact as text so it can be read before anything touches disk; :func:write_agentops_package is the side-effecting variant.

Two things the AgentOps tutorial gets wrong or leaves implicit, handled here:

agent_runtime/ is the platform's, not ours. It arrives by scaffolding a template from demo_agents/ and must be present in the destination before the zip is built — a package without it registers and then fails at pod start. We write alongside an existing scaffold rather than creating one.

The tutorial's own zip step says it excludes __pycache__ and .pyc, but its os.walk applies no filter at all. Ours actually filters — stale bytecode compiled against a different interpreter is a genuinely confusing failure inside a container.

_GENERATED module-attribute

_GENERATED = ('customer_agent.py', 'agent.py', 'requirements.txt', 'config.yaml')

_EXCLUDE_DIRS module-attribute

_EXCLUDE_DIRS = {'__pycache__', '.ipynb_checkpoints', '.git'}

_EXCLUDE_SUFFIXES module-attribute

_EXCLUDE_SUFFIXES = ('.pyc', '.pyo')

_MAX_DOMAINS_LISTED module-attribute

_MAX_DOMAINS_LISTED = 8

_MAX_DESCRIPTION module-attribute

_MAX_DESCRIPTION = 1000

_AGENT_RUNTIME_MODES module-attribute

_AGENT_RUNTIME_MODES = ('auto', 'generate', 'require')

_PLATFORM_RUNTIME_DIRS module-attribute

_PLATFORM_RUNTIME_DIRS = (join('~', 'Demo', 'AgentOps', 'agent_runtime'),)

_GENERATED_MARK module-attribute

_GENERATED_MARK = 'Generated by tdfs4ds'

DEFAULT_DOCKER_IMAGE module-attribute

DEFAULT_DOCKER_IMAGE = 'awsedge01.labsteradata.net:443/tdproduct-docker-stable/avmo/vmo-python-base:3.11.5'

_value_of

_value_of(attr, overrides=None)

Current value of attr: an override first, else module config or env.

Pass-through variables are never module attributes — they are read straight from os.environ by the serve layer and reconnect — so they have to be looked up there or they would silently export as unset.

split_config

split_config(*, backend=None, auth='service', overrides=None, mcp=False)

Split the running configuration into the AgentOps halves.

Parameters

backend : str, optional Vector store backend to classify against. Defaults to the running tdfs4ds.VECTOR_STORE_BACKEND. overrides : dict, optional Values that win over the session, keyed by bare attribute name — see :func:store_overrides. Used to state the deployment's feature store explicitly instead of inheriting whatever the session happened to have.

Returns

dict {"config": {ENV_NAME: value}, "runtime": {ENV_NAME: value}, "dropped": [ENV_NAME], "missing_runtime": [ENV_NAME]} where every key is the full TDFS4DS_-prefixed environment variable name.

``missing_runtime`` names the **required** runtime variables that are
not set in this session — the deployment must supply them, and the
caller surfaces them rather than letting the pod discover it. An unset
*optional* runtime variable is simply absent, not a finding.

store_overrides

store_overrides(database=None, database_view=None, databases_readonly=None, data_domain=None)

Build the :data:STORE_ATTRS override mapping from explicit arguments.

Only arguments actually given appear, so a caller that names just the database does not blank out the rest.

_render_config_yaml

_render_config_yaml(config_vars, runtime_names, version)

Render config.yaml, listing runtime variables as commented placeholders.

The commented entries matter: without them the file silently omits half the configuration, and whoever reads it later cannot tell what the deployment is expected to supply.

generate_agentops_package

generate_agentops_package(*, mcp_enabled=False, backend=None, auth='service', database=None, database_view=None, databases_readonly=None, data_domain=None, td_host=None)

Render the deployment package.

Model, embedding and Vector Store settings are read from the running session — you have proved those work by asking the agent questions, and reproducing them is the point. The feature store is stated, not inherited: it is a deployment target, and a pod that silently picks up whatever the session had is impossible to review at the call site.

Nothing is written and nothing is sent anywhere.

Parameters

mcp_enabled : bool, default False Baked into the generated agent as the mcp_enabled argument to :func:tdfs4ds.consumer_agent. Off by default; True is Enterprise-edition only and adds per-caller MCP authentication. backend : str, optional Vector store backend to classify against. Defaults to the running tdfs4ds.VECTOR_STORE_BACKEND. auth : {'service', 'jwt'}, default 'service' Credential model for the generated agent. database, database_view, data_domain : str, optional The feature store the deployed agent serves. Each falls back to the running session when omitted; :func:tdfs4ds.deploy_to_agentops requires database so a deployment always names its target. databases_readonly : list of str, optional Additional stores attached read-only (cross-store federation). td_host : str, optional The database host the POD connects to, when it differs from the session's TDFS4DS_TD_HOST (a pod that cannot resolve the name gets its address). Only runtime_config changes; the session is untouched.

Returns

dict {"files": {name: text}, "runtime_config": {...}, "dropped": [...], "missing_runtime": [...], "version": str, "auth": str, "store": {...}}.

``runtime_config`` goes in the deployment payload, **not** on disk.
``store`` reports the resolved feature store, so "which database will
this read?" is answerable before anything is deployed.

resolved_store

resolved_store(overrides=None)

The feature store the generated package will serve.

Reported by the preflight and by dry_run so the answer to "which database will the pod read?" is visible before anything is deployed rather than inferred from a failure afterwards.

default_agent_name

default_agent_name(store)

tdfs4ds-agent-<database>-<8 hex>, lower case, [a-z0-9-] only.

The database is the part a reader of the registry needs; the suffix keeps two deployments of the same store apart. A name with no usable database falls back to the historical tdfs4ds-consumer-agent-<uuid>.

agent_description

agent_description(store, *, auth='service', mcp=False, version=None, data_domains=None)

The registry description of an agent serving store (pure, ASCII).

States what does not change after the deploy: the feature store (and its view database and read-only stores), its data domains, what the agent answers, the MCP and logon choices and the tdfs4ds version. No counts: the store keeps growing after the deploy, and a count would go stale.

write_agentops_package

write_agentops_package(dest=None, *, mcp_enabled=False, backend=None, auth='service', database=None, database_view=None, databases_readonly=None, data_domain=None, agent_runtime='auto', make_zip=True, td_host=None)

Write the package into dest and (by default) build the deployable zip.

Parameters

dest : str, optional The scaffolded agent directory — the one holding agent_runtime/. Defaults to {tdfs4ds.AGENTOPS_PACKAGE_DIR}. Created when absent, with a warning: a package with no agent_runtime/ registers fine and then fails at pod start, so the gap is worth naming early. make_zip : bool, default True Also build <dest>.zip next to the directory — the artifact uploaded to POST /agent_definitions.

Returns

dict The :func:generate_agentops_package result plus "dest", "zip_path" and "written" (the file names written).

_ensure_agent_runtime

_ensure_agent_runtime(dest, version, mode='auto')

Make sure dest/agent_runtime exists, and report where it came from.

A platform-supplied copy always wins. Its host may depend on details beyond the two public symbols, and only the platform's own file can be authoritative about that - so 'auto' never overwrites one.

Returns {"source": 'platform'|'generated'|'missing', "path": str}.

_platform_runtime_dir

_platform_runtime_dir()

The first platform agent_runtime found on this machine, or None.

_is_generated_runtime

_is_generated_runtime(path)

True when path holds the agent_runtime tdfs4ds writes itself.

_dir_fingerprint

_dir_fingerprint(path)

Stable hash of a directory's .py contents, for provenance.

_build_zip

_build_zip(agent_dir, zip_path=None)

Zip agent_dir the way AgentOps expects: paths relative to the dir.

_logger

_logger()

deployment_payload

deployment_payload(agent_definition_id, runtime_config, *, deployment_name=None, environment='dev', docker_image=None)

Build the POST /agents payload with the constraints already applied.

The result is sent to the API verbatim, so it carries only fields the API defines — no generation timestamp or other bookkeeping that a strict endpoint would reject.

The tutorial's payload is sized for a toy agent. Three fields differ here, and each is load-bearing rather than a preference:

resources 512Mi does not hold teradataml + langchain + pandas + networkx.

replicas: 1 Conversation memory is an in-process MemorySaver; a second replica answers with no history.

enable_memory: False The platform's PostgreSQL checkpointer cannot be injected into the tdfs4ds graph, so enabling it would provision a database nothing reads.