Skip to main content

Agent application with multi-endpoint support for the k agent framework

Project description

kcastle

kcastle also provides a short k command alias, so you can start the agent with either kcastle or k.

PyPI

Agent application with multi-endpoint support for the K agent framework.

kcastle is a general-purpose agent application built on kagent. It provides a unified agent runtime accessible from multiple endpoints — each endpoint connects to the same agent instance and shares conversation history via kagent.Trace.

Architecture

┌─────────────────────────────────────────────┐
│  kcastle                                    │
│                                             │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐    │
│  │ CLI      │ │ Telegram │ │ Discord  │    │
│  │ Endpoint │ │ Endpoint │ │ Endpoint │    │
│  └────┬─────┘ └────┬─────┘ └────┬─────┘    │
│       │             │            │          │
│       └──────┬──────┴────────────┘          │
│              │                              │
│       ┌──────▼──────┐                       │
│       │ kagent.Agent│ ◄── EventBus (SPMC)   │
│       │ + Trace     │                       │
│       └──────┬──────┘                       │
│              │                              │
│       ┌──────▼──────┐                       │
│       │  TraceStore │ (persistence)         │
│       └─────────────┘                       │
└─────────────────────────────────────────────┘

Endpoints

Each endpoint is an adapter that:

  1. Receives user input from its platform (terminal, Telegram, Discord, etc.)
  2. Sends commands to the shared Agent instance (run(), steer(), abort())
  3. Subscribes to the Agent's event stream and renders output for its platform

Shared State

All endpoints share the same Agent instance and its Trace. This means:

  • Conversation history is unified across all endpoints
  • A message sent via Telegram is visible when resuming from the CLI
  • Pause/resume works by persisting the Trace via TraceStore and reconstructing the Agent

What kcastle owns

  • Endpoint adapters — CLI, Telegram, Discord (and future endpoints)
  • Provider factory/registry — provider-id-to-constructor mapping policy (kcastle.provider_factory)
  • PersistenceTraceStore configuration and session management
  • Tool registration — Domain-specific tools for the agent
  • Configuration — Agent setup, system prompts, model selection
  • UI/rendering — Platform-specific output formatting

What kcastle does NOT own

These live in lower layers:

  • Agent runtimekagent (agent loop, state, events, context builders)
  • LLM abstractionkai (providers, streaming, tool schemas)

Configuration

kcastle uses explicit provider profiles. The default runtime selection is a provider + model pair:

default:
	provider: deepseek-openai
	model: deepseek-chat

You can override built-in providers by redefining the same provider key:

providers:
	deepseek-openai:
		api_key: ${DEEPSEEK_API_KEY}
		base_url: https://api.deepseek.com
		models:
			deepseek-chat:
				active: true
			deepseek-reasoner:
				active: true

OpenTelemetry hooks are disabled by default. Set OTEL_EXPORTER_OTLP_ENDPOINT (e.g. http://localhost:4317) to enable trace export.

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

kcastle-0.0.1a2.tar.gz (52.2 kB view details)

Uploaded Source

Built Distribution

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

kcastle-0.0.1a2-py3-none-any.whl (69.0 kB view details)

Uploaded Python 3

File details

Details for the file kcastle-0.0.1a2.tar.gz.

File metadata

  • Download URL: kcastle-0.0.1a2.tar.gz
  • Upload date:
  • Size: 52.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kcastle-0.0.1a2.tar.gz
Algorithm Hash digest
SHA256 c950b4137d694a65f18426203c3bb99fb317a9af6a888aae30241cf701725306
MD5 0dfefce03149dd2b2078cee30d67ca44
BLAKE2b-256 ddfbf45ca0b244a82a439f94f53c51d53ed4bf014c65e931b6b6086faf9fa1fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for kcastle-0.0.1a2.tar.gz:

Publisher: release.yml on shenxiangzhuang/kcastle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kcastle-0.0.1a2-py3-none-any.whl.

File metadata

  • Download URL: kcastle-0.0.1a2-py3-none-any.whl
  • Upload date:
  • Size: 69.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kcastle-0.0.1a2-py3-none-any.whl
Algorithm Hash digest
SHA256 b3cc607239aebe1ceb218eafd40ad0456c28b1e4a0a0e6682819310ff7ff2bfe
MD5 992a588fb841beb64c4fe6df01701ea3
BLAKE2b-256 cde9a8b1a00a4cb78c11c84156afec2da121e73dbe02324c0abc500fe8283248

See more details on using hashes here.

Provenance

The following attestation bundles were made for kcastle-0.0.1a2-py3-none-any.whl:

Publisher: release.yml on shenxiangzhuang/kcastle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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