Skip to main content

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 kitagentcli to generate a complete, working agent project in a single command.
  • Standardized Agent Structure: The BaseAgent class 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 in manifest.json and customized at runtime in the UI.
  • self.output_path: A pathlib.Path object pointing to the directory where all artifacts, models, and metrics must be saved (e.g., ./_output locally, or a temporary path when run by kitexec).

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/name convention (e.g., performance/sharpe_ratio) to automatically group related charts under a common heading in the UI.
  • 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 the model.zip or norm_stats.json from a pre-training stage. The required artifact IDs are automatically injected into self.config by 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 by self.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kitagentsdk-0.3.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kitagentsdk-0.3-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file kitagentsdk-0.3.tar.gz.

File metadata

  • Download URL: kitagentsdk-0.3.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for kitagentsdk-0.3.tar.gz
Algorithm Hash digest
SHA256 dd3c88b8ec3362d7a945c659dbbb0ed6f6881d25e0da5f68d62616d2831016cc
MD5 5ed8aadcd9e9ff9e94cd38ce307bac58
BLAKE2b-256 1b2f14542f94245bbf1a33190d1b66eafe08062842af41349b88050f023d5e92

See more details on using hashes here.

File details

Details for the file kitagentsdk-0.3-py3-none-any.whl.

File metadata

  • Download URL: kitagentsdk-0.3-py3-none-any.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for kitagentsdk-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2e7775d8376bff6454cb0c96abcae4eb4fee98a2f1dee4a01009c88447253e7c
MD5 0b275ceb2d9aa50c21e7db480173f2cb
BLAKE2b-256 3272585b49e59490c4fb71ce75a032417c8bffb8399106064dcfd510d6a82467

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page