tsagentkit
Minimalist time-series forecasting toolkit for coding agents.
tsagentkit provides:
- a fixed panel data contract
- zero-config TSFM ensemble forecasting
- a small set of pipeline primitives for agent customization
- explicit TSFM model lifecycle control via
ModelCache
For architecture details and design rationale, see docs/DESIGN.md.
Install
pip install tsagentkit
Data Contract
Input data must include these required columns:
unique_id: series identifierds: timestampy: target value
Custom column remapping is not supported. Required columns must be non-null.
import pandas as pd
# Valid input schema (minimal)
raw_df = pd.DataFrame({
"unique_id": ["A"] * 30,
"ds": pd.date_range("2025-01-01", periods=30, freq="D"),
"y": range(30),
})
Quick Start
from tsagentkit import forecast
result = forecast(raw_df, h=7, freq="D")
print(result.df.head())
Standard Pipeline API
from tsagentkit import ForecastConfig, run_forecast
config = ForecastConfig(h=7, freq="D", ensemble_method="median")
result = run_forecast(raw_df, config)
print(result.df.head())
Building-Block Pipeline
from tsagentkit import (
ForecastConfig,
validate,
build_dataset,
make_plan,
fit_all,
predict_all,
ensemble,
)
config = ForecastConfig(h=7, freq="D")
df = validate(raw_df)
dataset = build_dataset(df, config)
models = make_plan(tsfm_only=True)
artifacts = fit_all(models, dataset)
predictions = predict_all(models, artifacts, dataset, h=config.h)
ensemble_df = ensemble(predictions, method=config.ensemble_method, quantiles=config.quantiles)
print(ensemble_df.head())
Performance
tsagentkit runs parallel model fitting and prediction by default. Large panels (>50k rows) automatically use streaming ensemble to reduce memory usage.
# Opt-out if needed (e.g., memory-constrained environments)
result = forecast(raw_df, h=7, parallel_fit=False, parallel_predict=False)
Model Cache Lifecycle
ModelCache manages loaded TSFM instances and avoids expensive reloads.
from tsagentkit import ModelCache, forecast
from tsagentkit.models.registry import REGISTRY
# Optional preload
models = [m for m in REGISTRY.values() if m.is_tsfm]
ModelCache.preload(models)
# Reuses cached models across calls
result = forecast(raw_df, h=7)
# Explicit release
ModelCache.unload() # all models
# ModelCache.unload("chronos") # one model
# Optional inspection
print(ModelCache.list_loaded())
ModelCache.unload() semantics:
- releases all
tsagentkit-owned model references - calls adapter unload hooks when available
- triggers best-effort backend cleanup (
gc.collect, CUDA/MPS cache clear) - cannot reclaim memory still referenced by external user code
Public API
Top-level (from tsagentkit import ...):
forecast,run_forecastForecastConfig,ForecastResult,RunResultTSDataset,CovariateSetvalidate,build_dataset,make_plan,fit_all,predict_all,ensembleModelCacheREGISTRY,ModelSpec,list_modelsLengthAdjustment,adjust_context_length,validate_prediction_lengthget_effective_limits,check_data_compatibilityresolve_devicecheck_healthTSAgentKitError,EContract,ENoTSFM,EInsufficient,ETemporal
Inspection API (from tsagentkit.inspect import ...):
list_modelscheck_health,HealthReport
Errors
Core error types:
EContract: input contract violationsENoTSFM: TSFM registry invariant violation (internal misconfiguration)EInsufficient: not enough successful model outputsETemporal: temporal integrity violations
from tsagentkit import EContract, forecast
try:
result = forecast(raw_df, h=7)
except EContract as e:
print(e.code, e.hint)
raise
Developer Commands
uv sync --all-extras
uv run pytest
uv run mypy src/tsagentkit
uv run ruff format src/
# Real TSFM smoke tests (live adapters)
TSFM_RUN_REAL=1 uv run pytest tests/ci/test_real_tsfm_smoke_gate.py tests/ci/test_standard_pipeline_real_smoke.py
License
Apache-2.0
Metadata
Release files for tsagentkit 2.0.3
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 |
|---|---|---|---|---|
| tsagentkit-2.0.3.tar.gz | 344.9 kB | With provenance | Details for tsagentkit-2.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tsagentkit-2.0.3-py3-none-any.whl | Python 3 | none | any | Details for tsagentkit-2.0.3-py3-none-any.whl |
Total release size: 397.9 kB
Release files / tsagentkit-2.0.3.tar.gz
| Download URL | tsagentkit-2.0.3.tar.gz |
|---|---|
| Size | 344.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39c174a0a5e419e4fa975d9c1c829fa9593de6032d2408b6b168b257f0dd2f53
|
|
BLAKE2b-256 checksum How to use checksums |
c6f7eddc30325e0e193b381839a06b908f526ee66770002d3fc690ea2a012e40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Feb 20, 2026.
Transparency logRelease files / tsagentkit-2.0.3-py3-none-any.whl
| Download URL | tsagentkit-2.0.3-py3-none-any.whl |
|---|---|
| Size | 53.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5752159c43dba5e1db425aa621afcce007baaa89f55ddb93065b483ea6e6bea9
|
|
BLAKE2b-256 checksum How to use checksums |
81cb8321285a3f3f70963193b11fcb304380948d8efd85ef3ec5696148599bb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Feb 20, 2026.
Transparency logSecurity for tsagentkit 2.0.3
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
Both files in this release have been uploaded with provenance metadata.
Attestation for tsagentkit-2.0.3.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 Feb 20, 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.