Skip to main content
Back to path selection

Level 02 / Developers

Build your first agent, then ship it

Open Agent Kernel (OAK) wraps the agent framework you already use and gives it an API, memory, channels and a way to production. This page walks the route from an empty folder to an agent that is deployed and tested.

01Write

Write the agent in the framework you know

OAK does not replace your framework. You define the agent the usual way, then hand it to a module.

Terminal
uv init --python 3.12 my-agent
cd my-agent
uv add "agentkernel[openai]"
export OPENAI_API_KEY=your-api-key-here

Two lines of the file belong to OAK: the module line registers the agent with the runtime, and CLI.main() starts it. The rest is your framework's own code.

OpenAI Agents guide
my_agent.py
from agents import Agent as OpenAIAgent
from agentkernel.cli import CLI
from agentkernel.openai import OpenAIModule

agent = OpenAIAgent(
name="assistant",
instructions="You are a helpful assistant.",
)

OpenAIModule([agent])

if __name__ == "__main__":
CLI.main()

02Run

Run it on your laptop, then call it over HTTP

The same file runs as an interactive session or as an API server. Only the last line changes.

In the terminal

The CLI opens a session with your agent. !list shows the registered agents, !select switches between them and !quit leaves.

Terminal
$ uv run python my_agent.py
AgentKernel CLI (type !help for commands or !quit to exit):
(kernel) >> Selected agent: assistant
(assistant) >> !list
Available agents:
assistant

(assistant) >> What is 2 + 2?
(assistant) >> 2 + 2 = 4.

As a REST API

Swap CLI.main() for RESTAPI.run() and the agent answers on /api/v1/chat, with sessions kept between calls.

my_agent.py
from agentkernel.api import RESTAPI

# ... your agent and its module line, unchanged ...

if __name__ == "__main__":
RESTAPI.run()
Terminal
uv add "agentkernel[api]"
uv run python my_agent.py

curl -X POST http://localhost:8000/api/v1/chat \
-H "Content-Type: application/json" \
-d '{"agent": "assistant", "prompt": "Hello!", "session_id": "test-123"}'

03Configure

Switch capabilities on in config.yaml

What you would otherwise build around an agent is a block of configuration. Every setting also has an environment variable, such as AK_SESSION__TYPE.

  • Memory

    Sessions start in memory and move to Redis, Valkey, DynamoDB, Cosmos DB or Firestore when you change session.type.

    Choose a memory backend
  • Channels

    The slack block names the agent that answers and where its credentials are read from. Each channel also needs a short adapter in your entry point, shown in its guide.

    Integration guides
  • Guardrails

    Input and output checks run in the same pipeline as the agent, with OpenAI, Amazon Bedrock or Walled AI as the provider.

    Guardrails
  • Tracing

    One block sends every run to Langfuse, OpenLLMetry, Pydantic Logfire or CloudWatch, with no instrumentation in your code.

    Traceability
config.yaml
session:
type: redis
redis:
url: redis://localhost:6379
ttl: 604800 # 7 days in seconds

slack:
agent: assistant
bot_token_key: SLACK_BOT_TOKEN
signing_secret_key: SLACK_SIGNING_SECRET

guardrail:
input:
enabled: true
type: bedrock
id: your-guardrail-id
version: "1"

trace:
enabled: true
type: langfuse
Configuration reference

04Deploy

Deploy with Terraform or Helm

The agent code stays the same on every target. Terraform modules cover AWS, Azure and Google Cloud, and a Helm chart covers your own Kubernetes cluster.

On your cloud

For AWS Lambda, end the file with handler = Lambda.handler in place of the CLI, point the module at your package, then run terraform init and terraform apply.

deploy/main.tf
module "serverless_agents" {
source = "yaalalabs/ak-serverless/aws"
providers = { aws = aws, docker = docker }

prefix = "ak-dev-quickstart"
region = var.region
product_display_name = "AK Quick Start"

request_handler = {
function_name = "ak-quickstart"
handler_path = "lambda.handler"
package_path = "../dist"
package_type = "Image"
memory_size = 256
timeout = 45
}
}

On your own cluster

The chart runs the IO handler and the agent runner as separate deployments, so that each scales on its own.

Terminal
helm pull oci://ghcr.io/yaalalabs/charts/agent-kernel --untar
helm install ak oci://ghcr.io/yaalalabs/charts/agent-kernel \
-f agent-kernel/values-dev.yaml \
--set ioHandler.image.repository=<io image> \
--set agentRunner.image.repository=<runner image> \
--set image.tag=<tag>

kubectl port-forward service/ak-agent-kernel-io 8000:80

05Test

Test it like any other code

The test framework starts your agent, sends it messages and checks the replies, inside pytest.

  • A session-scoped fixture keeps one conversation across ordered tests, so follow-up questions work
  • Replies are compared by string score, by an LLM judge, or by score first and the judge as a fallback
  • The same suite runs in CI against the CLI, the REST API or a container
test_my_agent.py
import pytest
import pytest_asyncio
from agentkernel.test import Test

pytestmark = pytest.mark.asyncio(loop_scope="session")

@pytest_asyncio.fixture(scope="session", loop_scope="session")
async def test_client():
test = Test("my_agent.py")
await test.start()
try:
yield test
finally:
await test.stop()

@pytest.mark.order(1)
async def test_first_question(test_client):
await test_client.send("Who won the 1996 cricket world cup?")
await test_client.expect(["Sri Lanka won the 1996 cricket world cup."])

@pytest.mark.order(2)
async def test_follow_up_question(test_client):
await test_client.send("Which country hosted the tournament?")
await test_client.expect(["Co-hosted by India, Pakistan and Sri Lanka."])

Ship your first agent today

Free and open source under Apache 2.0. No licensing costs and no lock-in.