In-Memory Storage for Workflows
Store workflow sessions and run history in the current Python process with InMemoryDb.
InMemoryDb stores a Workflow's sessions and run history in the current Python process. Data is lost when the process exits.
Usage
Start in a virtual environment and set the model key before running the example.
Set OpenAI Key
Set your OPENAI_API_KEY as an environment variable. You can get one from OpenAI.
export OPENAI_API_KEY=sk-***Install dependencies:
uv pip install agno openaifrom agno.agent import Agent
from agno.db.in_memory import InMemoryDb
from agno.models.openai import OpenAIResponses
from agno.tools.hackernews import HackerNewsTools
from agno.workflow.step import Step
from agno.workflow.workflow import Workflow
db = InMemoryDb()
research_agent = Agent(
name="Research Agent",
model=OpenAIResponses(id="gpt-5.2"),
tools=[HackerNewsTools()],
)
content_agent = Agent(
name="Content Agent",
model=OpenAIResponses(id="gpt-5.2"),
)
research_step = Step(name="Research", agent=research_agent)
content_step = Step(name="Content", agent=content_agent)
workflow = Workflow(
name="Content Workflow",
db=db,
steps=[research_step, content_step],
)
workflow.print_response("Recent AI trends")Run the Example
Save the code as in_memory_for_workflow.py, complete the prerequisites above, then run:
python in_memory_for_workflow.py