Skip to content

Plugin skills

A plugin skill adds an intent to the consumer agent without changing the package. Set TDFS4DS_SKILLS_FOLDER to a folder holding one sub-folder per skill:

<skills folder>/
    compliance/
        SKILL.md      # name, intent, description; the classifier reads them
        skill.py      # defines node(state) -> dict
    _lib/             # code shared by the plugins; not a skill
        __init__.py
        helpers.py

SKILL.md alone makes the skill visible to the classifier, and nothing answers it. A skill declaring an intent with no skill.py, or a skill.py with no node, logs a warning when the agent's graph is built, and the admin app's Skills panel shows it in its routed column.

The app's import takes the SKILL.md only. The app has no access control, so an uploaded skill.py would let anyone reaching its port run code on the server. Copy skill.py to the folder yourself.

What a plugin can call

import tdfs4ds
from _lib.helpers import my_rule            # any plugin can import from _lib


def node(state):
    question = state.get("question") or ""

    # the period the question names, with "today" read from the database clock
    period = tdfs4ds.parse_period(question, "Europe/Paris")

    # a statement on the session's connection, as a frame; BYTE and BLOB columns stay bytes
    rows = tdfs4ds.run_sql("SELECT TOP 5 a, b FROM db.t WHERE c = ?", ["x"])

    # the instruct model, returning JSON through whatever constraint the endpoint honours
    verdict = tdfs4ds.llm_json("You classify requests.", question,
                               schema={"type": "object", "properties": {"label": {"type": "string"}},
                                       "required": ["label"]},
                               expect=dict, default={"label": "unknown"})

    return {"skill_result": {"answer": f"{verdict['label']}: {len(rows)} rows", "docs_sources": []}}
Function Returns Notes
llm_json(system, user, schema=, expect=, default=) The parsed reply A failure logs and returns default. It honours STRUCTURED_OUTPUT_METHOD.
run_sql(sql, params=None) A pandas frame One session, so a volatile table stays visible to the next call. Teradataml only, not MCP. A database error raises. Not for a background thread.
chart_payload(result) A chart for the answer result comes from a plot_* function; put the payload in the skill's charts.
parse_period(question, timezone='UTC', now=None) {"start", "end", "how"} or None Aware datetimes, end excluded. A date with no offset is read in timezone. It raises when the database clock is needed and cannot be read.
deep_table_tag_documentation(database, table) A frame TAG_NAME, DESCRIPTION, UNIT Reads the documentation and DBC, never the table.
resolve_tags(question, catalogue) [{tag, description, unit, score, matched, how}] Pure. A tag the question names wins; otherwise it matches on the descriptions.

Finding a tag by its meaning

deep_table_tags scans the table and returns no description, and matching on names finds nothing when a question names a measurement by its meaning. Read the documentation once, and resolve each question against it:

catalogue = tdfs4ds.deep_table_tag_documentation('DB_SOURCE', 'HISTORIAN')
hits = tdfs4ds.resolve_tags('how hot was the furnace?', catalogue)
if len(hits) > 1 and hits[1]['score'] > 0.8:
    ...                                     # the question does not decide: ask

The match is on words: a word counts more the fewer tags have it, and there is no language model and no database read. A question and a description using different words for one thing do not match, so pass the candidates to llm_json if you need that.

A unit is read from the end of the tag's name (Length (m)) or from unit: m in its description.