In-Memory Storage for Workflows

Example using InMemoryDb with workflows for multi-step processes.

Usage

1from kern.agent import Agent
2from kern.db.in_memory import InMemoryDb
3from kern.models.openai import OpenAIResponses
4from kern.team import Team
5from kern.tools.hackernews import HackerNewsTools
6from kern.workflow.step import Step
7from kern.workflow.workflow import Workflow
8
9# Setup in-memory database
10db = InMemoryDb()
11
12# Create agents and team
13research_agent = Agent(
14 name="Research Agent",
15 model=OpenAIResponses(id="gpt-5.2"),
16 tools=[HackerNewsTools()],
17)
18
19content_agent = Agent(
20 name="Content Agent",
21 model=OpenAIResponses(id="gpt-5.2"),
22)
23
24# Define workflow steps
25research_step = Step(name="Research", agent=research_agent)
26content_step = Step(name="Content", agent=content_agent)
27
28# Create workflow
29workflow = Workflow(
30 name="Content Workflow",
31 db=db,
32 steps=[research_step, content_step],
33)
34
35workflow.print_response("AI trends in 2024")