ZDR Reasoning Agent

Code

1"""
2An example of using OpenAI Responses with reasoning features and ZDR mode enabled.
3
4Read more about ZDR mode here: https://openai.com/enterprise-privacy/.
5"""
6
7from kern.agent import Agent
8from kern.db.in_memory import InMemoryDb
9from kern.models.openai import OpenAIResponses
10
11agent = Agent(
12 name="ZDR Compliant Agent",
13 session_id="zdr_demo_session",
14 model=OpenAIResponses(
15 id="o4-mini",
16 store=False,
17 reasoning_summary="auto", # Requesting a reasoning summary
18 ),
19 instructions="You are a helpful AI assistant operating in Zero Data Retention mode for maximum privacy and compliance.",
20 db=InMemoryDb(),
21 add_history_to_context=True,
22 stream=True,
23)
24
25agent.print_response("What's the largest country in Europe by area?")
26agent.print_response("What's the population of that country?")
27agent.print_response("What's the population density per square kilometer?")

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Set your API key

1export OPENAI_API_KEY=xxx

Install dependencies

1uv pip install -U openai kern-ai

Run Agent

1python cookbook/11_models/openai/responses/zdr_reasoning_agent.py