Interactive walkthrough — build your first agent
Twelve numbered steps from zero to a deployed agent handling real invocations. Pick a language at step 1 and follow through — each step builds on the previous.
Step 1 — Pick a language + make a folder#
Choose the SDK matching your team's primary language:
| Language | Recommended for | Why |
|---|---|---|
| Python | Teams new to Konstera | Most mature, best coding-agent support |
| TypeScript | Teams already using Node | Ergonomic HTTP server, dual ESM/CJS |
| .NET / C# | Microsoft stack | Strong typing, full LINQ |
Then:
mkdir my-first-agent
cd my-first-agent
Step 2 — Install the SDK#
Pick the install command for your language:
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install konstera-sdk
npm init -y
npm install @konstera/sdk
npm install -D typescript @types/node
npx tsc --init --target ES2022 --module ESNext --moduleResolution Bundler
dotnet new console -n HelloAgent
cd HelloAgent
dotnet add package Konstera.Sdk --prerelease
Step 3 — Write the minimum agent#
The simplest agent: echo whatever's in req.input. Create one file —
main.py (Python), main.ts (TypeScript) or Program.cs (.NET):
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}!", echo_of=name)
return AgentResponse(content=f"Hello, {name}!")
if __name__ == "__main__":
run(HelloAgent())
import { Agent, AgentContext, AgentRequest, AgentResponse, run } from "@konstera/sdk";
class HelloAgent extends Agent {
async handle(req: AgentRequest, ctx: AgentContext): Promise<AgentResponse> {
const name = req.input.trim() || "world";
await ctx.log.info(`Hello, ${name}!`, { echo_of: name });
return { content: `Hello, ${name}!` };
}
}
run(new HelloAgent());
using Konstera.Sdk;
var agent = new Agent("io.konstera.hello-world");
agent.OnInvoke(async (ctx) =>
{
var name = ctx.Input<string>()?.Trim() ?? "world";
await ctx.Log.InfoAsync($"Hello, {name}!", new { echo_of = name });
return new { content = $"Hello, {name}!" };
});
await agent.RunAsync();
Step 4 — Run it locally in direct-run mode#
The SDK's run() detects an unset KONSTERA_KERNEL_MCP_URL and boots in
direct-run mode. The HTTP server comes up either way.
Kind of ctx call | Direct-run mode (KONSTERA_KERNEL_MCP_URL unset) | Live kernel |
|---|---|---|
Kernel-callback services like ctx.log.info | Silently no-op | Recorded |
Services that return data (e.g. ctx.state) | Raise | Work |
python -m main
npx tsc && node main.js
dotnet run
If it fails to start, re-check step 2 — probably a missing dependency. See Error catalog for the common first-run exceptions.
Step 5 — Hit /invoke#
In another terminal:
curl -X POST http://localhost:8080/invoke \
-H content-type:application/json \
-d '{"invocationId":"test-1","input":"Alice","config":{}}'
Expected response:
{"content":"Hello, Alice!","structured":null,"toolCalls":[]}
Try /health + /describe too:
curl http://localhost:8080/health
curl http://localhost:8080/describe
Step 6 — Write the manifest#
Agents are OCI containers that ship with a manifest. Create manifest.json:
{
"$schema": "https://schemas.konstera.ai/agent-manifest.v3.json",
"id": "io.konstera.hello-world",
"version": "0.1.0",
"name": "Hello World",
"description": "Echoes a greeting with the input name.",
"icon": "👋",
"autonomy": "autonomous",
"runtime": {
"kind": "container",
"image": "ghcr.io/your-org/hello-world:0.1.0",
"port": 8080,
"healthPath": "/health",
"timeoutSeconds": 30,
"memoryMi": 256,
"cpuMillis": 250
},
"input": {
"type": "object",
"properties": {
"input": { "type": "string", "description": "Name to greet" }
}
},
"capabilities": { "needs": [] }
}
See Manifest schema (full) for every field.
Step 7 — Write the Dockerfile#
The agent ships as a container. Pick the Dockerfile for your language.
Create Dockerfile:
FROM python:3.13-slim
WORKDIR /app
COPY . .
RUN pip install --no-cache-dir konstera-sdk
EXPOSE 8080
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8080/health', timeout=2)"
ENTRYPOINT ["python", "-u", "main.py"]
FROM node:20-slim AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npx tsc
FROM node:20-slim
WORKDIR /app
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/main.js ./
COPY package*.json ./
EXPOSE 8080
ENTRYPOINT ["node", "main.js"]
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY . .
RUN dotnet publish -c Release -o /app
FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
COPY --from=build /app .
EXPOSE 8080
ENTRYPOINT ["dotnet", "HelloAgent.dll"]
Step 8 — Run the container#
docker run --rm -p 8080:8080 hello-world:0.1.0
In another terminal, repeat the /invoke test from step 5.
Step 9 — Add a kernel-service call#
Now exercise a kernel service with real behaviour. Modify handle() to
also look up some state (which only works against a live kernel — in
direct-run mode it'll raise RuntimeError).
Python — update main.py's handle method:
async def handle(self, req, ctx):
count = (await ctx.state.get("greetings_sent")) or 0
count += 1
await ctx.state.set("greetings_sent", count)
name = req.input.strip() or "world"
await ctx.log.info(f"Hello, {name}!", count=count)
return AgentResponse(
content=f"Hello, {name}! (greeting #{count})",
structured={"count": count},
)
- TypeScript — equivalent
ctx.state.get<number>+ctx.state.set. - .NET — equivalent
ctx.State.GetAsync<int>+ctx.State.SetAsync.
Step 10 — Deploy to a Konstera instance (Cloud or self-hosted)#
Two paths:
- Sign up at konstera.ai/sign-up (private beta)
- Pair the CLI:
konstera login --scopes devx.metadata.read,devx.manifest.validate,devx.agent.deploy_dev - Build, push and publish:
konstera deploy --image ghcr.io/your-org/my-first-agent:0.1.0(a public image)
- Follow the Deploy guide —
docker compose up -druns the full stack (API + Portal + Postgres + Temporal) - Push to the local registry:
docker tag hello-world:0.1.0 localhost:4505/hello-world:0.1.0 && docker push localhost:4505/... - Upload the manifest in the portal → Agents → Upload
Step 11 — Invoke it in production#
In the portal → Agents → Hello World → Test invoke:
- Enter the inputInput:
Alice - Click InvokeClick Invoke.
Step 12 — Observe + debug#
Click the invocation in the Invocations tab. You see:
| Trace section | What it shows |
|---|---|
| Request | invocationId, input, payload, config |
| Kernel calls | the two ctx.state.* calls with latency + args |
| Log entries | your ctx.log.info call with structured fields |
| Response | the final body served to the caller |
What you've learned#
- How the SDK's
run()works (direct-run mode vs. live kernel) - The
handle()contract (req,ctx, returnAgentResponse) - Kernel services:
ctx.log(fire-and-forget) vsctx.state(data, requires kernel) - The three-file deployment unit: code + manifest + Dockerfile
- How to observe + debug an invocation in the portal
Next steps#
Integrate with a tenant-bound connector via ctx.capability.call("some.capability", ...). See Kernel MCP services.
Pause the workflow with ctx.human.request(). See the HITL recipe.
Use ctx.vector.query() to ground an LLM response. See the RAG recipe.
This agent is Python; try porting to TypeScript or .NET from the Code examples side-by-side page.
When something goes wrong#
| Symptom | Where to go |
|---|---|
| Agent fails to boot | Error catalog — Python SDK errors |
| Manifest upload fails | Error catalog — Manifest validation |
| Invocation fails on live kernel | Open the trace → see Debugging |
| General questions | FAQ |
| Stuck | Book a call — we read every message |