Skip to main content

konstera-sdk (Python)

Build Konstera agents in Python without hand-writing MCP client boilerplate, HTTP servers, or env-var parsing. Subclass Agent, override handle(), call run().

Status: v0.1.0 (M6). Log + LLM (stub) kernel services only. Vector / state / credentials / cost / tool / agents / human / prompt come in M7.

Install

The SDK ships as a Python package. During development, install from source:

pip install -e sdk/python

Container agents install it via a multi-stage Dockerfile — the SDK wheel is built in one stage and copied into the final image. See agents/hello-world-python/Dockerfile for the reference pattern.

Minimal agent

from konstera_sdk import Agent, AgentContext, AgentRequest, AgentResponse, run

class HelloAgent(Agent):
    async def handle(self, req: AgentRequest, ctx: AgentContext) -> AgentResponse:
        name = req.input.strip() or "world"
        await ctx.log.info(f"Hello, {name}!", input=name, language="python")
        return AgentResponse(content=f"Hello, {name}!")

if __name__ == "__main__":
    run(HelloAgent())

That's it — ~10 lines for a complete agent. run() handles:

  • Reading KONSTERA_KERNEL_MCP_URL, KONSTERA_AGENT_INSTANCE_ID, KONSTERA_AGENT_ID, KONSTERA_AGENT_VERSION from the environment (injected by the kernel's ContainerAgentHost)
  • Setting up the MCP client back to the kernel
  • Hosting /health, /describe, /invoke on port 8080
  • Routing invocations to your handle()
  • Graceful shutdown

API

Agent (base class)

class Agent:
    async def initialize(self, ctx: AgentContext) -> None: ...
    async def handle(self, req: AgentRequest, ctx: AgentContext) -> AgentResponse: ...
    async def shutdown(self, ctx: AgentContext) -> None: ...

Override handle() (required). Override initialize() / shutdown() for setup/teardown.

AgentContext

ctx.instance_id     # str — this agent instance's UUID
ctx.agent_id        # str — e.g. "io.konstera.hello-world-python"
ctx.agent_version   # str — e.g. "0.1.0"
ctx.log             # LogService — ctx.log.info/warn/error
ctx.llm             # LlmService — ctx.llm.complete (stub in M6)

LogService

await ctx.log.info(message, **fields)
await ctx.log.warn(message, **fields)
await ctx.log.error(message, **fields)

Structured fields (kwargs) are JSON-serialised and enriched by the kernel with tenant/instance/invocation context, then flowed to Serilog + App Insights.

LlmService (stub in M6)

text = await ctx.llm.complete(model="claude-sonnet-4-6", prompt="Hello")

Real Claude / OpenAI / Gemini adapters land in M10 (SPEC §10). Interface is stable now; agent code written today will keep working when the stub goes away.

run(agent, port=8080)

Blocks until the process is stopped. Handles all lifecycle: reads env, creates context, calls initialize(), serves HTTP, calls shutdown() on SIGTERM.

Direct-run mode

When KONSTERA_KERNEL_MCP_URL is unset, kernel callbacks become no-ops (they log a warning and return successfully). This lets you develop agents locally without the full Konstera stack running:

python -m your_agent_module
# Serves on :8080 — POST /invoke works but ctx.log/ctx.llm skip.

Licence

BSL-1.1 (Business Source License). See the repo-level LICENSE. Auto-converts to Apache 2.0 four years after each release.

Metadata

Release files for konstera-sdk 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for konstera-sdk 0.6.0
File Size Uploaded Provenance Actions
konstera_sdk-0.6.0.tar.gz 65.8 kB With provenance Details for konstera_sdk-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for konstera-sdk 0.6.0
File Interpreter ABI Platform Actions
konstera_sdk-0.6.0-py3-none-any.whl Python 3 none any Details for konstera_sdk-0.6.0-py3-none-any.whl

Total release size: 113.4 kB

Release files / konstera_sdk-0.6.0.tar.gz

Download URL konstera_sdk-0.6.0.tar.gz
Size 65.8 kB
Tags Source
SHA-256 checksum
How to use checksums
fde6609f30bae901345ffbd82b52bb6a0978fb84edd7408cbafe33239ec7e916
BLAKE2b-256 checksum
How to use checksums
d2b5d8db69c754d1f3df2eeae00536149c85cd8b22340bf6acf266b411a275e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 26, 2026.

Transparency log

Release files / konstera_sdk-0.6.0-py3-none-any.whl

Download URL konstera_sdk-0.6.0-py3-none-any.whl
Size 47.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
10bd26412217aafb74f642c4a069d564ef37792d096d80f57231d08773a850d9
BLAKE2b-256 checksum
How to use checksums
1802dce825ff0b7d16619e6de9c46d3a486b21cdb27cb7b46aefa2b802f4e094
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 26, 2026.

Transparency log

Security for konstera-sdk 0.6.0

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for konstera_sdk-0.6.0.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 Oct 26, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page