previous_interaction_id:
collaborative_planning=True→ agent returns a research plan.collaborative_planning=True→ refine the plan (optional).collaborative_planning=False→ agent executes the approved plan.
collaborative_planning is read fresh on every request, so flipping it on the model between turns switches plan-mode to execute-mode within the same conversation.
Code
cookbook/90_models/google/gemini_interactions/deep_research_collaborative_planning.py
Mutating
agent.model.collaborative_planning mid-conversation is safe only when the model instance is not shared across concurrent runs. For concurrent use, prefer two separate agents (a planner and an executor) sharing a session.Usage
1
Set up your virtual environment
2
Set your API key
3
Install dependencies
4
Run Agent