NeMo-Agent-Toolkit-schemagate
schemagate for NVIDIA NeMo Agent Toolkit. A text-to-SQL agent gets only the tables a question needs, picked from the tables the caller may read. A table the caller can't read is never a candidate, so it can't reach the prompt.
This package is a third-party plugin, maintained outside the NeMo Agent Toolkit repository.
What it does
schemagate reflects your database once (table structure only, never rows), indexes it, and for each question selects a handful of tables and views with hybrid lexical and vector retrieval, then adds the join tables the question never names by following foreign keys. Objects and columns restricted to roles the caller lacks are removed before ranking. The result is compact DDL to put in the SQL-writing prompt.
Selection runs locally and calls no model.
On Spider 2.0-lite's public BigQuery and Snowflake schemas, the median saving per database with 50+ tables was 91.1% of the prompt tokens the full schema would take. On small schemas there is little to cut: 8.8% on BIRD's seven-table databases. The method, the full table and the recall trade-off are in schemagate's BENCHMARKS.md.
Installation
uv add nemo-agent-toolkit-schemagate
or:
pip install nemo-agent-toolkit-schemagate
Database drivers are not included. Install the one for your database, for example psycopg[binary] for
PostgreSQL or oracledb for Oracle. SQLite needs nothing.
Check that NeMo Agent Toolkit discovers the plugin:
nat info components -q schemagate
Registered components
| Kind | _type |
Tools / use |
|---|---|---|
| Function group | schemagate |
<instance>__select, <instance>__list_objects (with the instance named schemagate: schemagate__select, schemagate__list_objects) |
| Retriever | schemagate |
Native toolkit retriever. One Document of DDL per selected table, for nat_retriever or builder.get_retriever |
Entry point: nat_schemagate = "nemo_agent_toolkit_schemagate.register" in the nat.plugins group.
schemagate__select takes question and returns:
ddl: the prompt fragment, compact DDL of the selected tables and viewsobjects: the names chosenexplain: score and selection reason per objectselected,total_objects,question
schemagate__list_objects returns every table and view the caller may read, with kind, column count and
description.
Minimal workflow
No database and no API key needed for the tool itself: database_url: demo uses schemagate's bundled SQLite
schema (42 tables and views; hr_compensation is readable by the payroll role only).
function_groups:
schemagate:
_type: schemagate
database_url: demo
top_k: 6
llms:
my_llm:
_type: nim
model_name: meta/llama-3.3-70b-instruct
workflow:
_type: react_agent
llm_name: my_llm
tool_names:
- schemagate
export NVIDIA_API_KEY=...
nat run --config_file examples/config.yml --input "Which tables do I need for late shipments by carrier?"
examples/config.yml is this workflow. examples/config_ollama.yml
is the same against a local Ollama server, with no key. examples/retriever.yml uses
the retriever through the toolkit's nat_retriever function.
Configuration
The same fields apply to the function group and the retriever.
| Field | Default | Description |
|---|---|---|
database_url |
SCHEMAGATE_DATABASE_URL, then demo |
SQLAlchemy URL to reflect, or demo. Stored as a secret, since a URL can carry a password. |
top_k |
6 |
Tables and views selected before foreign-key expansion adds join tables (1 to 50). |
principal |
none | Caller identity, namespaced as <source>:<id>, for example okta:jdoe. |
roles |
[] |
Roles of the caller. A table or column restricted to roles the caller lacks is never selected. |
expand_foreign_keys |
true |
Pull in join tables the question never names. |
max_columns |
40 |
Columns shown per table in the DDL. |
config_file |
none | A schemagate config file (hints, restrictions, concepts, rules), applied after reflection. |
Who the caller is
principal and roles are configuration, set by whoever deploys the workflow, and are deliberately not tool
arguments. If the agent could pass roles, it could pass payroll and read what the payroll role may read. One
configured group or retriever serves one caller identity; configure one instance per role you serve:
function_groups:
analyst_schema:
_type: schemagate
database_url: ${SCHEMAGATE_DATABASE_URL}
principal: okta:analyst
roles: [analyst]
payroll_schema:
_type: schemagate
database_url: ${SCHEMAGATE_DATABASE_URL}
principal: okta:payroll
roles: [analyst, payroll]
Restrictions come from a schemagate config_file or, for the demo, are built in. See
schemagate's README for restricting by role and reading
grants from the database.
Supported versions
- NeMo Agent Toolkit (
nvidia-nat-core) 1.8 and 1.9; the dependency is>=1.8,<2. - schemagate
>=1.15.1,<2. - Python 3.11, 3.12 and 3.13.
Tests
The tests use the bundled demo schema and need no network, database or API key.
uv sync --extra test
uv run pytest tests/ -v
or:
pip install -e ".[test]"
pytest tests/ -v
Bugs
- Wrong tables selected, a restriction not applied, or a problem in this plugin: open an issue in this repository or in schemagate.
- A problem in NeMo Agent Toolkit itself (
natCLI, workflow loading, agents): open an issue in NVIDIA/NeMo-Agent-Toolkit.
Security issues: follow schemagate's SECURITY.md.
License
Apache-2.0. See LICENSE.
Metadata
Release files for nemo-agent-toolkit-schemagate 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nemo_agent_toolkit_schemagate-0.1.0.tar.gz | 15.5 kB | With provenance | Details for nemo_agent_toolkit_schemagate-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nemo_agent_toolkit_schemagate-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nemo_agent_toolkit_schemagate-0.1.0-py3-none-any.whl |
Total release size: 30.7 kB
Release files / nemo_agent_toolkit_schemagate-0.1.0.tar.gz
| Download URL | nemo_agent_toolkit_schemagate-0.1.0.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df363bc8d6cb3aca11d29e35db3fb9572195c564707a4a2dac9c038cd0c69417
|
|
BLAKE2b-256 checksum How to use checksums |
6421906e68f99dd2467a5f012d89ce985905ad9df58abb4d1164c6b63311ad4e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logRelease files / nemo_agent_toolkit_schemagate-0.1.0-py3-none-any.whl
| Download URL | nemo_agent_toolkit_schemagate-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6fa85748693e3f96856342062333f1e46b2b85a18c5485edbbaea99817cba769
|
|
BLAKE2b-256 checksum How to use checksums |
4c11d3939f72090239d8662b348c2349d9cb964fb2847414a4e41040cc1ab8c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logSecurity for nemo-agent-toolkit-schemagate 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for nemo_agent_toolkit_schemagate-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.