Skip to content

tdfs4ds.agentops.smoke

tdfs4ds.agentops.smoke

Post-deployment smoke test against a live agent URL.

Closes the arc: preflight -> generate -> write -> deploy -> smoke test. Runs from the notebook, which holds the JWT and can reach the APISIX gateway; it does not run inside the pod.

Two of its six checks are the reason this is worth writing rather than curling the endpoint once:

grounded A generic smoke test cannot distinguish "the LLM replied" from "the agent replied from the feature store". A pod whose Teradata connection failed still answers — fluently, and about nothing. This check asserts a real catalog name appears in the response, reusing :func:~tdfs4ds.agent.consumer_agent._known_catalog_names, which only tdfs4ds is in a position to know.

session_isolation If the thread id ever degrades to a constant, every caller lands in one shared conversation and answers leak between users. That reads as a working memory feature from the outside, and a "does it respond?" test passes it happily. Here a fresh session must show no trace of the previous one.

The pair also localises a fault: session_memory failing while session_isolation passes means session_id never reached the graph; both failing means the thread id is constant.

Contracts, matching the other two reports and tested: never raises, never prints a secret (the token is used, never echoed), and each check is wrapped so one failure neither aborts the run nor hides what follows.

FAILED module-attribute

FAILED = 'failed'

OK module-attribute

OK = 'ok'

SKIPPED module-attribute

SKIPPED = 'skipped'

_TITLE module-attribute

_TITLE = 'tdfs4ds AgentOps deployed-agent test'

_Q_OPEN module-attribute

_Q_OPEN = 'What features are available?'

_Q_FOLLOW_UP module-attribute

_Q_FOLLOW_UP = 'Tell me more about the first one.'

_TIMEOUT module-attribute

_TIMEOUT = 180

_NOT_ROUTED_YET module-attribute

_NOT_ROUTED_YET = frozenset({404, 502, 503, 504})

_ROUTING_ATTEMPTS module-attribute

_ROUTING_ATTEMPTS = 6

_ROUTING_POLL module-attribute

_ROUTING_POLL = 5

_SMOKE_CHECKS module-attribute

_SMOKE_CHECKS = (_check_reachable, _check_answers, _check_grounded, _check_session_memory, _check_session_isolation, _check_latency)

_result

_result(name, label, status, detail='', hint=None, error=None, elapsed_s=None)

_short

_short(text, limit=_MAX_ECHO)

First line of text, truncated — errors are often multi-page.

Exceptions are flattened first, so a task-group wrapper never hides the cause from the caller or from :func:_match_hint.

run_checks

run_checks(checks, *, title, live=True, display=True, context=None)

Run checks and assemble the report.

Parameters

checks : sequence of callable Each takes (live, context) and returns a :func:_result dict. context : dict, optional Passed to every check — the shared state a report needs (an agent URL, a token, an accumulating latency record).

Returns

dict {"ok", "version", "live", "checks"}. ok is True when nothing failed; a skipped check does not fail the run.

_invoke

_invoke(context, message, session_id)

POST one turn. Returns (status_code, output_text, elapsed_ms).

_stringify

_stringify(output)

Flatten a structured output payload to searchable text.

_check_reachable

_check_reachable(live, context)

The gateway routes to a running pod.

_check_answers

_check_answers(live, context)

The entrypoint ran end to end and produced something.

_check_grounded

_check_grounded(live, context)

The answer came from the feature store, not just the model.

_check_session_memory

_check_session_memory(live, context)

A second turn on the same session resolves a back-reference.

_check_session_isolation

_check_session_isolation(live, context)

A different session does NOT inherit the first conversation.

_check_latency

_check_latency(live, context)

Report the cold and warm call times.

check_deployed_agent

check_deployed_agent(agent_url, *, token=None, live=True, display=True)

Exercise a deployed AgentOps agent and report what works.

Sends three turns: an opening question, a follow-up on the same session_id, and the same follow-up on a fresh one. Between them they establish that the pod is reachable, answers, answers from the feature store, remembers within a session and does not leak across sessions.

Parameters

agent_url : str The agent_url from GET /agents/{agent_id}. A trailing /invoke is added when absent. token : str, optional JWT bearer token. Defaults to TDFS4DS_TD_PASSWORD-independent environment lookup of TDFS4DS_AGENTOPS_TOKEN; in AI Studio pass the notebook's user_token. live : bool, default True `False makes no HTTP call — every check reports as skipped. For wiring tests. display : bool, default True Print the aligned summary.

Returns

dict {"ok", "version", "live", "checks": [...]}, the same shape as :func:tdfs4ds.check_configuration.

Notes

Never raises, and never prints the token.

Examples

tdfs4ds.check_deployed_agent(agent_url, token=user_token) # doctest: +SKIP