Impact-study agent¶
The impact-study agent is an optional reviewer of the impact study.
It is not a chatbot. The study itself is code first: tdfs4ds.impact_of and its feature-level reading
give the complete answer with no language model. The agent reads the findings the code could not decide,
or decided only in part, and goes a little further where the SQL resists a parser (table operators,
TD_* functions, user-defined functions, PIVOT, JSON shredding...). A short narrative comes after
and is secondary. The agent is off by default and never changes a verdict.
Use with expert review
These checks are not exhaustive and can report false positives: have an expert review the findings. They support experts, they do not replace them. A finding is a lead to investigate, not a verdict. The study is read from the SQL and the catalogs: estimates are not measurements, and readers outside the store are not seen. The absence of a finding is not proof that nothing is affected.
Every agent text is an opinion, for expert review: check it against the evidence ledger.
What the study always does¶
Without any model, every study:
- resolves the object (process, dataset, view or table) and reads the catalogs and the lineage graph;
- judges every reader and every feature: verdicts, severities and the chain of features;
- lists the assistant's footprint: the documentation rows, vector-index entries, glossary terms, plugin skills and evaluation scenarios that name the affected features and objects;
- compares the plans of the current and the proposed SELECT, with EXPLAIN only.
The agent never changes any of these results. A verdict is decided by the code.
What the agent adds¶
- A review of the undecided findings (its main job). After the deterministic steps, the reviewer
collects the items the code could not decide: a feature whose computation could not be compared, a
reader whose select list could not be narrowed or that
may_change, a view or probe that could not be read, and any SQL holding constructs the parser cannot follow. For each one (at mostIMPACT_AGENT_MAX_REVIEWS, default 8; breaks and may-change first, then unverified, then constructs) one bounded typed model call gives an opinionlikely_affected,likely_unaffectedorcannot_tell, a confidence (low,medium,high), a reason of at most two sentences, and the exact quote of the SQL that supports it. Code checks the quote: if it is not in the SQL that was given, the opinion becomescannot_tell("evidence not found in the SQL"). The reviewer is told what changed (columns removed or retyped, features whose logic changed, old and new SQL) and sees every output expression of the reader;cannot_tellis alwayslowconfidence. The default small model (mistral-small-latest) is enough for this. The opinion is shown beside the code's finding (a chip in the Features tab, a table first in the Assistant tab, a section in the reports) and marked "agent opinion, for expert review". When it contradicts the code (for instance "likely unaffected" againstbreaks) it is flagged "disagrees with the code", never substituted: severities, verdicts and counts are untouched. The consumer agent is asked about an undecided feature only when its documentation is missing (budgeted byIMPACT_AGENT_MAX_CONSUMER_CALLS). - Where the parser could not follow. Independently of any model, the study lists in
parse_limitsevery SQL text (the proposed SQL, the edited objects, the readers) with constructs the parser cannot follow, so the panel and the reports show a "resists parsing" note and say to have an expert review it. - A planner. With a model, the agent chooses which read-only tools to call next. It runs at most
IMPACT_AGENT_MAX_STEPSsteps (default 6). A step beyond the cap is reported, not run. - Questions to the consumer agent. The
ask_consumertool sends one question about the workflow (documentation, definitions, freshness, lineage in business words). At mostIMPACT_AGENT_MAX_CONSUMER_CALLSquestions are asked per study (default 3). The answer is recorded as evidence ("the consumer agent said"), never as a computed fact. - A short narrative, secondary. One grounded call writes at most six short bullets: what breaks, what
changes values and what the reviews add, nothing else. Every object, feature and column name in a bullet is checked against the study and the
footprint. A bullet that names anything the study does not hold is dropped and listed in
narrative_dropped. The narrative is labelled as written by the assistant, unverified wording. A second check then looks at the claims: a bullet that says an object is empty, has no rows, will fail, breaks, is identical or differs is dropped unless the severity, the consequence or the measure of the object it names backs the claim, and a bullet that attributes an opinion to the consumer agent is dropped when no consumer answer exists (a kept one gets the code severity of the objects it names appended). Each dropped claim is listed with its reason innarrative_dropped. Planner steps without a question, with arguments that do not fit the tool or already done by the deterministic order are skipped, not failed. A ledger entry carriesmodel(the model name, for model entries),ok,skippedand the error or skip reason inerror.
Tools¶
The agent works through a registry of read-only tools. The registry refuses, when the module loads, any tool that is not read-only. Every call is recorded in the ledger.
| Tool | What it does |
|---|---|
resolve_scope |
Reads what the study needs and resolves the edited object (process, dataset, view or table). |
study_change |
Judges every reader and every feature (the impact model plus the feature-level reading). |
feature_readers |
The readers of one feature, with their affected and unaffected features. |
feature_chain |
The chain of features computed from one feature, edge by edge. |
assistant_footprint |
The documentation rows, vector-index entries, glossary terms, plugin skills and evaluation scenarios naming the affected items. |
review_findings |
The reviewer: a bounded model opinion on each finding the code could not decide, shown beside the code's finding. Arguments: item ids (R1, R2...) or none. |
ask_consumer |
One question to the consumer agent. Budgeted; its answer is evidence. |
compare_efficiency |
The EXPLAIN and DYNAMIC EXPLAIN comparison of the two SELECTs. |
check_compile |
Checks that a proposed SELECT compiles (EXPLAIN only). |
The planner cannot start a measured comparison. Only a person can, from the Impact study panel or with
measure=True (see Measure on volatile tables).
The package also ships four short SKILL.md descriptions of the study's parts (is-scope,
is-feature-impact, is-assistant-surface, is-report). They document what each part does; the loop
does not load an external skills folder yet.
Ledger¶
Each tool call, each question to the consumer agent and each call to the agent's own model is recorded:
the tool, its arguments, a short digest of the result (so two studies can be compared without storing
the results twice), its duration, its source (code, consumer or model), whether it succeeded and
the error if not. The Assistant tab of the panel shows the ledger; in code it is
study['agent']['ledger'].
Which model¶
IMPACT_AGENT_MODEL (environment variable TDFS4DS_IMPACT_AGENT_MODEL) names another model of the
same provider, URL, key and region as the instruct model. Left blank, the agent uses
INSTRUCT_MODEL_MODEL. The name is overridden for that one call; no module setting changes.
When no provider or no model name is set, the agent is skipped and skipped_reason says why. The code
study is still returned in full.
Run it¶
from tdfs4ds.impact_agent import run_study
study = run_study('MY_DB.CUSTOMER_FEATURES', new_sql=NEW_SQL, agent=True,
question='Who should review this change first?')
study['agent']['used'] # False when no model is available: the code study is complete anyway
study['agent']['reviews'] # the opinions on the undecided findings (opinion, confidence, reason, evidence)
study['agent']['narrative'] # the short narrative bullets, or None
study['parse_limits'] # SQL the parser cannot follow (code only, no model)
study['agent']['ledger'] # every call: tool, source, model, duration, ok, skipped, error
Other arguments of run_study: as_of, dataset_change, domains, max_depth, consumer_timeout,
and the measured comparison (measure=True, with measure_force; both SELECTs are computed in full,
gated by the EXPLAIN estimate and the process's logged runs). The compare_efficiency tool returns the
logged runs too (logged_runs). The planner,
llm and consumer arguments replace the model parts, for tests and custom integrations.
Relation with the consumer agent¶
The consumer agent answers business questions about the workflow in the chat. The impact-study agent
asks it questions through ask_consumer: on its own conversation thread, with no valid time, for
read-only intents only, with data reads checked by the query guard, and within
its own budget. The study does not write to any chat history.
Limits¶
- A review is an opinion from the SQL that was given, bounded to about 4,000 characters per item. It can be wrong; the quote and the reason are shown so an expert can check them.
- The planner is one bounded loop of tool calls. It is not a general agent, and it cannot apply a change, run a process or start a measurement.
- No verdict and no severity comes from a model. A narrative bullet cannot add an object or a feature.
- The narrative is wording. Check it against the evidence in the study, which the report shows in full.
- What the study cannot see is listed in Study the impact of a change, and it applies to the agent too: DBQL readers and readers outside the feature store.
Settings¶
| Setting | Environment variable | Default | Meaning |
|---|---|---|---|
IMPACT_AGENT_MODEL |
TDFS4DS_IMPACT_AGENT_MODEL |
blank (the instruct model) | Another model of the same provider. |
IMPACT_AGENT_MAX_STEPS |
TDFS4DS_IMPACT_AGENT_MAX_STEPS |
6 |
Planner steps per study. |
IMPACT_AGENT_MAX_CONSUMER_CALLS |
TDFS4DS_IMPACT_AGENT_MAX_CONSUMER_CALLS |
3 |
Questions to the consumer agent per study. |
IMPACT_AGENT_MAX_REVIEWS |
TDFS4DS_IMPACT_AGENT_MAX_REVIEWS |
8 |
Model reviews of undecided findings per study. |