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_VERSIONfrom the environment (injected by the kernel'sContainerAgentHost) - Setting up the MCP client back to the kernel
- Hosting
/health,/describe,/invokeon 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
Apache-2.0. See the repo-level LICENSE.
Metadata
Release files for konstera-sdk 0.6.2
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 |
|---|---|---|---|---|
| konstera_sdk-0.6.2.tar.gz | 65.9 kB | With provenance | Details for konstera_sdk-0.6.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| konstera_sdk-0.6.2-py3-none-any.whl | Python 3 | none | any | Details for konstera_sdk-0.6.2-py3-none-any.whl |
Total release size: 113.6 kB
Release files / konstera_sdk-0.6.2.tar.gz
| Download URL | konstera_sdk-0.6.2.tar.gz |
|---|---|
| Size | 65.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f65f4c72f0353f6e754acad72f55b5506a9cbb9a1b917bc4690de2d523ac22a4
|
|
BLAKE2b-256 checksum How to use checksums |
79134dae8abeb818354c4a54160350a1392af63aa8dc5d2e0ab7d1fca2ba1de9
|
| 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 logRelease files / konstera_sdk-0.6.2-py3-none-any.whl
| Download URL | konstera_sdk-0.6.2-py3-none-any.whl |
|---|---|
| Size | 47.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48c4337a954d4fefbd1bf897181cd78c3867251581316407453e10ebd2a6a108
|
|
BLAKE2b-256 checksum How to use checksums |
163a2da87e3b5c34724d7c5dd49a7fe2214f675271bc38b4bc2bb1183749c4a8
|
| 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 logSecurity for konstera-sdk 0.6.2
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.
Attestation for konstera_sdk-0.6.2.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 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.