Deep Research Multi-turn (Interactions)

Continue a Deep Research interaction across turns. Each response carries an interaction_id; the next turn references it via previous_interaction_id so only the new user message is sent on the wire. The server already has the prior research and its citations.

Persisting the interaction ID requires a database. The assistant message stores it under provider_data, and the next turn reads it back.

Code

1from kern.agent import Agent
2from kern.db.sqlite import SqliteDb
3from kern.models.google import GeminiInteractions
4
5agent = Agent(
6 model=GeminiInteractions(
7 agent="deep-research-preview-04-2026",
8 thinking_summaries="auto",
9 ),
10 add_history_to_context=True,
11 db=SqliteDb(db_file="tmp/data.db"),
12 markdown=True,
13)
14
15if __name__ == "__main__":
16 agent.print_response(
17 "Research the current state of solid-state battery commercialization "
18 "and summarize the leading approaches."
19 )
20
21 agent.print_response(
22 "Dive deeper into the sulfide-electrolyte approach: who the leading "
23 "labs and companies are, and what their reported milestones look like."
24 )
25
26 agent.print_response(
27 "Based on everything we've covered, which approach has the clearest "
28 "path to mass-market EV deployment in the next five years?"
29 )

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 GOOGLE_API_KEY=xxx

Install dependencies

1uv pip install -U "google-genai>=2.0" kern-ai

Run Agent

1python cookbook/90_models/google/gemini_interactions/deep_research_multi_turn.py