SDK and CLI for building Kit platform agents.
Project description
Kit Agent SDK
https://pypi.org/project/kitagentsdk/
The kitagentsdk is a Python library that provides a standardized, high-level framework for developing agents for the Kit platform. It is designed to abstract away the boilerplate of platform integration, allowing developers to focus entirely on their agent's core logic.
This package includes both the SDK (the kitagentsdk library) and a command-line interface (kitagentcli) to accelerate development.
Key Features
- Rapid Scaffolding: Use the
kitagentclito generate a complete, working agent project in a single command. - Standardized Agent Structure: The
BaseAgentclass provides a clear and consistent structure for all agents. - Simplified Platform Interaction: A rich set of helper methods for logging, metrics, progress reporting, and data fetching that automatically communicate with the Kit platform.
- Local Testing: Agents are fully runnable on a local machine, enabling rapid testing and debugging.
Installation
The SDK and CLI are distributed as a single package on PyPI.
pip install kitagentsdk
Getting Started: Creating a New Agent
The fastest way to get started is by using the kitagentcli.
1. Create a New Agent Project
Run the new command to scaffold a new project directory.
kitagentcli new my-trading-agent
This creates a new folder named my-trading-agent with a clean, working structure:
├── .gitignore
├── README.md
├── manifest.json
├── requirements.txt
└── main.py
2. Implement Your Agent's Logic
Open main.py. The generated file provides a clear starting point for your agent's training logic, demonstrating the key SDK features.
3. Run Your Agent Locally
You can test your agent's train command directly on your local machine.
# Create a dummy config file (to simulate what the platform provides)
echo '{"total_steps": 100, "learning_rate": 0.01}' > config.json
# Create a directory for output
mkdir ./_output
# Run the agent's training script
python main.py train --config config.json --output-path ./_output
You will see your agent's log messages printed to the console, and the _output directory will contain the generated model.zip artifact and metrics.log file.
The BaseAgent API
All agents must inherit from kitagentsdk.BaseAgent. This base class provides the following helpers:
Core Properties
self.config: A dictionary containing the configuration parameters for the current run, as defined inmanifest.jsonand customized at runtime in the UI.self.output_path: Apathlib.Pathobject pointing to the directory where all artifacts, models, and metrics must be saved (e.g.,./_outputlocally, or a temporary path when run bykitexec).
UI and Platform Integration Methods
These methods are the primary way your agent communicates its state back to the Kit UI.
-
self.log(message: str): Prints a message to the agent's execution log, which is streamed in real-time to the training detail page in the UI. Use this for all status updates and important events. -
self.record_metric(name: str, step: int, value: float): Records a time-series data point. These are automatically collected and visualized as charts in the UI.- Pro Tip: Use a
group/nameconvention (e.g.,performance/sharpe_ratio) to automatically group related charts under a common heading in the UI.
- Pro Tip: Use a
-
self.report_progress(step: int): Reports the agent's current step count. This updates the progress bars for the run and the overall training in the UI. It is highly recommended to call this frequently (e.g., on every step) via a callback.
The Kit API Client: self.kit
The self.kit object is an instance of KitClient that handles authenticated communication with the Kit backend API.
-
self.kit.get_training_data(params: dict) -> dict | None: Requests a fully prepared, feature-enriched, and bias-corrected training dataset. This is the standard way for agents to receive market data.# Example usage inside your environment params = { "symbol": "YM", "start_date": "2020-01-01", "end_date": "2021-01-01", "features": self.config.get("features", []) # From manifest.json } data_json = self.kit.get_training_data(params) # data_json will contain 'short', 'mid', and 'long' timescale dataframes
-
self.kit.download_artifact(artifact_id: UUID, destination_path: str) -> bool: Downloads an artifact from a previous run. This is essential for multi-stage training, allowing a fine-tuning stage to download themodel.zipornorm_stats.jsonfrom a pre-training stage. The required artifact IDs are automatically injected intoself.configby the backend.
Standardized Artifacts
To enable automatic stage transitions, the platform expects two standardized artifact types:
model.zip: The primary output of any training stage (e.g., the saved SB3 model).norm_stats.json: A JSON file containing feature normalization statistics, typically only generated during a pre-training stage.
Your agent should save its final outputs using these filenames in self.output_path. The kitexec worker will automatically assign the correct type when uploading them.
The manifest.json File
This file provides the Kit platform with metadata about your agent.
name,description: Basic info displayed in the UI.parameters: Defines the hyperparameters and environment settings that will be exposed to the user in the "Create New Training" wizard.default_features: A list of features the agent requires. These are used byself.kit.get_training_data.default_training: Defines the default multi-stage training plan, including the configuration for each stage.
The kitagentcli
A command-line tool to accelerate development.
kitagentcli new <project_name>: Scaffolds a complete, ready-to-run agent project in a new directory named<project_name>.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kitagentsdk-0.2.10.tar.gz.
File metadata
- Download URL: kitagentsdk-0.2.10.tar.gz
- Upload date:
- Size: 22.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d888cfaa6555a63efcaa00b244dd3d17351c5f3bf65b660c33438fe49cdafc8
|
|
| MD5 |
698ef78bdfe7dc5494fe180b9a514de9
|
|
| BLAKE2b-256 |
a10b886f014c134c8ab63f6695d041c8d40d381409e1422eed653b465bf0bf0c
|
File details
Details for the file kitagentsdk-0.2.10-py3-none-any.whl.
File metadata
- Download URL: kitagentsdk-0.2.10-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a903166218893c7bc97c4eb6f69964591199094285ee37f4af4f2921a309b6f
|
|
| MD5 |
38a9947beae56e80204f5364fa378b75
|
|
| BLAKE2b-256 |
16b0cbcdb77896ed64cca895b9c01ec065d29645e146479685efe32fc31af6f0
|