Autonomous agents generating unbounded queries are a FinOps hazard. Ptolemaois sits between LLM execution runtimes and your analytical data warehouse—parsing ASTs in <10ms, blocking unpartitioned full scans, and generating verified PySpark schema patches in-flight.
pip install ptolemaois-proxy
-- Rogue agent query without partition bounds
SELECT
customer_id,
SUM(amount_usd) AS total_spend
FROM `raw_events.payments`
WHERE status = 'SETTLED'
GROUP BY 1
ORDER BY 2 DESC;
[AST VALIDATOR REJECT]: Missing required clustering/temporal key `_PARTITIONDATE`.
Budget threshold exceeded: MaxAllowed=500MB, Estimated=8400GB.
-- Injected bounded temporal scope + cluster pushdown
SELECT
customer_id,
SUM(amount_usd) AS total_spend
FROM `raw_events.payments`
WHERE status = 'SETTLED'
AND _PARTITIONDATE >= DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY)
AND tenant_id = 'prod_eu_central'
GROUP BY 1
ORDER BY 2 DESC;
[PROXY DISPATCH]: Validated with dryRun=true API.
Dispatched to BigQuery API backend. Latency overhead: 11.2ms.
A zero-trust middleware that validates every Text-to-SQL statement against database metadata and AST token limits. Unpartitioned scans are dropped or rewritten before reaching storage billing APIs.
Schema changes in upstream JSON APIs break downstream ETL. Ptolemaois catches PySpark and Dataflow stack traces, segregates drifted rows to dead-letter storage, and synthesizes schema-migration PRs.
Connects every LLM prompt and tool invocation directly to analytical warehouse rows and vector retrieval snapshots. Full audit trails for regulated sectors (EU AI Act, HIPAA).
# Minimal integration with LangChain / Custom Agent Runtime
import os
from ptolemaois import PtolemaoisGateway, BudgetPolicy
# Wrap your BigQuery or Snowflake client with deterministic guardrails
gateway = PtolemaoisGateway(
api_key=os.getenv("PTOLEMAOIS_API_KEY"),
warehouse="bigquery",
policy=BudgetPolicy(
max_bytes_per_query=500_000_000, # 500 MB ceiling
require_partition_filters=True,
auto_rewrite_with_sonnet=True
)
)
# Autonomous Agent passes generated SQL string:
safe_query = gateway.intercept(agent_sql)
results = safe_query.execute() # Executes safely within budget boundaries
Currently deploying private pilots with engineering teams running autonomous data agents in production on GCP and Snowflake.