Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: restore Deep Research plan approval (#10134)
Wasim Yousef Said71b7b30672b4
diff --git a/studio/backend/core/research_runs.py b/studio/backend/core/research_runs.pyindex 6a5fcff4d80..060c8e619b3 100644--- a/studio/backend/core/research_runs.py+++ b/studio/backend/core/research_runs.py@@ -1916,8 +1916,6 @@ class ResearchSupervisor:preview_labels = True,)plan = _parse_and_validate_plan(response, planning_reasoning, max_steps)- # Arming research in the composer is the approval, so the plan is queued as it is- # stored rather than parked for a second confirmation.try:result = await asyncio.to_thread(db.set_plan,@@ -1925,7 +1923,6 @@ class ResearchSupervisor:plan,None,self.worker_id,- auto_approve = True,)except db.ResearchConflictError:if await asyncio.to_thread(db.is_cancel_requested, run["id"]):diff --git a/studio/backend/storage/research_runs_db.py b/studio/backend/storage/research_runs_db.pyindex 34b6a05ebf5..44f7779d475 100644--- a/studio/backend/storage/research_runs_db.py+++ b/studio/backend/storage/research_runs_db.py@@ -652,18 +652,9 @@ def set_plan(plan: dict,expected_revision: int | None = None,worker_id: str | None = None,- auto_approve: bool = False,) -> dict:- """Store the plan and either park the run for review or queue it in the same write.-- Arming research in the composer is the approval, so the worker queues its own plan with- ``auto_approve``. Done in one transaction: a separate approve call left a window where- the run sat at awaiting_approval, flashing the review card and letting a concurrent plan- edit fail the run. The endpoint still parks a hand-edited plan for the user to confirm.- """raw, digest = canonical_plan(plan)steps = plan.get("steps") or []- status = "queued" if auto_approve else "awaiting_approval"conn = get_connection()try:conn.execute("BEGIN IMMEDIATE")@@ -690,9 +681,9 @@ def set_plan(revision += 1conn.execute("UPDATE research_runs SET plan_json = ?, plan_revision = ?, plan_hash = ?, "- "status = ?, error_message = NULL, lease_owner = NULL, "+ "status = 'awaiting_approval', error_message = NULL, lease_owner = NULL, ""lease_expires_at = NULL, updated_at = ? WHERE id = ?",- (raw, revision, digest, status, now_ms(), run_id),+ (raw, revision, digest, now_ms(), run_id),)conn.execute("DELETE FROM research_plan_steps WHERE run_id = ?", (run_id,))conn.executemany(@@ -707,14 +698,12 @@ def set_plan(run_id,"plan.ready",{- "status": status,+ "status": "awaiting_approval","plan": plan,"planRevision": revision,"planHash": digest,},)- if auto_approve:- _event_locked(conn, run_id, "run.approved", {"status": status})_commit_event(conn)return {"plan": plan, "planRevision": revision, "planHash": digest}except Exception:diff --git a/studio/backend/tests/test_deep_research_handoff_simulation.py b/studio/backend/tests/test_deep_research_handoff_simulation.pyindex 8c06c3fee30..6ec858b0097 100644--- a/studio/backend/tests/test_deep_research_handoff_simulation.py+++ b/studio/backend/tests/test_deep_research_handoff_simulation.py@@ -339,7 +339,7 @@ def test_the_handed_off_question_is_what_actually_gets_researched(research_home,assert RAW_MESSAGE not in prompts[0].split("Latest research request:")[-1]-def test_planning_no_longer_stops_to_ask_for_approval(research_home, monkeypatch):+def test_planning_waits_for_plan_approval_before_research(research_home, monkeypatch):from core import research_runs as workerresearch_db.create_run(@@ -371,7 +371,11 @@ def test_planning_no_longer_stops_to_ask_for_approval(research_home, monkeypatchclaimed = research_db.claim_next(supervisor.worker_id)asyncio.run(supervisor._plan(claimed))- assert research_db.get_run("run-1")["status"] == "queued"+ planned = research_db.get_run("run-1")+ assert planned["status"] == "awaiting_approval"+ assert research_db.claim_next("worker-2") is None+ assert research_db.approve("run-1", planned["planRevision"], planned["planHash"]) == "queued"+ assert research_db.claim_next("worker-2") is not None# ── What the change must not break ────────────────────────────────diff --git a/studio/backend/tests/test_research_runs_storage.py b/studio/backend/tests/test_research_runs_storage.pyindex 1b00bdc774f..764fa883d78 100644--- a/studio/backend/tests/test_research_runs_storage.py+++ b/studio/backend/tests/test_research_runs_storage.py@@ -1780,14 +1780,14 @@ def test_supervisor_planning_and_research_are_durable_with_mocked_io(planning = research_db.claim_next(supervisor.worker_id)asyncio.run(supervisor._process(planning))planned = research_db.get_run("run-1")- # Planning approves itself: arming research in the composer is the approval, so there is- # no second confirmation between the plan and the evidence gathering.- assert planned["status"] == "queued"+ assert planned["status"] == "awaiting_approval"assert planned["planRevision"] == 1assert planned["assistantMessageId"] is None+ assert research_db.claim_next(supervisor.worker_id) is None+ assert research_db.approve("run-1", planned["planRevision"], planned["planHash"]) == "queued"running = research_db.claim_next(supervisor.worker_id)- assert running is not None # planning released its lease; the queued run starts immediately+ assert running is not Noneasyncio.run(supervisor._process(running))completed = research_db.get_run("run-1")diff --git a/studio/frontend/src/features/chat/components/research-activity-panel.tsx b/studio/frontend/src/features/chat/components/research-activity-panel.tsxindex c33e95d844b..82e21edda6c 100644--- a/studio/frontend/src/features/chat/components/research-activity-panel.tsx+++ b/studio/frontend/src/features/chat/components/research-activity-panel.tsx@@ -600,7 +600,7 @@ function PlanReview({ runId }: { runId: string }): ReactElement | null {open={open}onOpenChange={(nextOpen) => setOpen(runId, nextOpen)}>- <DialogContent className="max-h-[min(680px,calc(100dvh-6rem))] grid-rows-[auto_minmax(0,1fr)_auto] gap-0 overflow-hidden p-0 sm:max-w-3xl [&>[data-slot=dialog-close]]:right-6 [&>[data-slot=dialog-close]]:top-6">+ <DialogContent className="max-h-[min(680px,calc(100dvh-6rem))] grid-rows-[auto_minmax(0,1fr)_auto] gap-0 overflow-hidden p-0 data-open:animate-none sm:max-w-3xl [&>[data-slot=dialog-close]]:right-6 [&>[data-slot=dialog-close]]:top-6"><DialogHeader className="border-b border-border/70 px-7 pb-4 pt-6 pr-16"><DialogTitle>Review the research plan</DialogTitle><DialogDescription className="max-w-2xl leading-relaxed">diff --git a/studio/frontend/tests/research-activity-progress.test.ts b/studio/frontend/tests/research-activity-progress.test.tsindex 48d9453be6a..99a52672238 100644--- a/studio/frontend/tests/research-activity-progress.test.ts+++ b/studio/frontend/tests/research-activity-progress.test.ts@@ -368,9 +368,12 @@ test("a stalled watcher does not stop events reaching the store", async () => {const iterator = watchResearchRun(RUN_ID)[Symbol.asyncIterator]();await iterator.next();+ const plan = { title: "Plan", steps: [{ title: "One", query: "q" }] };const planned = run({status: "awaiting_approval",- plan: { title: "Plan", steps: [{ title: "One", query: "q" }] },+ plan,+ planRevision: 1,+ planHash: "plan-hash",lastEventSeq: 1,});ingest(planned, event(1, "plan.ready", { planRevision: 1 }, planned));@@ -379,6 +382,13 @@ test("a stalled watcher does not stop events reaching the store", async () => {useResearchRunStore.getState().sessions[RUN_ID].run.status,"awaiting_approval",);++ assert.deepEqual(useResearchRunStore.getState().planReviewByRunId[RUN_ID], {+ revision: 1,+ open: true,+ editing: false,+ draft: plan,+ });const next = await iterator.next();assert.equal(next.value?.status, "awaiting_approval");await iterator.return?.(undefined);