Level 02 / Developers
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
OAK does not replace your framework. You define the agent the usual way, then hand it to a module.
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.
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
The same file runs as an interactive session or as an API server. Only the last line changes.
The CLI opens a session with your agent. !list shows the registered agents, !select switches between them and !quit leaves.
$ 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.
Swap CLI.main() for RESTAPI.run() and the agent answers on /api/v1/chat, with sessions kept between calls.
from agentkernel.api import RESTAPI
# ... your agent and its module line, unchanged ...
if __name__ == "__main__":
RESTAPI.run()
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
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.
Sessions start in memory and move to Redis, Valkey, DynamoDB, Cosmos DB or Firestore when you change session.type.
Choose a memory backendThe 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 guidesInput and output checks run in the same pipeline as the agent, with OpenAI, Amazon Bedrock or Walled AI as the provider.
GuardrailsOne block sends every run to Langfuse, OpenLLMetry, Pydantic Logfire or CloudWatch, with no instrumentation in your code.
Traceabilitysession:
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
04Deploy
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.
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.
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
}
}
The chart runs the IO handler and the agent runner as separate deployments, so that each scales on its own.
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
The test framework starts your agent, sends it messages and checks the replies, inside pytest.
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."])
Free and open source under Apache 2.0. No licensing costs and no lock-in.